* [PATCH] selftests/run_kselftest.sh: fix infinite loop on missing argument
@ 2026-04-13 14:03 Fernando Fernandez Mancera
0 siblings, 0 replies; only message in thread
From: Fernando Fernandez Mancera @ 2026-04-13 14:03 UTC (permalink / raw)
To: linux-kselftest; +Cc: shuah, Fernando Fernandez Mancera
Currently, passing an option that requires an argument as the final
parameter without providing the actual argument causes the script to
enter an infinite loop.
Handle this by adding a proper check for the number of positional
parameters.
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
Note: I hit this while automating some testing, I wasted a couple of
hours of CPU cycles + energy
---
tools/testing/selftests/run_kselftest.sh | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh
index 84d45254675c..2755c6aa367b 100755
--- a/tools/testing/selftests/run_kselftest.sh
+++ b/tools/testing/selftests/run_kselftest.sh
@@ -58,12 +58,24 @@ while true; do
per_test_logging=1
shift ;;
-t | --test)
+ if [ $# -lt 2 ]; then
+ echo "Error: option '$1' requires an argument" >&2
+ usage 1
+ fi
TESTS="$TESTS $2"
shift 2 ;;
-S | --skip)
+ if [ $# -lt 2 ]; then
+ echo "Error: option '$1' requires an argument" >&2
+ usage 1
+ fi
SKIP="$SKIP $2"
shift 2 ;;
-c | --collection)
+ if [ $# -lt 2 ]; then
+ echo "Error: option '$1' requires an argument" >&2
+ usage 1
+ fi
COLLECTIONS="$COLLECTIONS $2"
shift 2 ;;
-l | --list)
@@ -79,6 +91,10 @@ while true; do
RUN_IN_NETNS=1
shift ;;
-o | --override-timeout)
+ if [ $# -lt 2 ]; then
+ echo "Error: option '$1' requires an argument" >&2
+ usage 1
+ fi
kselftest_override_timeout="$2"
shift 2 ;;
-h | --help)
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-13 14:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-13 14:03 [PATCH] selftests/run_kselftest.sh: fix infinite loop on missing argument Fernando Fernandez Mancera
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox