diff options
| author | Gabriele Monaco <gmonaco@redhat.com> | 2026-07-23 09:45:32 +0200 |
|---|---|---|
| committer | Gabriele Monaco <gmonaco@redhat.com> | 2026-07-31 16:27:46 +0200 |
| commit | 7c700dcd74640b9f0f5eaafdc6fdc4d5741666e2 (patch) | |
| tree | c7c5b8359c2e2cc63e6eb3b0eb011eb84da1ab55 /tools/testing | |
| parent | 51f3fe704a880c7061057d9b22ada8964bc4c9de (diff) | |
| download | linux-7c700dcd74640b9f0f5eaafdc6fdc4d5741666e2.tar.gz linux-7c700dcd74640b9f0f5eaafdc6fdc4d5741666e2.zip | |
selftests/verification: Fix wrong errexit assumption
RV selftest rely on bash errexit (set -e) to terminate with error, when
a step is expected to return false, the following syntax is used:
! cmd
This however prevents the test from exiting when cmd is false (desired)
but doesn't exit if cmd is true, since commands prefixed with ! are
explicitly excluded from errexit.
Use the syntax
! cmd || false
Which ends up checking the exit value of ! cmd and supplies a false
command for errexit to evaluate.
Reviewed-by: Wen Yang <wen.yang@linux.dev>
Acked-by: Nam Cao <namcao@linutronix.de>
Link: https://lore.kernel.org/r/20260723074534.43521-16-gmonaco@redhat.com
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
Diffstat (limited to 'tools/testing')
3 files changed, 9 insertions, 9 deletions
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 index f29236defb5a..61e2c8b54d9a 100644 --- a/tools/testing/selftests/verification/test.d/rv_monitor_enable_disable.tc +++ b/tools/testing/selftests/verification/test.d/rv_monitor_enable_disable.tc @@ -10,7 +10,7 @@ test_simple_monitor() { grep -q "$monitor$" enabled_monitors echo 0 > "monitors/$prefix$monitor/enable" - ! grep -q "$monitor$" enabled_monitors + ! grep -q "$monitor$" enabled_monitors || false echo "$monitor" >> enabled_monitors grep -q 1 "monitors/$prefix$monitor/enable" @@ -34,12 +34,12 @@ test_container_monitor() { test -n "$nested" echo 0 > "monitors/$monitor/enable" - ! grep -q "^$monitor$" enabled_monitors + ! grep -q "^$monitor$" enabled_monitors || false for nested_dir in "monitors/$monitor"/*; do [ -d "$nested_dir" ] || continue nested=$(basename "$nested_dir") - ! grep -q "^$monitor:$nested$" enabled_monitors + ! grep -q "^$monitor:$nested$" enabled_monitors || false done echo "$monitor" >> enabled_monitors @@ -71,5 +71,5 @@ for monitor_dir in monitors/*; do fi done -! echo non_existent_monitor > enabled_monitors -! grep -q "^non_existent_monitor$" enabled_monitors +! echo non_existent_monitor > enabled_monitors || false +! grep -q "^non_existent_monitor$" enabled_monitors || false diff --git a/tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc b/tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc index 2958bf849338..516a20971390 100644 --- a/tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc +++ b/tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc @@ -64,5 +64,5 @@ 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" +! echo non_existent_reactor > "monitors/$monitor/reactors" || false +! grep -q "\\[non_existent_reactor\\]" "monitors/$monitor/reactors" || false 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 5a59432b1d93..96de95edb530 100644 --- a/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc +++ b/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc @@ -17,13 +17,13 @@ echo printk > monitors/wwnr/reactors load echo 0 > monitoring_on -! load +! load || false echo 1 > monitoring_on load echo 0 > reacting_on -! load +! load || false echo 1 > reacting_on echo nop > monitors/wwnr/reactors |
