Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] selftests: cpufreq: Propagate do_test() exit status
@ 2026-12-02 20:59 Loïc Minier
  2026-12-03  3:07 ` Zhongqiu Han
  0 siblings, 1 reply; 3+ messages in thread
From: Loïc Minier @ 2026-12-02 20:59 UTC (permalink / raw)
  To: Rafael J. Wysocki, Viresh Kumar, Shuah Khan, Muhammad Usama Anjum
  Cc: Shuah Khan, linux-pm, linux-kselftest, Loïc Minier

main.sh runs do_test through tee and checks ${PIPESTATUS[0]}, but by the
time the "exit ${PIPESTATUS[0]}" in the if body is executed, PIPESTATUS
has already been overwritten by the [ test, so the script exits 0.

As a result, when do_test() bails out, e.g. with "No cpu is managed by
cpufreq core, exiting", the test is reported as passing:

  # Bail out!  No cpu is managed by cpufreq core, exiting
  # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
  ok 1 selftests: cpufreq: main.sh

This was hit on a Qualcomm Glymur laptop with CONFIG_CPU_FREQ=y but
without CONFIG_ARM_SCMI_CPUFREQ, so no CPU had a cpufreq policy.

Save the pipeline status before testing it, so that the failure is
reported:

  not ok 1 selftests: cpufreq: main.sh # exit=1

Fixes: c7e84706fd3b ("selftests: cpufreq: conform test to TAP")
Signed-off-by: Loïc Minier <loic.minier@oss.qualcomm.com>
---
Tested on a Qualcomm Glymur laptop without CONFIG_ARM_SCMI_CPUFREQ:
the bail-out was reported as "ok 1" before this change and as "not
ok 1 ... # exit=1" after it.
---
 tools/testing/selftests/cpufreq/main.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/cpufreq/main.sh b/tools/testing/selftests/cpufreq/main.sh
index f12ff7416e41..03163cd7813e 100755
--- a/tools/testing/selftests/cpufreq/main.sh
+++ b/tools/testing/selftests/cpufreq/main.sh
@@ -207,8 +207,9 @@ prerequisite
 # Run requested functions
 clear_dumps $OUTFILE
 do_test | tee -a $OUTFILE.txt
-if [ "${PIPESTATUS[0]}" -ne 0 ]; then
-    exit ${PIPESTATUS[0]};
+ret=${PIPESTATUS[0]}
+if [ "$ret" -ne 0 ]; then
+    exit "$ret"
 fi
 dmesg_dumps $OUTFILE
 

---
base-commit: 0df89587a56e0f0392a9d5380334fb87ec4f2690
change-id: 20261202-kselftests-cpufreq-exit-status-3759fb29842c

Best regards,
--  
Loïc Minier <loic.minier@oss.qualcomm.com>


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

end of thread, other threads:[~2026-12-03 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 20:59 [PATCH] selftests: cpufreq: Propagate do_test() exit status Loïc Minier
2026-12-03  3:07 ` Zhongqiu Han
2026-12-03 13:42   ` Loïc Minier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox