Merge tag 'linux_kselftest-next-7.1-next-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest fixes from Shuah Khan:
 "Fix regressions in non-bash shells and busybox support, and revert a
  commit that regressed in build and installation when one or more tests
  fail to build.

  Fix duplicated test number reporting introduced in ktap support patch"

* tag 'linux_kselftest-next-7.1-next-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  selftests: Fix duplicated test number reporting
  selftests: Fix runner.sh for non-bash shells
  selftests: Fix runner.sh busybox support
  selftests: Deescalate error reporting
This commit is contained in:
Linus Torvalds committed 2026-04-20 17:19:30 -07:00
commit f154634e42
2 files changed
+28 -29

No files matched your search

+4 -4
View File
@@ -214,14 +214,14 @@ export KHDR_INCLUDES
.DEFAULT_GOAL := all
all:
@ret=0; \
@ret=1; \
for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do \
BUILD_TARGET=$$BUILD/$$TARGET; \
mkdir $$BUILD_TARGET -p; \
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET \
O=$(abs_objtree) \
$(if $(FORCE_TARGETS),|| exit); \
[ $$? -eq 0 ] || ret=1; \
ret=$$((ret * $$?)); \
done; exit $$ret;
run_tests: all
@@ -279,7 +279,7 @@ ifdef INSTALL_PATH
install -m 744 kselftest/ksft.py $(INSTALL_PATH)/kselftest/
install -m 744 run_kselftest.sh $(INSTALL_PATH)/
rm -f $(TEST_LIST)
@ret=0; \
@ret=1; \
for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do \
BUILD_TARGET=$$BUILD/$$TARGET; \
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install \
@@ -288,7 +288,7 @@ ifdef INSTALL_PATH
OBJ_PATH=$(INSTALL_PATH) \
O=$(abs_objtree) \
$(if $(FORCE_TARGETS),|| exit); \
[ $$? -eq 0 ] || ret=1; \
ret=$$((ret * $$?)); \
done; exit $$ret;
+24 -25
View File
@@ -1,8 +1,17 @@
#!/bin/bash
#!/bin/sh
# 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=
@@ -14,13 +23,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
@@ -49,7 +51,6 @@ run_one()
{
DIR="$1"
TEST="$2"
local rc test_num="$3"
BASENAME_TEST=$(basename $TEST)
@@ -106,7 +107,7 @@ run_one()
echo "# $TEST_HDR_MSG"
if [ ! -e "$TEST" ]; then
ktap_print_msg "Warning: file $TEST is missing!"
ktap_test_fail "$test_num $TEST_HDR_MSG"
ktap_test_fail "$TEST_HDR_MSG"
rc=$KSFT_FAIL
else
if [ -x /usr/bin/stdbuf ]; then
@@ -125,7 +126,7 @@ run_one()
interpreter=$(head -n 1 "$TEST" | cut -c 3-)
cmd="$stdbuf $interpreter ./$BASENAME_TEST"
else
ktap_test_fail "$test_num $TEST_HDR_MSG"
ktap_test_fail "$TEST_HDR_MSG"
return $KSFT_FAIL
fi
fi
@@ -136,15 +137,15 @@ run_one()
rc=$?
case "$rc" in
"$KSFT_PASS")
ktap_test_pass "$test_num $TEST_HDR_MSG";;
ktap_test_pass "$TEST_HDR_MSG";;
"$KSFT_SKIP")
ktap_test_skip "$test_num $TEST_HDR_MSG";;
ktap_test_skip "$TEST_HDR_MSG";;
"$KSFT_XFAIL")
ktap_test_xfail "$test_num $TEST_HDR_MSG";;
ktap_test_xfail "$TEST_HDR_MSG";;
"$timeout_rc")
ktap_test_fail "$test_num $TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds";;
ktap_test_fail "$TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds";;
*)
ktap_test_fail "$test_num $TEST_HDR_MSG # exit=$rc";;
ktap_test_fail "$TEST_HDR_MSG # exit=$rc";;
esac
cd - >/dev/null
fi
@@ -159,7 +160,7 @@ in_netns()
BASE_DIR=$BASE_DIR
source $BASE_DIR/kselftest/runner.sh
logfile=$logfile
run_one $DIR $TEST $test_num
run_one $DIR $TEST
EOF
}
@@ -172,7 +173,7 @@ run_in_netns()
ip netns add $netns
if [ $? -ne 0 ]; then
ktap_print_msg "Warning: Create namespace failed for $BASENAME_TEST"
ktap_test_fail "$test_num selftests: $DIR: $BASENAME_TEST # Create NS failed"
ktap_test_fail "selftests: $DIR: $BASENAME_TEST # Create NS failed"
fi
ip -n $netns link set lo up
@@ -189,28 +190,26 @@ run_in_netns()
run_many()
{
DIR="${PWD#${BASE_DIR}/}"
test_num=0
local rc
pids=()
pids=
for TEST in "$@"; do
BASENAME_TEST=$(basename $TEST)
test_num=$(( test_num + 1 ))
if [ -n "$per_test_logging" ]; then
logfile="$per_test_log_dir/$BASENAME_TEST"
cat /dev/null > "$logfile"
fi
if [ -n "$RUN_IN_NETNS" ]; then
run_in_netns &
pids+=($!)
pids="$pids $!"
else
run_one "$DIR" "$TEST" "$test_num"
run_one "$DIR" "$TEST"
fi
done
# 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