Skip to content

Commit 1f87c7c

Browse files
author
Shuah Khan
committed
selftests: lib.mk: change RUN_TESTS to print messages in TAP13 format
Change common RUN_TESTS to print messages in user friendly TAP13 format. This change add TAP13 header at the start of RUN_TESTS target run, and prints the resulting pass/fail messages with test number information in the TAP 13 format for each test in the run tests list. This change covers test scripts as well as test programs. Test programs have an option to use ksft_ API, however test scripts won't be able to. With this change, test scripts can print TAP13 format output without any changes to individual scripts. Test programs can provide TAP13 format output as needed as some tests already do. Tests that haven't been converted will benefit from this change. Tests that are converted benefit from the test counts for all the tests in each test directory. Running firmware tests: make --silent -C tools/testing/selftests/firmware/ run_tests Before the change: modprobe: ERROR: could not insert 'test_firmware': Operation not permitted ./fw_filesystem.sh: /sys/devices/virtual/misc/test_firmware not present You must have the following enabled in your kernel: CONFIG_TEST_FIRMWARE=y selftests: fw_filesystem.sh [FAIL] modprobe: ERROR: could not insert 'test_firmware': Operation not permitted selftests: fw_fallback.sh [FAIL] After the change: TAP version 13 selftests: fw_filesystem.sh ======================================== modprobe: ERROR: could not insert 'test_firmware': Operation not permitted ./fw_filesystem.sh: /sys/devices/virtual/misc/test_firmware not present You must have the following enabled in your kernel: CONFIG_TEST_FIRMWARE=y not ok 1..1 selftests: fw_filesystem.sh [FAIL] selftests: fw_fallback.sh ======================================== modprobe: ERROR: could not insert 'test_firmware': Operation not permitted not ok 1..2 selftests: fw_fallback.sh [FAIL] Signed-off-by: Shuah Khan <[email protected]>
1 parent 77d802e commit 1f87c7c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tools/testing/selftests/lib.mk

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@ TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
1111

1212
all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
1313

14+
.ONESHELL:
1415
define RUN_TESTS
15-
@for TEST in $(1); do \
16+
@test_num=`echo 0`;
17+
@echo "TAP version 13";
18+
@for TEST in $(1); do \
1619
BASENAME_TEST=`basename $$TEST`; \
20+
test_num=`echo $$test_num+1 | bc`; \
21+
echo "selftests: $$BASENAME_TEST"; \
22+
echo "========================================"; \
1723
if [ ! -x $$BASENAME_TEST ]; then \
1824
echo "selftests: Warning: file $$BASENAME_TEST is not executable, correct this.";\
19-
echo "selftests: $$BASENAME_TEST [FAIL]"; \
25+
echo "not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; \
2026
else \
21-
cd `dirname $$TEST` > /dev/null; (./$$BASENAME_TEST && echo "selftests: $$BASENAME_TEST [PASS]") || echo "selftests: $$BASENAME_TEST [FAIL]"; cd - > /dev/null;\
27+
cd `dirname $$TEST` > /dev/null; (./$$BASENAME_TEST && echo "ok 1..$$test_num selftests: $$BASENAME_TEST [PASS]") || echo "not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; cd - > /dev/null;\
2228
fi; \
2329
done;
2430
endef

0 commit comments

Comments
 (0)