public inbox for linux-kselftest@vger.kernel.org
 help / color / mirror / Atom feed
From: Hubert Mazur <hmazur@google.com>
To: Shuah Khan <shuah@kernel.org>, Jihed Chaibi <jihed.chaibi.dev@gmail.com>
Cc: Slawomir Rosek <srosek@google.com>,
	Lukasz Majczak <lmajczak@google.com>,
	 linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Hubert Mazur <hmazur@google.com>
Subject: [PATCH v1 1/1] selftests/cpu-hotplug: Make the script complaint with sh shell
Date: Wed, 18 Mar 2026 08:08:25 +0000	[thread overview]
Message-ID: <20260318080825.3063959-2-hmazur@google.com> (raw)
In-Reply-To: <20260318080825.3063959-1-hmazur@google.com>

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


  reply	other threads:[~2026-03-18  8:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-03-31 21:52   ` [PATCH v1 1/1] selftests/cpu-hotplug: Make the script complaint with sh shell Shuah Khan
2026-04-01 11:56     ` Hubert Mazur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260318080825.3063959-2-hmazur@google.com \
    --to=hmazur@google.com \
    --cc=jihed.chaibi.dev@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lmajczak@google.com \
    --cc=shuah@kernel.org \
    --cc=srosek@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox