[PATCH v4 16/17] selftests/verification: Rearrange the wwnr_printk test
From: Gabriele Monaco
Date: Fri Jul 17 2026 - 11:55:29 EST
The wwnr_printk test expects no reactions in some situations, after
fixing the bash assertion, the test is failing because expecting no
reaction after a previous step had reactions is flaky without making
sure all buffers are flushed.
Wait for reactions to be over when expected by polling dmesg for an
interval without any rv message.
Also simplify the load function to stop loads as soon as a reaction
occurs, this limits the number of lines to flush and makes tests overall
faster and more stable.
Reviewed-by: Wen Yang <wen.yang@xxxxxxxxx>
Signed-off-by: Gabriele Monaco <gmonaco@xxxxxxxxxx>
---
Notes:
V4:
* Wait for dmesg to flush all messages after reactions
.../verification/test.d/rv_wwnr_printk.tc | 23 ++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
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 96de95edb530..37d96e1ae93b 100644
--- a/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
+++ b/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc
@@ -4,23 +4,40 @@
# requires: available_reactors wwnr:monitor printk:reactor stress-ng:program
load() { # returns true if there was a reaction
- local lines_before num
+ local lines_before num load_pid ret
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"
+ stress-ng --cpu-sched "$num" --timer "$num" -t 5 -q &
+ load_pid=$!
+ timeout 5 dmesg -w | tail -n +$((lines_before + 1)) | grep -m 1 -q "rv: monitor wwnr does not allow event"
+ ret=$?
+ kill "$load_pid" || true
+ wait "$load_pid" || true
+ return $ret
+}
+
+# loads may flood the ringbuffer, wait for all pending printks
+wait_dmesg_flush() {
+ local last_before last_after=$(dmesg | grep "rv:" | tail -n 1 || true)
+ while [ "$last_before" != "$last_after" ]; do
+ last_before=$last_after
+ sleep .3
+ last_after=$(dmesg | grep "rv:" | tail -n 1 || true)
+ done
}
echo 1 > monitors/wwnr/enable
echo printk > monitors/wwnr/reactors
load
+wait_dmesg_flush
echo 0 > monitoring_on
! load || false
echo 1 > monitoring_on
load
+wait_dmesg_flush
echo 0 > reacting_on
! load || false
--
2.55.0