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 <[email protected]> --- 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

