Skip to content

Commit

Permalink
Add tracers tests (New) (#735)
Browse files Browse the repository at this point in the history
* Add: ptrace_test executable

This binary is intended to check availability of ptrace features.

Signed-off-by: Alexandre Esse <[email protected]>

* Add: ptrace test under new tracers unit

    This tracers unit got created because there is other possible tracers to be
tested such as ftrace.

Signed-off-by: Alexandre Esse <[email protected]>

* Add: ftrace tracer test

This test check running kernel config enabled ftrace.

Signed-off-by: Alexandre Esse <[email protected]>

* Add: tracefs file system test

This test checks for tracefs file system availability.
It should be used by ftrace.

Signed-off-by: Alexandre Esse <[email protected]>

* Add: resource for kernel config file

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]>

---------

Signed-off-by: Alexandre Esse <[email protected]>
  • Loading branch information
ahresse authored Oct 30, 2023
1 parent e2b28d8 commit 1c88dc1
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 2 deletions.
1 change: 1 addition & 0 deletions providers/base/src/EXECUTABLES
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
alsa_test
clocktest
threaded_memtest
ptrace_test
4 changes: 2 additions & 2 deletions providers/base/src/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.PHONY:
all: alsa_test clocktest threaded_memtest
all: alsa_test clocktest threaded_memtest ptrace_test

.PHONY: clean
clean:
rm -f alsa_test clocktest threaded_memtest
rm -f alsa_test clocktest threaded_memtest ptrace_test

threaded_memtest: CFLAGS += -pthread
threaded_memtest: CFLAGS += -Wno-unused-but-set-variable
Expand Down
11 changes: 11 additions & 0 deletions providers/base/src/ptrace_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <sys/ptrace.h>
#include <stdio.h>

int main() {
if (ptrace(PTRACE_TRACEME, 0, 1, 0) < 0) {
// if ptrace() call return a negative value -> fail (or program is already beeing ptraced?)
return 1;
}

return 0;
}
49 changes: 49 additions & 0 deletions providers/base/units/tracers/jobs.pxu
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
id: tracers/ptrace
plugin: shell
command:
if ptrace_test
then
echo "ptrace: supported"
exit 0
else
echo "ptrace: unsupported"
exit 1
fi
_summary:
Tests the ptrace tracer availability
_description:
The test initiates tracing using the ptrace syscall with ptrace_test binary (c source code).

id: tracers/ftrace
plugin: shell
command:
if grep -q -e "^CONFIG_FTRACE=y" /boot/config-"$(uname -r)"
then
echo "ftrace: supported"
exit 0
else
echo "ftrace: unsupported"
exit 1
fi
_summary:
Tests ftrace kernel tracing infrastructure is enable
_description:
Check if kernel configuration item CONFIG_FTRACE bool is set to 'y'.
requires:
kernel_config_file.detected == 'true'

id: tracers/tracefs
plugin: shell
command:
if mount | grep -q tracefs
then
echo "tracefs: supported"
exit 0
else
echo "ftracefs: unsupported"
exit 1
fi
_summary:
Tests the tracefs file system availability
_description:
Check if the tracefs is mounted on a system using the mount command.
12 changes: 12 additions & 0 deletions providers/base/units/tracers/resource.pxu
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
id: kernel_config_file
plugin: resource
_summary:
Kernel config file resource
command:
if [[ -f "/boot/config-$(uname -r)" ]]
then
echo "detected: true"
else
echo "detected: false"
fi
_description: Check existence of kernel config file
11 changes: 11 additions & 0 deletions providers/base/units/tracers/test-plan.pxu
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id: tracers
unit: test plan
_name: Tracers tests
_description:
Tracers tests
include:
tracers/ftrace
tracers/ptrace
tracers/tracefs
bootstrap_include:
kernel_config_file

0 comments on commit 1c88dc1

Please sign in to comment.