linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] selftests/verification: Add initial RV tests
@ 2025-09-26  9:46 Gabriele Monaco
  2025-09-26  9:46 ` [PATCH 1/2] selftest/ftrace: Generalise ftracetest to use with RV Gabriele Monaco
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Gabriele Monaco @ 2025-09-26  9:46 UTC (permalink / raw)
  To: linux-kernel, Steven Rostedt, Nam Cao
  Cc: Gabriele Monaco, Masami Hiramatsu, John Kacur, Waylon Cude,
	linux-trace-kernel, linux-kselftest

Add a series of tests to validate the RV tracefs API and basic
functionality.

* available monitors:
    Check that all monitors (from the monitors folder) appear as
    available and have a description. Works with nested monitors.

* enable/disable:
    Enable and disable all monitors and validate both the enabled file
    and the enabled_monitors. Check that enabling container monitors
    enables all nested monitors.

* reactors:
    Set all reactors and validate the setting, also for nested monitors.

* wwnr with printk:
    wwnr is broken on purpose, run it with a load and check that the
    printk reactor works. Also validate disabling reacting_on or
    monitoring_on prevents reactions.

These tests use the ftracetest suite. The first patch of the series
adapts ftracetest to make this possible.

The enable/disable test cannot pass on upstream without the application
of the fix in [1].

[1] - https://lore.kernel.org/lkml/87tt0t4u19.fsf@yellow.woof

To: Steven Rostedt <rostedt@goodmis.org>
To: Nam Cao <namcao@linutronix.de>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: John Kacur <jkacur@redhat.com>
Cc: Waylon Cude <wcude@redhat.com>
Cc: linux-trace-kernel@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org

Gabriele Monaco (2):
  selftest/ftrace: Generalise ftracetest to use with RV
  selftests/verification: Add initial RV tests

 MAINTAINERS                                   |  1 +
 tools/testing/selftests/ftrace/ftracetest     | 34 ++++++---
 .../ftrace/test.d/00basic/mount_options.tc    |  2 +-
 .../testing/selftests/ftrace/test.d/functions |  6 +-
 .../testing/selftests/verification/.gitignore |  2 +
 tools/testing/selftests/verification/Makefile |  8 ++
 tools/testing/selftests/verification/config   |  1 +
 tools/testing/selftests/verification/settings |  1 +
 .../selftests/verification/test.d/functions   | 39 ++++++++++
 .../test.d/rv_monitor_enable_disable.tc       | 75 +++++++++++++++++++
 .../verification/test.d/rv_monitor_reactor.tc | 68 +++++++++++++++++
 .../test.d/rv_monitors_available.tc           | 18 +++++
 .../verification/test.d/rv_wwnr_printk.tc     | 29 +++++++
 .../verification/verificationtest-ktap        |  8 ++
 14 files changed, 278 insertions(+), 14 deletions(-)
 create mode 100644 tools/testing/selftests/verification/.gitignore
 create mode 100644 tools/testing/selftests/verification/Makefile
 create mode 100644 tools/testing/selftests/verification/config
 create mode 100644 tools/testing/selftests/verification/settings
 create mode 100644 tools/testing/selftests/verification/test.d/functions
 create mode 100644 tools/testing/selftests/verification/test.d/rv_monitor_enable_disable.tc
 create mode 100644 tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc
 create mode 100644 tools/testing/selftests/verification/test.d/rv_monitors_available.tc
 create mode 100644 tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
 create mode 100644 tools/testing/selftests/verification/verificationtest-ktap


base-commit: cec1e6e5d1ab33403b809f79cd20d6aff124ccfe
-- 
2.51.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] selftest/ftrace: Generalise ftracetest to use with RV
  2025-09-26  9:46 [PATCH 0/2] selftests/verification: Add initial RV tests Gabriele Monaco
@ 2025-09-26  9:46 ` Gabriele Monaco
  2025-09-26  9:46 ` [PATCH 2/2] selftests/verification: Add initial RV tests Gabriele Monaco
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Gabriele Monaco @ 2025-09-26  9:46 UTC (permalink / raw)
  To: linux-kernel, Steven Rostedt, Masami Hiramatsu, Shuah Khan,
	linux-trace-kernel, linux-kselftest
  Cc: Gabriele Monaco, Nam Cao, John Kacur, Waylon Cude

The ftracetest script is a fairly complete test framework for tracefs-like
subsystem, but it can only be used for ftrace selftests.

If OPT_TEST_DIR is provided and includes a function file, use that as
test directory going forward rather than just grabbing tests from it.

Generalise function names like initialize_ftrace to initialize_system.

Add the --rv argument to set up the test for rv, basically changing the
trace directory to $TRACING_DIR/rv and displaying an error if that
cannot be found.

This prepares for rv selftests inclusion.

Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---
 tools/testing/selftests/ftrace/ftracetest     | 34 +++++++++++++------
 .../ftrace/test.d/00basic/mount_options.tc    |  2 +-
 .../testing/selftests/ftrace/test.d/functions |  6 ++--
 3 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index cce72f8b03dc..3230bd54dba8 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -22,6 +22,7 @@ echo "		--fail-unresolved Treat UNRESOLVED as a failure"
 echo "		-d|--debug Debug mode (trace all shell commands)"
 echo "		-l|--logdir <dir> Save logs on the <dir>"
 echo "		            If <dir> is -, all logs output in console only"
+echo "		--rv       Run RV selftests instead of ftrace ones"
 exit $1
 }
 
@@ -133,6 +134,10 @@ parse_opts() { # opts
       LINK_PTR=
       shift 2
     ;;
+    --rv)
+      RV_TEST=1
+      shift 1
+    ;;
     *.tc)
       if [ -f "$1" ]; then
         OPT_TEST_CASES="$OPT_TEST_CASES `abspath $1`"
@@ -152,9 +157,13 @@ parse_opts() { # opts
     ;;
     esac
   done
-  if [ ! -z "$OPT_TEST_CASES" ]; then
+  if [ -n "$OPT_TEST_CASES" ]; then
     TEST_CASES=$OPT_TEST_CASES
   fi
+  if [ -n "$OPT_TEST_DIR" -a -f "$OPT_TEST_DIR"/test.d/functions ]; then
+    TOP_DIR=$OPT_TEST_DIR
+    TEST_DIR=$TOP_DIR/test.d
+  fi
 }
 
 # Parameters
@@ -190,10 +199,6 @@ fi
 TOP_DIR=`absdir $0`
 TEST_DIR=$TOP_DIR/test.d
 TEST_CASES=`find_testcases $TEST_DIR`
-LOG_TOP_DIR=$TOP_DIR/logs
-LOG_DATE=`date +%Y%m%d-%H%M%S`
-LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
-LINK_PTR=$LOG_TOP_DIR/latest
 KEEP_LOG=0
 KTAP=0
 DEBUG=0
@@ -201,14 +206,23 @@ VERBOSE=0
 UNSUPPORTED_RESULT=0
 UNRESOLVED_RESULT=0
 STOP_FAILURE=0
+RV_TEST=0
 # Parse command-line options
 parse_opts $*
 
+LOG_TOP_DIR=$TOP_DIR/logs
+LOG_DATE=`date +%Y%m%d-%H%M%S`
+LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
+LINK_PTR=$LOG_TOP_DIR/latest
+
 [ $DEBUG -ne 0 ] && set -x
 
-# Verify parameters
-if [ -z "$TRACING_DIR" -o ! -d "$TRACING_DIR" ]; then
-  errexit "No ftrace directory found"
+if [ $RV_TEST -ne 0 ]; then
+	TRACING_DIR=$TRACING_DIR/rv
+	if [ ! -d "$TRACING_DIR" ]; then
+		err_ret=$err_skip
+		errexit "rv is not configured in this kernel"
+	fi
 fi
 
 # Preparing logs
@@ -419,7 +433,7 @@ trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL
 __run_test() { # testfile
   # setup PID and PPID, $$ is not updated.
   (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x;
-   checkreq $1; initialize_ftrace; . $1)
+   checkreq $1; initialize_system; . $1)
   [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID
 }
 
@@ -496,7 +510,7 @@ for t in $TEST_CASES; do
     exit 1
   fi
 done
-(cd $TRACING_DIR; finish_ftrace) # for cleanup
+(cd $TRACING_DIR; finish_system) # for cleanup
 
 prlog ""
 prlog "# of passed: " `echo $PASSED_CASES | wc -w`
diff --git a/tools/testing/selftests/ftrace/test.d/00basic/mount_options.tc b/tools/testing/selftests/ftrace/test.d/00basic/mount_options.tc
index 8a7ce647a60d..318939451caf 100644
--- a/tools/testing/selftests/ftrace/test.d/00basic/mount_options.tc
+++ b/tools/testing/selftests/ftrace/test.d/00basic/mount_options.tc
@@ -28,7 +28,7 @@ unmount_tracefs() {
 	local mount_point="$1"
 
 	# Need to make sure the mount isn't busy so that we can umount it
-	(cd $mount_point; finish_ftrace;)
+	(cd $mount_point; finish_system;)
 
 	cleanup
 }
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index a1052bf460fc..e8e718139294 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -104,7 +104,7 @@ clear_dynamic_events() { # reset all current dynamic events
     done
 }
 
-initialize_ftrace() { # Reset ftrace to initial-state
+initialize_system() { # Reset ftrace to initial-state
 # As the initial state, ftrace will be set to nop tracer,
 # no events, no triggers, no filters, no function filters,
 # no probes, and tracing on.
@@ -134,8 +134,8 @@ initialize_ftrace() { # Reset ftrace to initial-state
     enable_tracing
 }
 
-finish_ftrace() {
-    initialize_ftrace
+finish_system() {
+    initialize_system
 # And recover it to default.
     [ -f options/pause-on-trace ] && echo 0 > options/pause-on-trace
 }
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] selftests/verification: Add initial RV tests
  2025-09-26  9:46 [PATCH 0/2] selftests/verification: Add initial RV tests Gabriele Monaco
  2025-09-26  9:46 ` [PATCH 1/2] selftest/ftrace: Generalise ftracetest to use with RV Gabriele Monaco
