Skip to content

Commit df410ad

Browse files
broonieshuahkh
authored andcommitted
selftests: Fix runner.sh for non-bash shells
Commit 2964f6b ("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/[email protected] Fixes: 2964f6b ("selftests: Use ktap helpers for runner.sh") Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 93edbf1 commit df410ad

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tools/testing/selftests/kselftest/runner.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
# SPDX-License-Identifier: GPL-2.0
33
#
44
# Runs a set of tests in a given subdirectory.
@@ -193,7 +193,7 @@ run_many()
193193
DIR="${PWD#${BASE_DIR}/}"
194194
test_num=0
195195
local rc
196-
pids=()
196+
pids=
197197

198198
for TEST in "$@"; do
199199
BASENAME_TEST=$(basename $TEST)
@@ -204,15 +204,15 @@ run_many()
204204
fi
205205
if [ -n "$RUN_IN_NETNS" ]; then
206206
run_in_netns &
207-
pids+=($!)
207+
pids="$pids $!"
208208
else
209209
run_one "$DIR" "$TEST" "$test_num"
210210
fi
211211
done
212212

213213
# These variables are outputs of ktap_helpers.sh but since we've
214214
# run the test in a subprocess we need to update them manually
215-
for pid in "${pids[@]}"; do
215+
for pid in $pids; do
216216
wait "$pid"
217217
rc=$?
218218
case "$rc" in

0 commit comments

Comments
 (0)