Skip to content

Commit 83ef26f

Browse files
broonieshuahkh
authored andcommitted
selftests: Fix duplicated test number reporting
Commit 2964f6b ("selftests: Use ktap helpers for runner.sh") converted the prints in runner.sh to use the relevant helpers from ktap_helpers.sh, not modifying any of the strings printed in the process. This included converting all the result reports to use the relevant ktap_test_ function. Since the output was originally KTAP compliant the strings reported for test names now include test numbers: ok 59 59 selftests: arm64: syscall-abi instead of the expected format: ok 59 selftests: arm64: syscall-abi which causes result parsers to interpret the second number as part of the test name. Given the use of the helpers the tracking of test numbers by runner.sh is now redundant, remove it entirely to restore the expected output format. Link: https://lore.kernel.org/r/20260417-selftests-fix-double-number-v1-1-1be5d7c36b94@kernel.org 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 df410ad commit 83ef26f

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

tools/testing/selftests/kselftest/runner.sh

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ run_one()
5151
{
5252
DIR="$1"
5353
TEST="$2"
54-
local rc test_num="$3"
5554

5655
BASENAME_TEST=$(basename $TEST)
5756

@@ -108,7 +107,7 @@ run_one()
108107
echo "# $TEST_HDR_MSG"
109108
if [ ! -e "$TEST" ]; then
110109
ktap_print_msg "Warning: file $TEST is missing!"
111-
ktap_test_fail "$test_num $TEST_HDR_MSG"
110+
ktap_test_fail "$TEST_HDR_MSG"
112111
rc=$KSFT_FAIL
113112
else
114113
if [ -x /usr/bin/stdbuf ]; then
@@ -127,7 +126,7 @@ run_one()
127126
interpreter=$(head -n 1 "$TEST" | cut -c 3-)
128127
cmd="$stdbuf $interpreter ./$BASENAME_TEST"
129128
else
130-
ktap_test_fail "$test_num $TEST_HDR_MSG"
129+
ktap_test_fail "$TEST_HDR_MSG"
131130
return $KSFT_FAIL
132131
fi
133132
fi
@@ -138,15 +137,15 @@ run_one()
138137
rc=$?
139138
case "$rc" in
140139
"$KSFT_PASS")
141-
ktap_test_pass "$test_num $TEST_HDR_MSG";;
140+
ktap_test_pass "$TEST_HDR_MSG";;
142141
"$KSFT_SKIP")
143-
ktap_test_skip "$test_num $TEST_HDR_MSG";;
142+
ktap_test_skip "$TEST_HDR_MSG";;
144143
"$KSFT_XFAIL")
145-
ktap_test_xfail "$test_num $TEST_HDR_MSG";;
144+
ktap_test_xfail "$TEST_HDR_MSG";;
146145
"$timeout_rc")
147-
ktap_test_fail "$test_num $TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds";;
146+
ktap_test_fail "$TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds";;
148147
*)
149-
ktap_test_fail "$test_num $TEST_HDR_MSG # exit=$rc";;
148+
ktap_test_fail "$TEST_HDR_MSG # exit=$rc";;
150149
esac
151150
cd - >/dev/null
152151
fi
@@ -161,7 +160,7 @@ in_netns()
161160
BASE_DIR=$BASE_DIR
162161
source $BASE_DIR/kselftest/runner.sh
163162
logfile=$logfile
164-
run_one $DIR $TEST $test_num
163+
run_one $DIR $TEST
165164
EOF
166165
}
167166

@@ -174,7 +173,7 @@ run_in_netns()
174173
ip netns add $netns
175174
if [ $? -ne 0 ]; then
176175
ktap_print_msg "Warning: Create namespace failed for $BASENAME_TEST"
177-
ktap_test_fail "$test_num selftests: $DIR: $BASENAME_TEST # Create NS failed"
176+
ktap_test_fail "selftests: $DIR: $BASENAME_TEST # Create NS failed"
178177
fi
179178
ip -n $netns link set lo up
180179

@@ -191,13 +190,11 @@ run_in_netns()
191190
run_many()
192191
{
193192
DIR="${PWD#${BASE_DIR}/}"
194-
test_num=0
195193
local rc
196194
pids=
197195

198196
for TEST in "$@"; do
199197
BASENAME_TEST=$(basename $TEST)
200-
test_num=$(( test_num + 1 ))
201198
if [ -n "$per_test_logging" ]; then
202199
logfile="$per_test_log_dir/$BASENAME_TEST"
203200
cat /dev/null > "$logfile"
@@ -206,7 +203,7 @@ run_many()
206203
run_in_netns &
207204
pids="$pids $!"
208205
else
209-
run_one "$DIR" "$TEST" "$test_num"
206+
run_one "$DIR" "$TEST"
210207
fi
211208
done
212209

0 commit comments

Comments
 (0)