* [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
* Re: [PATCH] selftests: cpufreq: Propagate do_test() exit status
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
0 siblings, 1 reply; 3+ messages in thread
From: Zhongqiu Han @ 2026-12-03 3:07 UTC (permalink / raw)
To: Loïc Minier, Rafael J. Wysocki, Viresh Kumar, Shuah Khan,
Muhammad Usama Anjum
Cc: Shuah Khan, linux-pm, linux-kselftest, Zhongqiu Han
Hi Loic,
Thanks a lot for the patch.
On 12/3/2026 4:59 AM, Loïc Minier wrote:
> 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>
The fix looks correct to me.
However, I think the issue was introduced by commit 40d70d4d6097
("selftests: cpufreq: Write test output to stdout as well"). Commit
c7e84706fd3b ("selftests: cpufreq: conform test to TAP") attempted to
fix it by checking PIPESTATUS, but the fix did not work as intended.
So the Fixes tag should point to 40d70d4d6097 instead, right?
> ---
> 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>
>
>
--
Thx and BRs,
Zhongqiu Han
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests: cpufreq: Propagate do_test() exit status
2026-12-03 3:07 ` Zhongqiu Han
@ 2026-12-03 13:42 ` Loïc Minier
0 siblings, 0 replies; 3+ messages in thread
From: Loïc Minier @ 2026-12-03 13:42 UTC (permalink / raw)
To: Zhongqiu Han
Cc: Rafael J. Wysocki, Viresh Kumar, Shuah Khan, Muhammad Usama Anjum,
Shuah Khan, linux-pm, linux-kselftest
Hi Zhongqiu,
and thanks for the quick review!
On Thu, Dec 03, 2026 at 11:07:46AM +0800, Zhongqiu Han wrote:
> On 12/3/2026 4:59 AM, Loïc Minier wrote:
[...]
> > Fixes: c7e84706fd3b ("selftests: cpufreq: conform test to TAP")
>
> The fix looks correct to me.
>
> However, I think the issue was introduced by commit 40d70d4d6097
> ("selftests: cpufreq: Write test output to stdout as well"). Commit
> c7e84706fd3b ("selftests: cpufreq: conform test to TAP") attempted to
> fix it by checking PIPESTATUS, but the fix did not work as intended.
>
> So the Fixes tag should point to 40d70d4d6097 instead, right?
You're right: before 40d70d4d6097, do_test ran in the main shell, so its
"exit 2" terminated main.sh with that status. Running it in a pipeline
moved it to a subshell, and the status has been lost since. c7e84706fd3b
tried to propagate it, but the check never worked.
I'll wait another day or two and then I'll send a v2 with the Fixes tag
pointing to 40d70d4d6097.
Best
- Loïc
^ permalink raw reply [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