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

selftests: lib.mk: add SKIP handling and test suite name to EMIT_TESTS

EMIT_TESTS which is the common function that implements run_tests target,
treats all non-zero return codes from tests as failures. When tests are
skipped with non-zero return code, because of unmet dependencies and/or
unsupported configuration, it reports them as failed. This will lead to
too many false negatives even on the tests that couldn't be run.

EMIT_TESTS is changed to test for SKIP=4 return from tests to enable
the framework for individual tests to return special SKIP code.

Tests will be changed as needed to report SKIP instead FAIL/PASS when
they get skipped.

Currently just the test name is printed in the RUN_TESTS output. For
example, when raw_skew sub-test from timers tests in run, the output
shows just raw_skew. Include main test name when printing sub-test
results.

In addition, remove duplicate strings for printing common information with
a new for the test header information.

With this change run_kelftest.sh output for breakpoints test will be:

TAP version 13
Running tests in breakpoints
========================================
selftests: breakpoints: step_after_suspend_test
not ok 1..1 selftests: breakpoints: step_after_suspend_test [SKIP]
selftests: breakpoints: breakpoint_test
ok 1..2 selftests: breakpoints: breakpoint_test [PASS]

Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>

+8 -3
+2 -1
tools/testing/selftests/Makefile
··· 135 135 echo "else" >> $(ALL_SCRIPT) 136 136 echo " OUTPUT=/dev/stdout" >> $(ALL_SCRIPT) 137 137 echo "fi" >> $(ALL_SCRIPT) 138 - echo "export KSFT_TAP_LEVEL=`echo 1`" >> $(ALL_SCRIPT) 138 + echo "export KSFT_TAP_LEVEL=1" >> $(ALL_SCRIPT) 139 + echo "export skip=4" >> $(ALL_SCRIPT) 139 140 140 141 for TARGET in $(TARGETS); do \ 141 142 BUILD_TARGET=$$BUILD/$$TARGET; \
+6 -2
tools/testing/selftests/lib.mk
··· 94 94 endif 95 95 96 96 define EMIT_TESTS 97 - @for TEST in $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS); do \ 97 + @test_num=`echo 0`; \ 98 + for TEST in $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS); do \ 98 99 BASENAME_TEST=`basename $$TEST`; \ 99 - echo "(./$$BASENAME_TEST >> \$$OUTPUT 2>&1 && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \ 100 + test_num=`echo $$test_num+1 | bc`; \ 101 + TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \ 102 + echo "echo $$TEST_HDR_MSG"; \ 103 + echo "(./$$BASENAME_TEST >> \$$OUTPUT 2>&1 && echo \"ok 1..$$test_num $$TEST_HDR_MSG [PASS]\") || (if [ \$$? -eq \$$skip ]; then echo \"not ok 1..$$test_num $$TEST_HDR_MSG [SKIP]\"; else echo \"not ok 1..$$test_num $$TEST_HDR_MSG [FAIL]\"; fi;)"; \ 100 104 done; 101 105 endef 102 106