[PATCH] selftests/tracing: support flexible helper functions
From: Gabriele Monaco
Date: Tue Jun 16 2026 - 10:26:53 EST
Target directory or file arguments passed to ftracetest had
to contain their own nested test.d/functions files to properly override
the top-level directory (TOP_DIR). This works for standard ftrace tests
that would fall back to ftrace's functions, but doesn't for rv tests.
Introduce find_functions() to recursively check parent and grandparent
directories of the target test directory/file to dynamically locate the
appropriate root functions config.
This allows to define additional directories for rv selftests and run
them with the appropriate rv functions:
ftracetest --rv tools/testing/selftests/verification/test.d/<topic>
Signed-off-by: Gabriele Monaco <gmonaco@xxxxxxxxxx>
---
tools/testing/selftests/ftrace/ftracetest | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/self=
tests/ftrace/ftracetest
index 0a56bf209f..5d1b1f9380 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -80,6 +80,23 @@ find_testcases() { #directory
echo `find $1 -name \*.tc | sort`
}
=20
+find_functions() { # [directory] [test_cases]
+ local BASE_DIR=3D"$1"
+ if [ -f "$1" ]; then
+ BASE_DIR=3D"`absdir $1`"
+ elif [ ! -d "$1" ]; then
+ return
+ fi
+
+ if [ -f "$BASE_DIR"/test.d/functions ]; then
+ echo "$BASE_DIR"
+ elif [ -f "$BASE_DIR"/../test.d/functions ]; then
+ abspath "$BASE_DIR"/..
+ elif [ -f "$BASE_DIR"/../../test.d/functions ]; then
+ abspath "$BASE_DIR"/../..
+ fi
+}
+
parse_opts() { # opts
local OPT_TEST_CASES=3D
local OPT_TEST_DIR=3D
@@ -159,7 +176,8 @@ parse_opts() { # opts
if [ -n "$OPT_TEST_CASES" ]; then
TEST_CASES=3D$OPT_TEST_CASES
fi
- if [ -n "$OPT_TEST_DIR" -a -f "$OPT_TEST_DIR"/test.d/functions ]; then
+ OPT_TEST_DIR=3D"`find_functions $OPT_TEST_DIR $OPT_TEST_CASES`"
+ if [ -n "$OPT_TEST_DIR" ]; then
TOP_DIR=3D$OPT_TEST_DIR
TEST_DIR=3D$TOP_DIR/test.d
fi
--=20
2.54.0