@ 2025-09-26  9:46 ` Gabriele Monaco
  2025-10-13 11:51 ` [PATCH 0/2] " Gabriele Monaco
  2025-10-17  7:38 ` Nam Cao
  3 siblings, 0 replies; 7+ messages in thread
From: Gabriele Monaco @ 2025-09-26  9:46 UTC (permalink / raw)
  To: linux-kernel, Steven Rostedt, Gabriele Monaco, Shuah Khan,
	linux-trace-kernel, linux-kselftest
  Cc: Nam Cao, Masami Hiramatsu, John Kacur, Waylon Cude

Add a series of tests to validate the RV tracefs API and basic
functionality.

* available monitors:
    Check that all monitors (from the monitors folder) appear as
    available and have a description. Works with nested monitors.

* enable/disable:
    Enable and disable all monitors and validate both the enabled file
    and the enabled_monitors. Check that enabling container monitors
    enables all nested monitors.

* reactors:
    Set all reactors and validate the setting, also for nested monitors.

* wwnr with printk:
    wwnr is broken on purpose, run it with a load and check that the
    printk reactor works. Also validate disabling reacting_on or
    monitoring_on prevents reactions.

These tests use the ftracetest suite.

Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---
 MAINTAINERS                                   |  1 +
 .../testing/selftests/verification/.gitignore |  2 +
 tools/testing/selftests/verification/Makefile |  8 ++
 tools/testing/selftests/verification/config   |  1 +
 tools/testing/selftests/verification/settings |  1 +
 .../selftests/verification/test.d/functions   | 39 ++++++++++
 .../test.d/rv_monitor_enable_disable.tc       | 75 +++++++++++++++++++
 .../verification/test.d/rv_monitor_reactor.tc | 68 +++++++++++++++++
 .../test.d/rv_monitors_available.tc           | 18 +++++
 .../verification/test.d/rv_wwnr_printk.tc     | 29 +++++++
 .../verification/verificationtest-ktap        |  8 ++
 11 files changed, 250 insertions(+)
 create mode 100644 tools/testing/selftests/verification/.gitignore
 create mode 100644 tools/testing/selftests/verification/Makefile
 create mode 100644 tools/testing/selftests/verification/config
 create mode 100644 tools/testing/selftests/verification/settings
 create mode 100644 tools/testing/selftests/verification/test.d/functions
 create mode 100644 tools/testing/selftests/verification/test.d/rv_monitor_enable_disable.tc
 create mode 100644 tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc
 create mode 100644 tools/testing/selftests/verification/test.d/rv_monitors_available.tc
 create mode 100644 tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
 create mode 100644 tools/testing/selftests/verification/verificationtest-ktap

diff --git a/MAINTAINERS b/MAINTAINERS
index 520fb4e379a3..50e2e99e8c0c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22059,6 +22059,7 @@ F:	Documentation/trace/rv/
 F:	include/linux/rv.h
 F:	include/rv/
 F:	kernel/trace/rv/
+F:	tools/testing/selftests/verification/
 F:	tools/verification/
 
 RUST
diff --git a/tools/testing/selftests/verification/.gitignore b/tools/testing/selftests/verification/.gitignore
new file mode 100644
index 000000000000..2659417cb2c7
--- /dev/null
+++ b/tools/testing/selftests/verification/.gitignore
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+logs
diff --git a/tools/testing/selftests/verification/Makefile b/tools/testing/selftests/verification/Makefile
new file mode 100644
index 000000000000..aa8790c22a71
--- /dev/null
+++ b/tools/testing/selftests/verification/Makefile
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+all:
+
+TEST_PROGS := verificationtest-ktap
+TEST_FILES := test.d settings
+EXTRA_CLEAN := $(OUTPUT)/logs/*
+
+include ../lib.mk
diff --git a/tools/testing/selftests/verification/config b/tools/testing/selftests/verification/config
new file mode 100644
index 000000000000..43072c1c38f4
--- /dev/null
+++ b/tools/testing/selftests/verification/config
@@ -0,0 +1 @@
+CONFIG_RV=y
diff --git a/tools/testing/selftests/verification/settings b/tools/testing/selftests/verification/settings
new file mode 100644
index 000000000000..e7b9417537fb
--- /dev/null
+++ b/tools/testing/selftests/verification/settings
@@ -0,0 +1 @@
+timeout=0
diff --git a/tools/testing/selftests/verification/test.d/functions b/tools/testing/selftests/verification/test.d/functions
new file mode 100644
index 000000000000..ec36a092f56e
--- /dev/null
+++ b/tools/testing/selftests/verification/test.d/functions
@@ -0,0 +1,39 @@
+check_requires() { # Check required files, monitors and reactors
+	for i in "$@" ; do
+		p=${i%:program}
+		m=${i%:monitor}
+		r=${i%:reactor}
+		if [ $p != $i ]; then
+			if ! which $p ; then
+				echo "Required program $p is not found."
+				exit_unresolved
+			fi
+		elif [ $m != $i ]; then
+			if ! grep -wq $m available_monitors ; then
+				echo "Required monitor $m is not configured."
+				exit_unsupported
+			fi
+		elif [ $r != $i ]; then
+			if ! grep -wq $r available_reactors ; then
+				echo "Required reactor $r is not configured."
+				exit_unsupported
+			fi
+		elif [ ! -e $i ]; then
+			echo "Required feature interface $i doesn't exist."
+			exit_unsupported
+		fi
+	done
+}
+
+initialize_system() { # Reset RV to initial-state
+	echo > enabled_monitors
+	for m in monitors/*; do
+		echo nop > $m/reactors || true
+	done
+	echo 1 > monitoring_on
+	echo 1 > reacting_on || true
+}
+
+finish_system() {
+	initialize_system
+}
diff --git a/tools/testing/selftests/verification/test.d/rv_monitor_enable_disable.tc b/tools/testing/selftests/verification/test.d/rv_monitor_enable_disable.tc
new file mode 100644
index 000000000000..f29236defb5a
--- /dev/null
+++ b/tools/testing/selftests/verification/test.d/rv_monitor_enable_disable.tc
@@ -0,0 +1,75 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# description: Test monitor enable/disable
+
+test_simple_monitor() {
+    local monitor="$1"
+    local prefix="$2" # nested monitors
+
+    echo 1 > "monitors/$prefix$monitor/enable"
+    grep -q "$monitor$" enabled_monitors
+
+    echo 0 > "monitors/$prefix$monitor/enable"
+    ! grep -q "$monitor$" enabled_monitors
+
+    echo "$monitor" >> enabled_monitors
+    grep -q 1 "monitors/$prefix$monitor/enable"
+
+    echo "!$monitor" >> enabled_monitors
+    grep -q 0 "monitors/$prefix$monitor/enable"
+}
+
+test_container_monitor() {
+    local monitor="$1"
+	local nested
+
+    echo 1 > "monitors/$monitor/enable"
+    grep -q "^$monitor$" enabled_monitors
+
+    for nested_dir in "monitors/$monitor"/*; do
+        [ -d "$nested_dir" ] || continue
+        nested=$(basename "$nested_dir")
+        grep -q "^$monitor:$nested$" enabled_monitors
+    done
+	test -n "$nested"
+
+    echo 0 > "monitors/$monitor/enable"
+    ! grep -q "^$monitor$" enabled_monitors
+
+    for nested_dir in "monitors/$monitor"/*; do
+        [ -d "$nested_dir" ] || continue
+        nested=$(basename "$nested_dir")
+        ! grep -q "^$monitor:$nested$" enabled_monitors
+    done
+
+    echo "$monitor" >> enabled_monitors
+    grep -q 1 "monitors/$monitor/enable"
+
+    for nested_dir in "monitors/$monitor"/*; do
+        [ -d "$nested_dir" ] || continue
+        nested=$(basename "$nested_dir")
+        grep -q "^$monitor:$nested$" enabled_monitors
+    done
+
+    echo "!$monitor" >> enabled_monitors
+    grep -q 0 "monitors/$monitor/enable"
+
+    for nested_dir in "monitors/$monitor"/*; do
+        [ -d "$nested_dir" ] || continue
+        nested=$(basename "$nested_dir")
+		test_simple_monitor "$nested" "$monitor/"
+    done
+}
+
+for monitor_dir in monitors/*; do
+    monitor=$(basename "$monitor_dir")
+
+    if find "$monitor_dir" -mindepth 1 -type d | grep -q .; then
+        test_container_monitor "$monitor"
+    else
+        test_simple_monitor "$monitor"
+    fi
+done
+
+! echo non_existent_monitor > enabled_monitors
+! grep -q "^non_existent_monitor$" enabled_monitors
diff --git a/tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc b/tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc
new file mode 100644
index 000000000000..2958bf849338
--- /dev/null
+++ b/tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc
@@ -0,0 +1,68 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# description: Test monitor reactor setting
+# requires: available_reactors
+
+test_monitor_reactor() {
+    local monitor="$1"
+    local prefix="$2" # nested monitors
+
+    while read -r reactor; do
+        [ "$reactor" = nop ] && continue
+
+        echo "$reactor" > "monitors/$prefix$monitor/reactors"
+        grep -q "\\[$reactor\\]" "monitors/$prefix$monitor/reactors"
+    done < available_reactors
+
+    echo nop > "monitors/$prefix$monitor/reactors"
+    grep -q "\\[nop\\]" "monitors/$prefix$monitor/reactors"
+}
+
+test_container_monitor() {
+    local monitor="$1"
+	local nested
+
+    while read -r reactor; do
+        [ "$reactor" = nop ] && continue
+
+        echo "$reactor" > "monitors/$monitor/reactors"
+        grep -q "\\[$reactor\\]" "monitors/$monitor/reactors"
+
+        for nested_dir in "monitors/$monitor"/*; do
+            [ -d "$nested_dir" ] || continue
+            nested=$(basename "$nested_dir")
+            grep -q "\\[$reactor\\]" "monitors/$monitor/$nested/reactors"
+        done
+    done < available_reactors
+	test -n "$nested"
+
+    echo nop > "monitors/$monitor/reactors"
+    grep -q "\\[nop\\]" "monitors/$monitor/reactors"
+
+    for nested_dir in "monitors/$monitor"/*; do
+        [ -d "$nested_dir" ] || continue
+        nested=$(basename "$nested_dir")
+        grep -q "\\[nop\\]" "monitors/$monitor/$nested/reactors"
+    done
+
+    for nested_dir in "monitors/$monitor"/*; do
+        [ -d "$nested_dir" ] || continue
+        nested=$(basename "$nested_dir")
+        test_monitor_reactor "$nested" "$monitor/"
+    done
+}
+
+for monitor_dir in monitors/*; do
+    monitor=$(basename "$monitor_dir")
+
+    if find "$monitor_dir" -mindepth 1 -type d | grep -q .; then
+        test_container_monitor "$monitor"
+    else
+        test_monitor_reactor "$monitor"
+    fi
+done
+
+monitor=$(ls /sys/kernel/tracing/rv/monitors -1 | head -n 1)
+test -f "monitors/$monitor/reactors"
+! echo non_existent_reactor > "monitors/$monitor/reactors"
+! grep -q "\\[non_existent_reactor\\]" "monitors/$monitor/reactors"
diff --git a/tools/testing/selftests/verification/test.d/rv_monitors_available.tc b/tools/testing/selftests/verification/test.d/rv_monitors_available.tc
new file mode 100644
index 000000000000..e6a4a1410690
--- /dev/null
+++ b/tools/testing/selftests/verification/test.d/rv_monitors_available.tc
@@ -0,0 +1,18 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# description: Check available monitors
+
+for monitor_dir in monitors/*; do
+    monitor=$(basename "$monitor_dir")
+
+    grep -q "^$monitor$" available_monitors
+    grep -q . "$monitor_dir"/desc
+
+    for nested_dir in "$monitor_dir"/*; do
+        [ -d "$nested_dir" ] || continue
+        nested=$(basename "$nested_dir")
+
+        grep -q "^$monitor:$nested$" available_monitors
+		grep -q . "$nested_dir"/desc
+    done
+done
diff --git a/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc b/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
new file mode 100644
index 000000000000..bc0b2668bf7c
--- /dev/null
+++ b/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
@@ -0,0 +1,29 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# description: Test wwnr monitor with printk reactor
+# requires: available_reactors wwnr:monitor printk:reactor stress-ng:program
+
+load() { # returns true if there was a reaction
+	local lines_before
+	lines_before=$(dmesg | wc -l)
+	stress-ng --cpu-sched 2 --timer 2 -t 5 -q
+	dmesg | tail -n $((lines_before + 1)) | grep -q "rv: monitor wwnr does not allow event"
+}
+
+echo 1 > monitors/wwnr/enable
+echo printk > monitors/wwnr/reactors
+
+load
+
+echo 0 > monitoring_on
+! load
+echo 1 > monitoring_on
+
+load
+
+echo 0 > reacting_on
+! load
+echo 1 > reacting_on
+
+echo nop > monitors/wwnr/reactors
+echo 0 > monitors/wwnr/enable
diff --git a/tools/testing/selftests/verification/verificationtest-ktap b/tools/testing/selftests/verification/verificationtest-ktap
new file mode 100644
index 000000000000..18f7fe324e2f
--- /dev/null
+++ b/tools/testing/selftests/verification/verificationtest-ktap
@@ -0,0 +1,8 @@
+#!/bin/sh -e
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# ftracetest-ktap: Wrapper to integrate ftracetest with the kselftest runner
+#
+# Copyright (C) Arm Ltd., 2023
+
+../ftrace/ftracetest -K -v --rv ../verification
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] selftests/verification: Add initial RV tests
  2025-09-26  9:46 [PATCH 0/2] selftests/verification: Add initial RV tests Gabriele Monaco
  2025-09-26  9:46 ` [PATCH 1/2] selftest/ftrace: Generalise ftracetest to use with RV Gabriele Monaco
  2025-09-26  9:46 ` [PATCH 2/2] selftests/verification: Add initial RV tests Gabriele Monaco
@ 2025-10-13 11:51 ` Gabriele Monaco
  2025-10-13 11:56   ` Nam Cao
  2025-10-17  7:38 ` Nam Cao
  3 siblings, 1 reply; 7+ messages in thread
From: Gabriele Monaco @ 2025-10-13 11:51 UTC (permalink / raw)
  To: linux-kernel, Steven Rostedt, Nam Cao
  Cc: Masami Hiramatsu, John Kacur, Waylon Cude, linux-trace-kernel,
	linux-kselftest

On Fri, 2025-09-26 at 11:46 +0200, Gabriele Monaco wrote:
> Add a series of tests to validate the RV tracefs API and basic
> functionality.
> 
> * available monitors:
>     Check that all monitors (from the monitors folder) appear as
>     available and have a description. Works with nested monitors.
> 
> * enable/disable:
>     Enable and disable all monitors and validate both the enabled file
>     and the enabled_monitors. Check that enabling container monitors
>     enables all nested monitors.
> 
> * reactors:
>     Set all reactors and validate the setting, also for nested monitors.
> 
> * wwnr with printk:
>     wwnr is broken on purpose, run it with a load and check that the
>     printk reactor works. Also validate disabling reacting_on or
>     monitoring_on prevents reactions.
> 
> These tests use the ftracetest suite. The first patch of the series
> adapts ftracetest to make this possible.
> 
> The enable/disable test cannot pass on upstream without the application
> of the fix in [1].

Steve, Nam, would you have time to have a look at this series.
If possible, I'd like to get this minimal selftest to next together with Nam's
(urgent) patches.

Thanks,
Gabriele

> 
> [1] - https://lore.kernel.org/lkml/87tt0t4u19.fsf@yellow.woof
> 
> To: Steven Rostedt <rostedt@goodmis.org>
> To: Nam Cao <namcao@linutronix.de>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: John Kacur <jkacur@redhat.com>
> Cc: Waylon Cude <wcude@redhat.com>
> Cc: linux-trace-kernel@vger.kernel.org
> Cc: linux-kselftest@vger.kernel.org
> 
> Gabriele Monaco (2):
>   selftest/ftrace: Generalise ftracetest to use with RV
>   selftests/verification: Add initial RV tests
> 
>  MAINTAINERS                                   |  1 +
>  tools/testing/selftests/ftrace/ftracetest     | 34 ++++++---
>  .../ftrace/test.d/00basic/mount_options.tc    |  2 +-
>  .../testing/selftests/ftrace/test.d/functions |  6 +-
>  .../testing/selftests/verification/.gitignore |  2 +
>  tools/testing/selftests/verification/Makefile |  8 ++
>  tools/testing/selftests/verification/config   |  1 +
>  tools/testing/selftests/verification/settings |  1 +
>  .../selftests/verification/test.d/functions   | 39 ++++++++++
>  .../test.d/rv_monitor_enable_disable.tc       | 75 +++++++++++++++++++
>  .../verification/test.d/rv_monitor_reactor.tc | 68 +++++++++++++++++
>  .../test.d/rv_monitors_available.tc           | 18 +++++
>  .../verification/test.d/rv_wwnr_printk.tc     | 29 +++++++
>  .../verification/verificationtest-ktap        |  8 ++
>  14 files changed, 278 insertions(+), 14 deletions(-)
>  create mode 100644 tools/testing/selftests/verification/.gitignore
>  create mode 100644 tools/testing/selftests/verification/Makefile
>  create mode 100644 tools/testing/selftests/verification/config
>  create mode 100644 tools/testing/selftests/verification/settings
>  create mode 100644 tools/testing/selftests/verification/test.d/functions
>  create mode 100644
> tools/testing/selftests/verification/test.d/rv_monitor_enable_disable.tc
>  create mode 100644
> tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc
>  create mode 100644
> tools/testing/selftests/verification/test.d/rv_monitors_available.tc
>  create mode 100644
> tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
>  create mode 100644 tools/testing/selftests/verification/verificationtest-ktap
> 
> 
> base-commit: cec1e6e5d1ab33403b809f79cd20d6aff124ccfe


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] selftests/verification: Add initial RV tests
  2025-10-13 11:51 ` [PATCH 0/2] " Gabriele Monaco
@ 2025-10-13 11:56   ` Nam Cao
  0 siblings, 0 replies; 7+ messages in thread
