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.

selftests: harness: Validate that explicit kselftest exitcodes are handled

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>

authored by

Thomas Weißschuh and committed by
Shuah Khan
758b8905 fd1b4eb8

+46 -9
+20
tools/testing/selftests/kselftest_harness/harness-selftest.c
··· 118 118 TH_LOG("after"); 119 119 } 120 120 121 + TEST(exit_pass) { 122 + exit(KSFT_PASS); 123 + } 124 + 125 + TEST(exit_xpass) { 126 + exit(KSFT_XPASS); 127 + } 128 + 129 + TEST(exit_fail) { 130 + exit(KSFT_FAIL); 131 + } 132 + 133 + TEST(exit_xfail) { 134 + exit(KSFT_XFAIL); 135 + } 136 + 137 + TEST(exit_skip) { 138 + exit(KSFT_SKIP); 139 + } 140 + 121 141 int main(int argc, char **argv) 122 142 { 123 143 /*
+26 -9
tools/testing/selftests/kselftest_harness/harness-selftest.expected
··· 1 1 TAP version 13 2 - 1..9 3 - # Starting 9 tests from 4 test cases. 2 + 1..14 3 + # Starting 14 tests from 4 test cases. 4 4 # RUN global.standalone_pass ... 5 5 # harness-selftest.c:19:standalone_pass:before 6 6 # harness-selftest.c:23:standalone_pass:after ··· 24 24 # signal_fail: Test terminated by assertion 25 25 # FAIL global.signal_fail 26 26 not ok 4 global.signal_fail 27 + # RUN global.exit_pass ... 28 + # OK global.exit_pass 29 + ok 5 global.exit_pass 30 + # RUN global.exit_xpass ... 31 + # OK global.exit_xpass 32 + ok 6 global.exit_xpass # XPASS unknown 33 + # RUN global.exit_fail ... 34 + # exit_fail: Test failed 35 + # FAIL global.exit_fail 36 + not ok 7 global.exit_fail 37 + # RUN global.exit_xfail ... 38 + # OK global.exit_xfail 39 + ok 8 global.exit_xfail # XFAIL unknown 40 + # RUN global.exit_skip ... 41 + # OK global.exit_skip 42 + ok 9 global.exit_skip # SKIP unknown 27 43 # RUN fixture.pass ... 28 44 # harness-selftest.c:53:pass:setup 29 45 # harness-selftest.c:62:pass:before ··· 48 32 # harness-selftest.c:66:pass:after 49 33 # harness-selftest.c:58:pass:teardown same-process=1 50 34 # OK fixture.pass 51 - ok 5 fixture.pass 35 + ok 10 fixture.pass 52 36 # RUN fixture.fail ... 53 37 # harness-selftest.c:53:fail:setup 54 38 # harness-selftest.c:70:fail:before ··· 56 40 # harness-selftest.c:58:fail:teardown same-process=1 57 41 # fail: Test terminated by assertion 58 42 # FAIL fixture.fail 59 - not ok 6 fixture.fail 43 + not ok 11 fixture.fail 60 44 # RUN fixture.timeout ... 61 45 # harness-selftest.c:53:timeout:setup 62 46 # harness-selftest.c:77:timeout:before 63 47 # timeout: Test terminated by timeout 64 48 # FAIL fixture.timeout 65 - not ok 7 fixture.timeout 49 + not ok 12 fixture.timeout 66 50 # RUN fixture_parent.pass ... 67 51 # harness-selftest.c:87:pass:setup 68 52 # harness-selftest.c:96:pass:before 69 53 # harness-selftest.c:98:pass:after 70 54 # harness-selftest.c:92:pass:teardown same-process=0 71 55 # OK fixture_parent.pass 72 - ok 8 fixture_parent.pass 56 + ok 13 fixture_parent.pass 73 57 # RUN fixture_setup_failure.pass ... 74 58 # harness-selftest.c:106:pass:setup 75 59 # harness-selftest.c:108:pass:Expected 0 (0) == 1 (1) 76 60 # pass: Test terminated by assertion 77 61 # FAIL fixture_setup_failure.pass 78 - not ok 9 fixture_setup_failure.pass 79 - # FAILED: 4 / 9 tests passed. 80 - # Totals: pass:4 fail:5 xfail:0 xpass:0 skip:0 error:0 62 + not ok 14 fixture_setup_failure.pass 63 + # FAILED: 8 / 14 tests passed. 64 + # 1 skipped test(s) detected. Consider enabling relevant config options to improve coverage. 65 + # Totals: pass:5 fail:6 xfail:1 xpass:1 skip:1 error:0