]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: harness: Validate that explicit kselftest exitcodes are handled
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Mon, 2 Mar 2026 14:13:29 +0000 (15:13 +0100)
committerShuah Khan <skhan@linuxfoundation.org>
Tue, 31 Mar 2026 19:48:16 +0000 (13:48 -0600)
The test programs can directly call exit with one of the KSFT_* constants.

Add tests for this functionality.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Link: https://lore.kernel.org/r/20260302-kselftest-harness-v2-2-3143aa41d989@linutronix.de
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/kselftest_harness/harness-selftest.c
tools/testing/selftests/kselftest_harness/harness-selftest.expected

index 7820bb5d0e6d9af343928e72cea6c4cf5e6088e3..f109a21ed6f7c2ab57cfd064a9d54faa26b3ac4c 100644 (file)
@@ -118,6 +118,26 @@ TEST_F(fixture_setup_failure, pass) {
        TH_LOG("after");
 }
 
+TEST(exit_pass) {
+       exit(KSFT_PASS);
+}
+
+TEST(exit_xpass) {
+       exit(KSFT_XPASS);
+}
+
+TEST(exit_fail) {
+       exit(KSFT_FAIL);
+}
+
+TEST(exit_xfail) {
+       exit(KSFT_XFAIL);
+}
+
+TEST(exit_skip) {
+       exit(KSFT_SKIP);
+}
+
 int main(int argc, char **argv)
 {
        /*
index 97e1418c1c7ee55df69c8eb9193a51363c5a9829..da7febc11e1050d5b4fb9ac315ee0daf2e197e4a 100644 (file)
@@ -1,6 +1,6 @@
 TAP version 13
-1..9
-# Starting 9 tests from 4 test cases.
+1..14
+# Starting 14 tests from 4 test cases.
 #  RUN           global.standalone_pass ...
 # harness-selftest.c:19:standalone_pass:before
 # harness-selftest.c:23:standalone_pass:after
@@ -24,6 +24,22 @@ ok 3 global.signal_pass
 # signal_fail: Test terminated by assertion
 #          FAIL  global.signal_fail
 not ok 4 global.signal_fail
+#  RUN           global.exit_pass ...
+#            OK  global.exit_pass
+ok 5 global.exit_pass
+#  RUN           global.exit_xpass ...
+#            OK  global.exit_xpass
+ok 6 global.exit_xpass # XPASS unknown
+#  RUN           global.exit_fail ...
+# exit_fail: Test failed
+#          FAIL  global.exit_fail
+not ok 7 global.exit_fail
+#  RUN           global.exit_xfail ...
+#            OK  global.exit_xfail
+ok 8 global.exit_xfail # XFAIL unknown
+#  RUN           global.exit_skip ...
+#            OK  global.exit_skip
+ok 9 global.exit_skip # SKIP unknown
 #  RUN           fixture.pass ...
 # harness-selftest.c:53:pass:setup
 # harness-selftest.c:62:pass:before
@@ -32,7 +48,7 @@ not ok 4 global.signal_fail
 # harness-selftest.c:66:pass:after
 # harness-selftest.c:58:pass:teardown same-process=1
 #            OK  fixture.pass
-ok 5 fixture.pass
+ok 10 fixture.pass
 #  RUN           fixture.fail ...
 # harness-selftest.c:53:fail:setup
 # harness-selftest.c:70:fail:before
@@ -40,25 +56,26 @@ ok 5 fixture.pass
 # harness-selftest.c:58:fail:teardown same-process=1
 # fail: Test terminated by assertion
 #          FAIL  fixture.fail
-not ok 6 fixture.fail
+not ok 11 fixture.fail
 #  RUN           fixture.timeout ...
 # harness-selftest.c:53:timeout:setup
 # harness-selftest.c:77:timeout:before
 # timeout: Test terminated by timeout
 #          FAIL  fixture.timeout
-not ok 7 fixture.timeout
+not ok 12 fixture.timeout
 #  RUN           fixture_parent.pass ...
 # harness-selftest.c:87:pass:setup
 # harness-selftest.c:96:pass:before
 # harness-selftest.c:98:pass:after
 # harness-selftest.c:92:pass:teardown same-process=0
 #            OK  fixture_parent.pass
-ok 8 fixture_parent.pass
+ok 13 fixture_parent.pass
 #  RUN           fixture_setup_failure.pass ...
 # harness-selftest.c:106:pass:setup
 # harness-selftest.c:108:pass:Expected 0 (0) == 1 (1)
 # pass: Test terminated by assertion
 #          FAIL  fixture_setup_failure.pass
-not ok 9 fixture_setup_failure.pass
-# FAILED: 4 / 9 tests passed.
-# Totals: pass:4 fail:5 xfail:0 xpass:0 skip:0 error:0
+not ok 14 fixture_setup_failure.pass
+# FAILED: 8 / 14 tests passed.
+# 1 skipped test(s) detected. Consider enabling relevant config options to improve coverage.
+# Totals: pass:5 fail:6 xfail:1 xpass:1 skip:1 error:0