tracing: selftests: Add testing a user string to filters
Steven Rostedt
maintainerPATCH 1/1 tracing: selftests: Add testing a user string to filters
From: Steven Rostedt <[email protected]>
Running the following commands was broken:
# cd /sys/kernel/tracing # echo "filename.ustring ~ \"/proc*\"" > events/syscalls/sys_enter_openat/filter # echo 1 > events/syscalls/sys_enter_openat/enable # ls /proc/$$/maps # cat trace
And would produce nothing when it should have produced something like:
ls-1192 [007] ..... 8169.828333: sys_openat(dfd: ffffffffffffff9c, filename: 7efc18359904, flags: 80000, mode: 0)
Add a test to check this case so that it will be caught if it breaks again.
---
Shuah, I'm Cc'ing you on this for your information, but I'll take it through my tree as it will be attached with the fix, as it will fail without it.
.../test.d/filter/event-filter-function.tc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc +19 -0
@@ -80,6 +80,25 @@ if [ $misscnt -gt 0 ]; then exit_fail fi +# Check strings too +if [ -f events/syscalls/sys_enter_openat/filter ]; then + echo "filename.ustring ~ \"*test.d*\"" > events/syscalls/sys_enter_openat/filter + echo 1 > events/syscalls/sys_enter_openat/enable + echo 1 > tracing_on + ls /bin/sh + nocnt=`grep openat trace | wc -l` + ls $TEST_DIR + echo 0 > tracing_on + hitcnt=`grep openat trace | wc -l`; + echo 0 > events/syscalls/sys_enter_openat/enable + if [ $nocnt -gt 0 ]; then + exit_fail + fi + if [ $hitcnt -eq 0 ]; then + exit_fail + fi +fi + reset_events_filter exit 0
Signature · 1 line
2.47.2
Masami Hiramatsu (Google)
maintainerQuoted 31 lines · On Thu, 17 Apr 2025 22:33:23 -0400 Steven Rostedt <[email protected]> wrote:
From: Steven Rostedt <[email protected]>
Running the following commands was broken:
# cd /sys/kernel/tracing # echo "filename.ustring ~ \"/proc*\"" > events/syscalls/sys_enter_openat/filter # echo 1 > events/syscalls/sys_enter_openat/enable # ls /proc/$$/maps # cat traceAnd would produce nothing when it should have produced something like:
ls-1192 [007] ..... 8169.828333: sys_openat(dfd: ffffffffffffff9c, filename: 7efc18359904, flags: 80000, mode: 0)Add a test to check this case so that it will be caught if it breaks again.
Signed-off-by Steven Rostedt (Google) <[email protected]>---
Shuah, I'm Cc'ing you on this for your information, but I'll take it through my tree as it will be attached with the fix, as it will fail without it..../test.d/filter/event-filter-function.tc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc +0
-0
tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc if [ $misscnt -gt 0 ]; then · line 85
Quoted 6 lines
tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc +3
-0@@ -80,6 +80,25 @@ if [ $misscnt -gt 0 ]; then exit_fail fi +# Check strings too +if [ -f events/syscalls/sys_enter_openat/filter ]; then + echo "filename.ustring ~ \"*test.d*\"" > events/syscalls/sys_enter_openat/filter
I think it is better to use a $TMPDIR for the test script, instead of reusing the $TEST_DIR. Since $TMPDIR has been introduced to be used for this purpose.
DIRNAME=basename $TMPDIR
echo "filename.ustring ~ \"\*$DIRNAME\*\"" > events/syscalls/sys_enter_openat/filter
tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc if [ $misscnt -gt 0 ]; then · line 90
Quoted 5 lines
tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc +5
-0+ echo 1 > events/syscalls/sys_enter_openat/enable + echo 1 > tracing_on + ls /bin/sh + nocnt=`grep openat trace | wc -l` + ls $TEST_DIR
and ls $TMPDIR ?
Does that work?
Thank you,
Quoted 17 lines
tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc +11
-0+ echo 0 > tracing_on + hitcnt=`grep openat trace | wc -l`; + echo 0 > events/syscalls/sys_enter_openat/enable + if [ $nocnt -gt 0 ]; then + exit_fail + fi + if [ $hitcnt -eq 0 ]; then + exit_fail + fi +fi + reset_events_filter exit 0Signature · 1 line
2.47.2
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Steven Rostedt
maintainerQuoted 19 lines · On Fri, 18 Apr 2025 16:14:04 +0900 Masami Hiramatsu (Google)…
tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc if [ $misscnt -gt 0 ]; then · line 85
Quoted 2 lines
tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc +2
-0+if [ -f events/syscalls/sys_enter_openat/filter ]; then + echo "filename.ustring ~ \"*test.d*\"" > events/syscalls/sys_enter_openat/filterI think it is better to use a $TMPDIR for the test script, instead of reusing the $TEST_DIR. Since $TMPDIR has been introduced to be used for this purpose.
DIRNAME=
basename $TMPDIRecho "filename.ustring ~ \"\*$DIRNAME\*\"" > events/syscalls/sys_enter_openat/filter
tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc if [ $misscnt -gt 0 ]; then · line 90
Quoted 5 lines
tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc +5
-0+ echo 1 > events/syscalls/sys_enter_openat/enable + echo 1 > tracing_on + ls /bin/sh + nocnt=`grep openat trace | wc -l` + ls $TEST_DIRand
ls $TMPDIR?
Quoted 2 lines
Does that work?
Yeah I can do that instead.
My actual fear is that 'ls' may one day not call openat and the test fails. But if that happens we can always update the test.
Thanks,
-- Steve