mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-11 17:10:13 +00:00
selftests/verification: Add initial RV tests
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.
Acked-by: Nam Cao <namcao@linutronix.de>
Link: https://lore.kernel.org/r/20251017115203.140080-3-gmonaco@redhat.com
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
This commit is contained in:
parent
a0aa283c53
commit
0c0cd931a0
@ -22498,6 +22498,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
|
||||
|
||||
2
tools/testing/selftests/verification/.gitignore
vendored
Normal file
2
tools/testing/selftests/verification/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
logs
|
||||
8
tools/testing/selftests/verification/Makefile
Normal file
8
tools/testing/selftests/verification/Makefile
Normal file
@ -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
|
||||
1
tools/testing/selftests/verification/config
Normal file
1
tools/testing/selftests/verification/config
Normal file
@ -0,0 +1 @@
|
||||
CONFIG_RV=y
|
||||
1
tools/testing/selftests/verification/settings
Normal file
1
tools/testing/selftests/verification/settings
Normal file
@ -0,0 +1 @@
|
||||
timeout=0
|
||||
39
tools/testing/selftests/verification/test.d/functions
Normal file
39
tools/testing/selftests/verification/test.d/functions
Normal file
@ -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
|
||||
}
|
||||
@ -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
|
||||
@ -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"
|
||||
@ -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
|
||||
@ -0,0 +1,30 @@
|
||||
#!/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 num
|
||||
num=$((($(nproc) + 1) / 2))
|
||||
lines_before=$(dmesg | wc -l)
|
||||
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"
|
||||
}
|
||||
|
||||
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
|
||||
8
tools/testing/selftests/verification/verificationtest-ktap
Executable file
8
tools/testing/selftests/verification/verificationtest-ktap
Executable file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user