From: Nam Cao @ 2025-10-13 11:56 UTC (permalink / raw)
  To: Gabriele Monaco, linux-kernel, Steven Rostedt
  Cc: Masami Hiramatsu, John Kacur, Waylon Cude, linux-trace-kernel,
	linux-kselftest

Gabriele Monaco <gmonaco@redhat.com> writes:
> Steve, Nam, would you have time to have a look at this series.
> If possible, I'd like to get this minimal selftest to next together with Nam's
> (urgent) patches.

Right, I completely forgot that this exists.

I am at the final steps in another project, should be able to look at
this tomorrow.

Nam

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] selftests/verification: Add initial RV tests
  2025-09-26  9:46 [PATCH 0/2] selftests/verification: Add initial RV tests Gabriele Monaco
                   ` (2 preceding siblings ...)
  2025-10-13 11:51 ` [PATCH 0/2] " Gabriele Monaco
@ 2025-10-17  7:38 ` Nam Cao
  2025-10-17  8:50   ` Gabriele Monaco
  3 siblings, 1 reply; 7+ messages in thread
From: Nam Cao @ 2025-10-17  7:38 UTC (permalink / raw)
  To: Gabriele Monaco, linux-kernel, Steven Rostedt
  Cc: Gabriele Monaco, Masami Hiramatsu, John Kacur, Waylon Cude,
	linux-trace-kernel, linux-kselftest

Gabriele Monaco <gmonaco@redhat.com> writes:
> Add a series of tests to validate the RV tracefs API and basic
> functionality.

Thanks for the writing this test. My bash knowledge is not great, and
I'm not familiar with the existing ftrace test, so I am not able to
review all the details. But looks good as far as I can tell:

Acked-by: Nam Cao <namcao@linutronix.de>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] selftests/verification: Add initial RV tests
  2025-10-17  7:38 ` Nam Cao
@ 2025-10-17  8:50   ` Gabriele Monaco
  0 siblings, 0 replies; 7+ messages in thread
From: Gabriele Monaco @ 2025-10-17  8:50 UTC (permalink / raw)
  To: Nam Cao, linux-kernel, Steven Rostedt
  Cc: Masami Hiramatsu, John Kacur, Waylon Cude, linux-trace-kernel,
	linux-kselftest

On Fri, 2025-10-17 at 09:38 +0200, Nam Cao wrote:
> Gabriele Monaco <gmonaco@redhat.com> writes:
> > Add a series of tests to validate the RV tracefs API and basic
> > functionality.
> 
> Thanks for the writing this test. My bash knowledge is not great, and
> I'm not familiar with the existing ftrace test, so I am not able to
> review all the details. But looks good as far as I can tell:
> 
> Acked-by: Nam Cao <namcao@linutronix.de>

Thanks for the ack!
I think that's good for now as it's going to go to Steve as a next step anyway.

I'm going to send a V2 with the following change just to increase the likelihood
of a wwnr reaction and prepare a PR.
I'll keep your ack there unless you explicitly mean otherwise.

Thanks,
Gabriele

diff --git a/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
b/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
index bc0b2668bf7c..5a59432b1d93 100644
--- a/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
+++ b/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
@@ -4,9 +4,10 @@
 # requires: available_reactors wwnr:monitor printk:reactor stress-ng:program
 
 load() { # returns true if there was a reaction
-       local lines_before
+       local lines_before num
+       num=$((($(nproc) + 1) / 2))
        lines_before=$(dmesg | wc -l)
-       stress-ng --cpu-sched 2 --timer 2 -t 5 -q
+       stress-ng --cpu-sched "$num" --timer "$num" -t 5 -q
        dmesg | tail -n $((lines_before + 1)) | grep -q "rv: monitor wwnr does
not allow event"
 }


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-10-17  8:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-26  9:46 [PATCH 0/2] selftests/verification: Add initial RV tests Gabriele Monaco
2025-09-26  9:46 ` [PATCH 1/2] selftest/ftrace: Generalise ftracetest to use with RV Gabriele Monaco
2025-09-26  9:46 ` [PATCH 2/2] selftests/verification: Add initial RV tests Gabriele Monaco
2025-10-13 11:51 ` [PATCH 0/2] " Gabriele Monaco
2025-10-13 11:56   ` Nam Cao
2025-10-17  7:38 ` Nam Cao
2025-10-17  8:50   ` Gabriele Monaco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).