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.
Simplify the test and run the steps expecting no reaction before the one expecting reactions. 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 more stable. Signed-off-by: Gabriele Monaco <[email protected]> --- .../verification/test.d/rv_wwnr_printk.tc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 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 96de95edb5..a23d22f6ec 100644 --- a/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc +++ b/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc @@ -4,27 +4,30 @@ # 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" + wait "$load_pid" + return $ret } echo 1 > monitors/wwnr/enable echo printk > monitors/wwnr/reactors -load - echo 0 > monitoring_on ! load || false echo 1 > monitoring_on -load - echo 0 > reacting_on ! load || false echo 1 > reacting_on +load + echo nop > monitors/wwnr/reactors echo 0 > monitors/wwnr/enable -- 2.54.0
