Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tracers tests (New) #735

Merged
merged 5 commits into from
Oct 30, 2023
Merged

Add tracers tests (New) #735

merged 5 commits into from
Oct 30, 2023

Conversation

ahresse
Copy link
Contributor

@ahresse ahresse commented Sep 18, 2023

This is an attempt to add ptrace and ftrace tests in checkbox.

Description

For a specific project at Canonical we are using checkbox and we need to check for the availability of user-space ptrace and ftrace tools in our images. Thus, we want to add a dedicated test to check this and since it could be relevant to other, this might be into base checkbox test plan.

This, PR:

  • Introduces a new dedicated unit for tracers.
  • Introduces a specific binary tool: ptrace_test (source code in C) that aims to test the ptrace() system call availability.
  • Introduces the associated test with ptrace_test.
  • Introduces a new test to check ftrace availability (based on the availability of tracefs).

A potential alternative to the usage of specific ptrace_test binary: parsing /proc/kallsyms got identified but not developed.

Resolved issues

Associated Jira ticket

Documentation

Tests

@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Merging #735 (0ef5bdc) into main (c3c3f45) will not change coverage.
Report is 1 commits behind head on main.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #735   +/-   ##
=======================================
  Coverage   34.83%   34.83%           
=======================================
  Files         302      302           
  Lines       34165    34165           
  Branches     5909     5909           
=======================================
  Hits        11903    11903           
  Misses      21697    21697           
  Partials      565      565           
Flag Coverage Δ
provider-base 3.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@ahresse ahresse marked this pull request as ready for review September 20, 2023 09:10
@ahresse
Copy link
Contributor Author

ahresse commented Sep 20, 2023

Can't assign reviewer but @zongminl and @LaiderLai should be in it.

@ahresse ahresse changed the title Add ptrace tracer test (New) Add tracers tests (New) Sep 21, 2023
@yphus
Copy link
Contributor

yphus commented Sep 26, 2023

What are the reasons why ptrace/ftrace would not be available on the base image? is it via kernel config?

I'd suggest turning the two proposed jobs into a resource job that would output something like that:

ptrace: supported
ftrace: unsupported

More tracers could be added in the future to this resource.
and have a new job that checks their availability (using the fail-on-resource flag):

id: tracers/check
category_id: tracer
_summary: ptrace and ftrace availability
_description:
  Check availability of ptrace syscall and ftrace mount (tracefs)
flags: simple fail-on-resource
command: echo "ptrace and ftrace found in the image"
requires:
  tracers.ptrace == 'supported'
  tracers.ftrace == 'supported'

@kissiel
Copy link
Contributor

kissiel commented Sep 26, 2023

What are the reasons why ptrace/ftrace would not be available on the base image? is it via kernel config?

Yep, https://github.com/torvalds/linux/blob/master/kernel/trace/Kconfig#L157

Copy link
Contributor

@kissiel kissiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. One comment about descriptions below.

providers/base/units/tracers/jobs.pxu Outdated Show resolved Hide resolved
providers/base/units/tracers/jobs.pxu Outdated Show resolved Hide resolved
@ahresse ahresse requested a review from kissiel October 2, 2023 15:17
Copy link
Contributor

@kissiel kissiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm missing something, this will not work as intended, as the resource job kernel_config_file has to be included in the test plan in the "bootstrapping_include" section, otherwise the ftrace will never run.

I've also placed some comments below.

providers/base/units/tracers/resource.pxu Outdated Show resolved Hide resolved
providers/base/units/tracers/resource.pxu Outdated Show resolved Hide resolved
Copy link
Contributor

@kissiel kissiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when any of those tests fail the error code is not propagated, so in the end this may happen:

=========[ Running job 2 / 3. Estimated time left (at least): 0:00:00 ]=========
--------------------[ Tests the ptrace tracer availability ]--------------------
ID: com.canonical.certification::tracers/ptrace                                 
Category: com.canonical.plainbox::uncategorised                                 
... 8< -------------------------------------------------------------------------
ptrace: unsupported                                                                            
------------------------------------------------------------------------- >8 ---
Outcome: job passed    
 

providers/base/units/tracers/jobs.pxu Show resolved Hide resolved
providers/base/units/tracers/jobs.pxu Show resolved Hide resolved
providers/base/units/tracers/resource.pxu Show resolved Hide resolved
@ahresse
Copy link
Contributor Author

ahresse commented Oct 26, 2023

/canonical/self-hosted-runners/run-workflows ca01039

1 similar comment
@kissiel
Copy link
Contributor

kissiel commented Oct 26, 2023

/canonical/self-hosted-runners/run-workflows ca01039

This binary is intended to check availability of ptrace features.

Signed-off-by: Alexandre Esse <[email protected]>
    This tracers unit got created because there is other possible tracers to be
tested such as ftrace.

Signed-off-by: Alexandre Esse <[email protected]>
This test check running kernel config enabled ftrace.

Signed-off-by: Alexandre Esse <[email protected]>
This test checks for tracefs file system availability.
It should be used by ftrace.

Signed-off-by: Alexandre Esse <[email protected]>
This file might be absent for different reasons:
  - disabled in kernel configuration
  - stored in a different location than the default one here (/boot/config-*)

Signed-off-by: Alexandre Esse <[email protected]>
@kissiel
Copy link
Contributor

kissiel commented Oct 26, 2023

/canonical/self-hosted-runners/run-workflows 0ef5bdc

Copy link
Contributor

@kissiel kissiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work, TYVM

@kissiel kissiel merged commit 1c88dc1 into canonical:main Oct 30, 2023
10 checks passed
@ahresse ahresse deleted the tracers branch November 16, 2023 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants