* [PATCH v1 0/1] Make the script complaint with 'sh' shell
@ 2026-03-18 8:08 Hubert Mazur
2026-03-18 8:08 ` [PATCH v1 1/1] selftests/cpu-hotplug: Make the script complaint with sh shell Hubert Mazur
0 siblings, 1 reply; 4+ messages in thread
From: Hubert Mazur @ 2026-03-18 8:08 UTC (permalink / raw)
To: Shuah Khan, Jihed Chaibi
Cc: Slawomir Rosek, Lukasz Majczak, linux-kselftest, linux-kernel,
Hubert Mazur
Hello,
I'm sending a change that modifies the script a bit to make it
compliant with the 'sh' shell. The reason behind it is that the test
cannot be executed on x86 embedded devices without bash. The introduced
changes are:
- /bin/bash -> /bin/sh
- Usage of env $UID changed to command execution $(id -u)
- $FUNCNAME env changed to local variables with function names
I'm aware that the last one may be the most controversial since it is
not the most elegant one, though I didn't find any better solution
to retrieve the name of currently executed function in 'sh'.
Please take a look.
Regards,
Hubert
Hubert Mazur (1):
selftests/cpu-hotplug: Make the script complaint with sh shell
tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
--
2.53.0.959.g497ff81fa9-goog
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1 1/1] selftests/cpu-hotplug: Make the script complaint with sh shell
2026-03-18 8:08 [PATCH v1 0/1] Make the script complaint with 'sh' shell Hubert Mazur
@ 2026-03-18 8:08 ` Hubert Mazur
2026-03-31 21:52 ` Shuah Khan
0 siblings, 1 reply; 4+ messages in thread
From: Hubert Mazur @ 2026-03-18 8:08 UTC (permalink / raw)
To: Shuah Khan, Jihed Chaibi
Cc: Slawomir Rosek, Lukasz Majczak, linux-kselftest, linux-kernel,
Hubert Mazur
The script uses by default the bash shell that is inaccessible in
the x86 embedded devices. This leads to the syntax errors. To mitigate
this, change the interpreter to /bin/sh and properly assign the
FUNCNAME variable for each of the functions as 'sh' doesn't set this
env. Change the conditional check for being a root from not
existent UID and replace with command execution "id -u".
Signed-off-by: Hubert Mazur <hmazur@google.com>
---
tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
index 6232a46ca6e1..9d5d61413443 100755
--- a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
+++ b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
SYSFS=
@@ -10,7 +10,7 @@ prerequisite()
{
msg="skip all tests:"
- if [ $UID != 0 ]; then
+ if [ $(id -u) -ne 0 ]; then
echo $msg must be run as root >&2
exit $ksft_skip
fi
@@ -99,6 +99,7 @@ offline_cpu()
online_cpu_expect_success()
{
+ FUNCNAME="online_cpu_expect_success()"
local cpu=$1
if ! online_cpu $cpu; then
@@ -112,6 +113,8 @@ online_cpu_expect_success()
online_cpu_expect_fail()
{
+
+ FUNCNAME="online_cpu_expect_fail()"
local cpu=$1
if online_cpu $cpu 2> /dev/null; then
@@ -125,6 +128,8 @@ online_cpu_expect_fail()
offline_cpu_expect_success()
{
+
+ FUNCNAME="offline_cpu_expect_success()"
local cpu=$1
if ! offline_cpu $cpu; then
@@ -139,6 +144,7 @@ offline_cpu_expect_success()
offline_cpu_expect_fail()
{
local cpu=$1
+ FUNCNAME="offline_cpu_expect_fail()"
if offline_cpu $cpu 2> /dev/null; then
echo $FUNCNAME $cpu: unexpected success >&2
--
2.53.0.959.g497ff81fa9-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] selftests/cpu-hotplug: Make the script complaint with sh shell
2026-03-18 8:08 ` [PATCH v1 1/1] selftests/cpu-hotplug: Make the script complaint with sh shell Hubert Mazur
@ 2026-03-31 21:52 ` Shuah Khan
2026-04-01 11:56 ` Hubert Mazur
0 siblings, 1 reply; 4+ messages in thread
From: Shuah Khan @ 2026-03-31 21:52 UTC (permalink / raw)
To: Hubert Mazur, Shuah Khan, Jihed Chaibi
Cc: Slawomir Rosek, Lukasz Majczak, linux-kselftest, linux-kernel,
Shuah Khan
On 3/18/26 02:08, Hubert Mazur wrote:
> The script uses by default the bash shell that is inaccessible in
> the x86 embedded devices. This leads to the syntax errors. To mitigate
some x86 embedded devices - which ones?
> this, change the interpreter to /bin/sh and properly assign the
> FUNCNAME variable for each of the functions as 'sh' doesn't set this
> env. Change the conditional check for being a root from not
> existent UID and replace with command execution "id -u".
Please include errors in the change log
>
> Signed-off-by: Hubert Mazur <hmazur@google.com>
> ---
> tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] selftests/cpu-hotplug: Make the script complaint with sh shell
2026-03-31 21:52 ` Shuah Khan
@ 2026-04-01 11:56 ` Hubert Mazur
0 siblings, 0 replies; 4+ messages in thread
From: Hubert Mazur @ 2026-04-01 11:56 UTC (permalink / raw)
To: Shuah Khan
Cc: Shuah Khan, Jihed Chaibi, Slawomir Rosek, Lukasz Majczak,
linux-kselftest, linux-kernel
On Tue, Mar 31, 2026 at 11:52 PM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 3/18/26 02:08, Hubert Mazur wrote:
> > The script uses by default the bash shell that is inaccessible in
> > the x86 embedded devices. This leads to the syntax errors. To mitigate
>
> some x86 embedded devices - which ones?
Actually - this isn't particularly accurate since it applies to any devices
which rely on busybox or other small environments.
> > this, change the interpreter to /bin/sh and properly assign the
> > FUNCNAME variable for each of the functions as 'sh' doesn't set this
> > env. Change the conditional check for being a root from not
> > existent UID and replace with command execution "id -u".
>
> Please include errors in the change log
The first error comes from the "$UID" environment variable,
and the error is:
./cpu-on-off-test.sh[193]: [: 0: unexpected operator/operand
Regarding the changes to "$FUNCNAME" - there's no error printed
but also the function name is missing in print:
"echo $FUNCNAME $cpu: unexpected success >&2"
The v1 already addresses the most urgent issues with $UID and $FUNCNAME
which I faced but in the meantime I took a look at the sashiko.dev review tool:
https://sashiko.dev/#/patchset/20260318080825.3063959-2-hmazur%40google.com
and uploaded v2 patch which addresses other issues reported by the tool:
https://lore.kernel.org/all/20260331115111.1522473-1-hmazur@google.com/
Please let me know if I should revert to v1 and update the changelog
and commit message or we can continue with v2.
Regards
Hubert
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-01 11:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-18 8:08 [PATCH v1 0/1] Make the script complaint with 'sh' shell Hubert Mazur
2026-03-18 8:08 ` [PATCH v1 1/1] selftests/cpu-hotplug: Make the script complaint with sh shell Hubert Mazur
2026-03-31 21:52 ` Shuah Khan
2026-04-01 11:56 ` Hubert Mazur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox