Skip to contentSkip to conversation

selftests/tracing: Test only toplevel README file not the instances

PATCH RESEND In review Steven Rostedt 2 participants 5 messages Feb 20, 2025

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover selftests/tracing: Test only toplevel README file not the instances

Allow some more tests to run in instances. There's a few tests that require something in README to be present to run. But currently README can't be used for instance tests. Fix that and then allow 4 more tests to run in instances.

[ RESEND to include selftest maintainers and lists:
original: https://lore.kernel.org/linux-trace-kernel/[email protected]/ ]

Steven Rostedt (3):
selftests/tracing: Test only toplevel README file not the instances selftests/ftrace: Clean up triggers after setting them selftests/tracing: Allow some more tests to run in instances

----

 tools/testing/selftests/ftrace/test.d/functions                   | 8 +++++++-
 .../test.d/trigger/inter-event/trigger-action-hist-xfail.tc       | 1 +
 .../test.d/trigger/inter-event/trigger-onchange-action-hist.tc    | 3 +++
 .../test.d/trigger/inter-event/trigger-snapshot-action-hist.tc    | 3 +++
 .../selftests/ftrace/test.d/trigger/trigger-hist-expressions.tc   | 1 +
 5 files changed, 15 insertions(+), 1 deletion(-)
author maintainer
#1 lore raw

PATCH RESEND 1/3 selftests/tracing: Test only toplevel README file not the instances

From: Steven Rostedt <[email protected]>

For the tests that have both a README attribute as well as the instance flag to run the tests as an instance, the instance version will always exit with UNSUPPORTED. That's because the instance directory does not contain a README file. Currently, the tests check for a README file in the directory that the test runs in and if there's a requirement for something to be present in the README file, it will not find it, as the instance directory doesn't have it.

Have the tests check if the current directory is an instance directory, and if it is, check two directories above the current directory for the README file:

/sys/kernel/tracing/README
/sys/kernel/tracing/instances/foo/../../README

---
 tools/testing/selftests/ftrace/test.d/functions | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/functions +7 -1
index 84d6a9c7ad67..a1052bf460fc 100644
@@ -156,7 +156,13 @@ check_requires() { # Check required files and tracers
                 exit_unsupported
             fi
         elif [ "$r" != "$i" ]; then
-            if ! grep -Fq "$r" README ; then
+	    # If this is an instance, check the top directory
+	    if echo $TRACING_DIR | grep -q "/instances/"; then
+		test="$TRACING_DIR/../.."
+	    else
+		test=$TRACING_DIR
+	    fi
+            if ! grep -Fq "$r" $test/README ; then
                 echo "Required feature pattern \"$r\" is not in README."
                 exit_unsupported
             fi
Signature · 1 line
2.47.2
author maintainer
#2 lore raw

PATCH RESEND 2/3 selftests/ftrace: Clean up triggers after setting them

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

The triggers set in trigger-onchange-action-hist.tc and trigger-snapshot-action-hist.tc are not cleaned up at the end. These tests can also be done in instances and without cleaning up the triggers, the instances can not be removed as they are still "busy".

---
 .../test.d/trigger/inter-event/trigger-onchange-action-hist.tc  | 2 ++
 .../test.d/trigger/inter-event/trigger-snapshot-action-hist.tc  | 2 ++
 2 files changed, 4 insertions(+)
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc +2 -0
index 91339c130832..2430f541cd5d 100644
@@ -19,4 +19,6 @@ if ! grep -q "changed:" events/sched/sched_waking/hist; then
     fail "Failed to create onchange action inter-event histogram"
 fi
 
+echo '!hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio) if comm=="ping"' >> events/sched/sched_waking/trigger
+
 exit 0
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc +2 -0
index 147967e86584..334595daa9f4 100644
@@ -27,4 +27,6 @@ if ! grep -q "comm=ping" snapshot; then
     fail "Failed to create snapshot action inter-event histogram"
 fi
 
+echo '!hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio):onchange($newprio).snapshot() if comm=="ping"' >> events/sched/sched_waking/trigger
+
 exit 0
Signature · 1 line
2.47.2
author maintainer
#3 lore raw

PATCH RESEND 3/3 selftests/tracing: Allow some more tests to run in instances

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

The tests:

trigger-action-hist-xfail.tc
trigger-onchange-action-hist.tc
trigger-snapshot-action-hist.tc
trigger-hist-expressions.tc

can all run in an instance. Test them in an instance as well.

---
 .../test.d/trigger/inter-event/trigger-action-hist-xfail.tc      | 1 +
 .../test.d/trigger/inter-event/trigger-onchange-action-hist.tc   | 1 +
 .../test.d/trigger/inter-event/trigger-snapshot-action-hist.tc   | 1 +
 .../selftests/ftrace/test.d/trigger/trigger-hist-expressions.tc  | 1 +
 4 files changed, 4 insertions(+)
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-action-hist-xfail.tc +1 -0
index 1590d6bfb857..20a35fea13f8 100644
@@ -2,6 +2,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # description: event trigger - test inter-event histogram trigger expected fail actions
 # requires: set_event snapshot "snapshot()":README
+# flags: instance
 
 fail() { #msg
     echo $1
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc +1 -0
index 2430f541cd5d..55ab0270e5f7 100644
@@ -2,6 +2,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # description: event trigger - test inter-event histogram trigger onchange action
 # requires: set_event "onchange(var)":README ping:program
+# flags: instance
 
 fail() { #msg
     echo $1
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc +1 -0
index 334595daa9f4..9eb37c2fa417 100644
@@ -2,6 +2,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # description: event trigger - test inter-event histogram trigger snapshot action
 # requires: set_event snapshot events/sched/sched_process_fork/hist "onchange(var)":README "snapshot()":README ping:program
+# flags: instance
 
 fail() { #msg
     echo $1
tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-expressions.tc +1 -0
index 05ffba299dbf..0ebda2068a00 100644
@@ -2,6 +2,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # description: event trigger - test histogram expression parsing
 # requires: set_event events/sched/sched_process_fork/trigger events/sched/sched_process_fork/hist error_log "<var1>=<field|var_ref|numeric_literal>":README
+# flags: instance
 
 
 fail() { #msg
Signature · 1 line
2.47.2
maintainer
#4 lore raw
In reply to Steven Rostedt
Quoted 14 lines · Steven Rostedt

Allow some more tests to run in instances. There's a few tests that require something in README to be present to run. But currently README can't be used for instance tests. Fix that and then allow 4 more tests to run in instances.

[ RESEND to include selftest maintainers and lists:

   original: https://lore.kernel.org/linux-trace-kernel/[email protected]/ ]

Steven Rostedt (3):
selftests/tracing: Test only toplevel README file not the instances selftests/ftrace: Clean up triggers after setting them selftests/tracing: Allow some more tests to run in instances

Quoted 7 lines

----

  tools/testing/selftests/ftrace/test.d/functions                   | 8 +++++++-
  .../test.d/trigger/inter-event/trigger-action-hist-xfail.tc       | 1 +
  .../test.d/trigger/inter-event/trigger-onchange-action-hist.tc    | 3 +++
  .../test.d/trigger/inter-event/trigger-snapshot-action-hist.tc    | 3 +++
  .../selftests/ftrace/test.d/trigger/trigger-hist-expressions.tc   | 1 +
  5 files changed, 15 insertions(+), 1 deletion(-)

Thanks - applied for Linux 6.15-rc1

thanks,
-- Shuah