Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: Fix runner.sh for non-bash shells

Commit 2964f6b816c2 ("selftests: Use ktap helpers for runner.sh") added a
number of bashisms and updated the interpreter specified for the script to
be /bin/bash to reflect this. Unfortunately this does not actually achieve
anything in production since the main way runner.sh is invoked is from the
top level run_kselftest.sh which sources it rather than running it as a
separate script and specifies the shell as /bin/sh. This means that on
systems where /bin/sh is not bash (such as Debian where /bin/sh defaults to
being dash) we see failures:

./run_kselftest.sh: 195: ./kselftest/runner.sh: Syntax error: "(" unexpected (expecting "}")

These bashisms come from this part of the change:

4. In runner.sh run_one(), get the return value and use ktap helpers for
all pass/fail reporting. This allows counting pass/fail numbers in the
main process.

which uses a bash array to track all the subtests being run. Convert this
to use a simple flat variable instead.

Link: https://lore.kernel.org/r/20260416-selftest-fix-readlink-e-v1-2-94e4cabbdec4@kernel.org
Fixes: 2964f6b816c2 ("selftests: Use ktap helpers for runner.sh")
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Mark Brown and committed by
Shuah Khan
df410ad4 93edbf17

+4 -4
+4 -4
tools/testing/selftests/kselftest/runner.sh
··· 1 - #!/bin/bash 1 + #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # 4 4 # Runs a set of tests in a given subdirectory. ··· 193 193 DIR="${PWD#${BASE_DIR}/}" 194 194 test_num=0 195 195 local rc 196 - pids=() 196 + pids= 197 197 198 198 for TEST in "$@"; do 199 199 BASENAME_TEST=$(basename $TEST) ··· 204 204 fi 205 205 if [ -n "$RUN_IN_NETNS" ]; then 206 206 run_in_netns & 207 - pids+=($!) 207 + pids="$pids $!" 208 208 else 209 209 run_one "$DIR" "$TEST" "$test_num" 210 210 fi ··· 212 212 213 213 # These variables are outputs of ktap_helpers.sh but since we've 214 214 # run the test in a subprocess we need to update them manually 215 - for pid in "${pids[@]}"; do 215 + for pid in $pids; do 216 216 wait "$pid" 217 217 rc=$? 218 218 case "$rc" in