* [PATCH 0/2] selftests: Fix runner.sh breakage
@ 2026-04-16 19:03 Mark Brown
2026-04-16 19:03 ` [PATCH 1/2] selftests: Fix runner.sh busybox support Mark Brown
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mark Brown @ 2026-04-16 19:03 UTC (permalink / raw)
To: Shuah Khan, Hangbin Liu, Brendan Jackman
Cc: Shuah Khan, linux-kselftest, linux-kernel, Mark Brown
Commit 2964f6b816c2 ("selftests: Use ktap helpers for runner.sh")
introduced several regressions by introducing dependencies on bash and
GNU coreutils breaking testing on Debian based systems. Roll these
changes back.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
Mark Brown (2):
selftests: Fix runner.sh busybox support
selftests: Fix runner.sh for non-bash shells
tools/testing/selftests/kselftest/runner.sh | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
---
base-commit: 2964f6b816c25ee094df4a143eb5b8828910045f
change-id: 20260416-selftest-fix-readlink-e-da604f02686b
Best regards,
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] selftests: Fix runner.sh busybox support
2026-04-16 19:03 [PATCH 0/2] selftests: Fix runner.sh breakage Mark Brown
@ 2026-04-16 19:03 ` Mark Brown
2026-04-16 19:03 ` [PATCH 2/2] selftests: Fix runner.sh for non-bash shells Mark Brown
2026-04-16 21:14 ` [PATCH 0/2] selftests: Fix runner.sh breakage Shuah Khan
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-04-16 19:03 UTC (permalink / raw)
To: Shuah Khan, Hangbin Liu, Brendan Jackman
Cc: Shuah Khan, linux-kselftest, linux-kernel, Mark Brown
Commit 2964f6b816c2 ("selftests: Use ktap helpers for runner.sh") added an
import of ktap_helper.sh to runner.sh in order to standardise on these for
output formatting. Rather than build on the existing requirement for the
user to supply BASE_DIR to find the helpers it uses some magic which
features a use of "readlink -e". Unfortunately the -e option is a GNU
extension and is not available in at least busybox, meaning that runner.sh
starts failing:
./run_kselftest.sh: 5: ./kselftest/runner.sh: Bad substitution
./run_kselftest.sh: 5: .: cannot open ./ktap_helpers.sh: No such file
Fix this by using the already required BASE_DIR to locate the helper
library.
Fixes: 2964f6b816c2 ("selftests: Use ktap helpers for runner.sh")
Signed-off-by: Mark Brown <broonie@kernel.org>
---
tools/testing/selftests/kselftest/runner.sh | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh
index 3eeec93c9da4..4dfc4271e4ec 100644
--- a/tools/testing/selftests/kselftest/runner.sh
+++ b/tools/testing/selftests/kselftest/runner.sh
@@ -2,7 +2,16 @@
# SPDX-License-Identifier: GPL-2.0
#
# Runs a set of tests in a given subdirectory.
-. $(dirname "$(readlink -e "${BASH_SOURCE[0]}")")/ktap_helpers.sh
+
+# There isn't a shell-agnostic way to find the path of a sourced file,
+# so we must rely on BASE_DIR being set to find other tools.
+if [ -z "$BASE_DIR" ]; then
+ echo "Error: BASE_DIR must be set before sourcing." >&2
+ exit 1
+fi
+
+. ${BASE_DIR}/kselftest/ktap_helpers.sh
+
export timeout_rc=124
export logfile=/dev/stdout
export per_test_logging=
@@ -13,13 +22,6 @@ export RUN_IN_NETNS=
# over our soft timeout limit.
export kselftest_default_timeout=45
-# There isn't a shell-agnostic way to find the path of a sourced file,
-# so we must rely on BASE_DIR being set to find other tools.
-if [ -z "$BASE_DIR" ]; then
- echo "Error: BASE_DIR must be set before sourcing." >&2
- exit 1
-fi
-
TR_CMD=$(command -v tr)
# If Perl is unavailable, we must fall back to line-at-a-time prefixing
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] selftests: Fix runner.sh for non-bash shells
2026-04-16 19:03 [PATCH 0/2] selftests: Fix runner.sh breakage Mark Brown
2026-04-16 19:03 ` [PATCH 1/2] selftests: Fix runner.sh busybox support Mark Brown
@ 2026-04-16 19:03 ` Mark Brown
2026-04-16 21:14 ` [PATCH 0/2] selftests: Fix runner.sh breakage Shuah Khan
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-04-16 19:03 UTC (permalink / raw)
To: Shuah Khan, Hangbin Liu, Brendan Jackman
Cc: Shuah Khan, linux-kselftest, linux-kernel, Mark Brown
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.
Fixes: 2964f6b816c2 ("selftests: Use ktap helpers for runner.sh")
Signed-off-by: Mark Brown <broonie@kernel.org>
---
tools/testing/selftests/kselftest/runner.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh
index 4dfc4271e4ec..50919ce206f3 100644
--- a/tools/testing/selftests/kselftest/runner.sh
+++ b/tools/testing/selftests/kselftest/runner.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# Runs a set of tests in a given subdirectory.
@@ -192,7 +192,7 @@ run_many()
DIR="${PWD#${BASE_DIR}/}"
test_num=0
local rc
- pids=()
+ pids=
for TEST in "$@"; do
BASENAME_TEST=$(basename $TEST)
@@ -203,7 +203,7 @@ run_many()
fi
if [ -n "$RUN_IN_NETNS" ]; then
run_in_netns &
- pids+=($!)
+ pids="$pids $!"
else
run_one "$DIR" "$TEST" "$test_num"
fi
@@ -211,7 +211,7 @@ run_many()
# These variables are outputs of ktap_helpers.sh but since we've
# run the test in a subprocess we need to update them manually
- for pid in "${pids[@]}"; do
+ for pid in $pids; do
wait "$pid"
rc=$?
case "$rc" in
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] selftests: Fix runner.sh breakage
2026-04-16 19:03 [PATCH 0/2] selftests: Fix runner.sh breakage Mark Brown
2026-04-16 19:03 ` [PATCH 1/2] selftests: Fix runner.sh busybox support Mark Brown
2026-04-16 19:03 ` [PATCH 2/2] selftests: Fix runner.sh for non-bash shells Mark Brown
@ 2026-04-16 21:14 ` Shuah Khan
2 siblings, 0 replies; 4+ messages in thread
From: Shuah Khan @ 2026-04-16 21:14 UTC (permalink / raw)
To: Mark Brown, Shuah Khan, Hangbin Liu, Brendan Jackman
Cc: linux-kselftest, linux-kernel, Shuah Khan
On 4/16/26 13:03, Mark Brown wrote:
> Commit 2964f6b816c2 ("selftests: Use ktap helpers for runner.sh")
> introduced several regressions by introducing dependencies on bash and
> GNU coreutils breaking testing on Debian based systems. Roll these
> changes back.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> Mark Brown (2):
> selftests: Fix runner.sh busybox support
> selftests: Fix runner.sh for non-bash shells
>
> tools/testing/selftests/kselftest/runner.sh | 26 ++++++++++++++------------
> 1 file changed, 14 insertions(+), 12 deletions(-)
> ---
> base-commit: 2964f6b816c25ee094df4a143eb5b8828910045f
> change-id: 20260416-selftest-fix-readlink-e-da604f02686b
>
> Best regards,
> --
> Mark Brown <broonie@kernel.org>
>
Thank you. I applied these two patches to linux-kselftest next and will send pr tomorrow.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-16 21:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-16 19:03 [PATCH 0/2] selftests: Fix runner.sh breakage Mark Brown
2026-04-16 19:03 ` [PATCH 1/2] selftests: Fix runner.sh busybox support Mark Brown
2026-04-16 19:03 ` [PATCH 2/2] selftests: Fix runner.sh for non-bash shells Mark Brown
2026-04-16 21:14 ` [PATCH 0/2] selftests: Fix runner.sh breakage Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox