Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+28 -29
+4 -4
tools/testing/selftests/Makefile
··· 214 214 .DEFAULT_GOAL := all 215 215 216 216 all: 217 - @ret=0; \ 217 + @ret=1; \ 218 218 for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do \ 219 219 BUILD_TARGET=$$BUILD/$$TARGET; \ 220 220 mkdir $$BUILD_TARGET -p; \ 221 221 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET \ 222 222 O=$(abs_objtree) \ 223 223 $(if $(FORCE_TARGETS),|| exit); \ 224 - [ $$? -eq 0 ] || ret=1; \ 224 + ret=$$((ret * $$?)); \ 225 225 done; exit $$ret; 226 226 227 227 run_tests: all ··· 279 279 install -m 744 kselftest/ksft.py $(INSTALL_PATH)/kselftest/ 280 280 install -m 744 run_kselftest.sh $(INSTALL_PATH)/ 281 281 rm -f $(TEST_LIST) 282 - @ret=0; \ 282 + @ret=1; \ 283 283 for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do \ 284 284 BUILD_TARGET=$$BUILD/$$TARGET; \ 285 285 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install \ ··· 288 288 OBJ_PATH=$(INSTALL_PATH) \ 289 289 O=$(abs_objtree) \ 290 290 $(if $(FORCE_TARGETS),|| exit); \ 291 - [ $$? -eq 0 ] || ret=1; \ 291 + ret=$$((ret * $$?)); \ 292 292 done; exit $$ret; 293 293 294 294
+24 -25
tools/testing/selftests/kselftest/runner.sh
··· 1 - #!/bin/bash 1 + #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # 4 4 # Runs a set of tests in a given subdirectory. 5 - . $(dirname "$(readlink -e "${BASH_SOURCE[0]}")")/ktap_helpers.sh 5 + 6 + # There isn't a shell-agnostic way to find the path of a sourced file, 7 + # so we must rely on BASE_DIR being set to find other tools. 8 + if [ -z "$BASE_DIR" ]; then 9 + echo "Error: BASE_DIR must be set before sourcing." >&2 10 + exit 1 11 + fi 12 + 13 + . ${BASE_DIR}/kselftest/ktap_helpers.sh 14 + 6 15 export timeout_rc=124 7 16 export logfile=/dev/stdout 8 17 export per_test_logging= ··· 22 13 # "timeout" how many seconds to let each test run before running 23 14 # over our soft timeout limit. 24 15 export kselftest_default_timeout=45 25 - 26 - # There isn't a shell-agnostic way to find the path of a sourced file, 27 - # so we must rely on BASE_DIR being set to find other tools. 28 - if [ -z "$BASE_DIR" ]; then 29 - echo "Error: BASE_DIR must be set before sourcing." >&2 30 - exit 1 31 - fi 32 16 33 17 TR_CMD=$(command -v tr) 34 18 ··· 51 49 { 52 50 DIR="$1" 53 51 TEST="$2" 54 - local rc test_num="$3" 55 52 56 53 BASENAME_TEST=$(basename $TEST) 57 54 ··· 107 106 echo "# $TEST_HDR_MSG" 108 107 if [ ! -e "$TEST" ]; then 109 108 ktap_print_msg "Warning: file $TEST is missing!" 110 - ktap_test_fail "$test_num $TEST_HDR_MSG" 109 + ktap_test_fail "$TEST_HDR_MSG" 111 110 rc=$KSFT_FAIL 112 111 else 113 112 if [ -x /usr/bin/stdbuf ]; then ··· 126 125 interpreter=$(head -n 1 "$TEST" | cut -c 3-) 127 126 cmd="$stdbuf $interpreter ./$BASENAME_TEST" 128 127 else 129 - ktap_test_fail "$test_num $TEST_HDR_MSG" 128 + ktap_test_fail "$TEST_HDR_MSG" 130 129 return $KSFT_FAIL 131 130 fi 132 131 fi ··· 137 136 rc=$? 138 137 case "$rc" in 139 138 "$KSFT_PASS") 140 - ktap_test_pass "$test_num $TEST_HDR_MSG";; 139 + ktap_test_pass "$TEST_HDR_MSG";; 141 140 "$KSFT_SKIP") 142 - ktap_test_skip "$test_num $TEST_HDR_MSG";; 141 + ktap_test_skip "$TEST_HDR_MSG";; 143 142 "$KSFT_XFAIL") 144 - ktap_test_xfail "$test_num $TEST_HDR_MSG";; 143 + ktap_test_xfail "$TEST_HDR_MSG";; 145 144 "$timeout_rc") 146 - ktap_test_fail "$test_num $TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds";; 145 + ktap_test_fail "$TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds";; 147 146 *) 148 - ktap_test_fail "$test_num $TEST_HDR_MSG # exit=$rc";; 147 + ktap_test_fail "$TEST_HDR_MSG # exit=$rc";; 149 148 esac 150 149 cd - >/dev/null 151 150 fi ··· 160 159 BASE_DIR=$BASE_DIR 161 160 source $BASE_DIR/kselftest/runner.sh 162 161 logfile=$logfile 163 - run_one $DIR $TEST $test_num 162 + run_one $DIR $TEST 164 163 EOF 165 164 } 166 165 ··· 173 172 ip netns add $netns 174 173 if [ $? -ne 0 ]; then 175 174 ktap_print_msg "Warning: Create namespace failed for $BASENAME_TEST" 176 - ktap_test_fail "$test_num selftests: $DIR: $BASENAME_TEST # Create NS failed" 175 + ktap_test_fail "selftests: $DIR: $BASENAME_TEST # Create NS failed" 177 176 fi 178 177 ip -n $netns link set lo up 179 178 ··· 190 189 run_many() 191 190 { 192 191 DIR="${PWD#${BASE_DIR}/}" 193 - test_num=0 194 192 local rc 195 - pids=() 193 + pids= 196 194 197 195 for TEST in "$@"; do 198 196 BASENAME_TEST=$(basename $TEST) 199 - test_num=$(( test_num + 1 )) 200 197 if [ -n "$per_test_logging" ]; then 201 198 logfile="$per_test_log_dir/$BASENAME_TEST" 202 199 cat /dev/null > "$logfile" 203 200 fi 204 201 if [ -n "$RUN_IN_NETNS" ]; then 205 202 run_in_netns & 206 - pids+=($!) 203 + pids="$pids $!" 207 204 else 208 - run_one "$DIR" "$TEST" "$test_num" 205 + run_one "$DIR" "$TEST" 209 206 fi 210 207 done 211 208 212 209 # These variables are outputs of ktap_helpers.sh but since we've 213 210 # run the test in a subprocess we need to update them manually 214 - for pid in "${pids[@]}"; do 211 + for pid in $pids; do 215 212 wait "$pid" 216 213 rc=$? 217 214 case "$rc" in