Skip to content

Commit 132618c

Browse files
t-8chshuahkh
authored andcommitted
selftests: harness: Validate intermixing of kselftest and harness functionality
Make sure that calling ksft_test_result_*() functions from harness tests work as expected. Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Link: https://lore.kernel.org/r/20260302-kselftest-harness-v2-5-3143aa41d989@linutronix.de Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent a0877a3 commit 132618c

2 files changed

Lines changed: 46 additions & 9 deletions

File tree

tools/testing/selftests/kselftest_harness/harness-selftest.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,26 @@ TEST(exit_skip) {
138138
exit(KSFT_SKIP);
139139
}
140140

141+
TEST(test_result_pass) {
142+
ksft_test_result_pass("");
143+
}
144+
145+
TEST(test_result_xpass) {
146+
ksft_test_result_xpass("");
147+
}
148+
149+
TEST(test_result_fail) {
150+
ksft_test_result_fail("");
151+
}
152+
153+
TEST(test_result_xfail) {
154+
ksft_test_result_xfail("");
155+
}
156+
157+
TEST(test_result_skip) {
158+
ksft_test_result_skip("");
159+
}
160+
141161
int main(int argc, char **argv)
142162
{
143163
/*

tools/testing/selftests/kselftest_harness/harness-selftest.expected

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
TAP version 13
2-
1..14
3-
# Starting 14 tests from 4 test cases.
2+
1..19
3+
# Starting 19 tests from 4 test cases.
44
# RUN global.standalone_pass ...
55
# harness-selftest.c:19:standalone_pass:before
66
# harness-selftest.c:23:standalone_pass:after
@@ -40,6 +40,23 @@ ok 8 global.exit_xfail # XFAIL unknown
4040
# RUN global.exit_skip ...
4141
# OK global.exit_skip
4242
ok 9 global.exit_skip # SKIP unknown
43+
# RUN global.test_result_pass ...
44+
# OK global.test_result_pass
45+
ok 10 global.test_result_pass
46+
# RUN global.test_result_xpass ...
47+
# OK global.test_result_xpass
48+
ok 11 global.test_result_xpass
49+
# RUN global.test_result_fail ...
50+
not ok 1 # Illegal usage of low-level ksft APIs in harness test
51+
# test_result_fail: Test failed
52+
# FAIL global.test_result_fail
53+
not ok 12 global.test_result_fail
54+
# RUN global.test_result_xfail ...
55+
# OK global.test_result_xfail
56+
ok 13 global.test_result_xfail
57+
# RUN global.test_result_skip ...
58+
# OK global.test_result_skip
59+
ok 14 global.test_result_skip
4360
# RUN fixture.pass ...
4461
# harness-selftest.c:53:pass:setup
4562
# harness-selftest.c:62:pass:before
@@ -48,34 +65,34 @@ ok 9 global.exit_skip # SKIP unknown
4865
# harness-selftest.c:66:pass:after
4966
# harness-selftest.c:58:pass:teardown same-process=1
5067
# OK fixture.pass
51-
ok 10 fixture.pass
68+
ok 15 fixture.pass
5269
# RUN fixture.fail ...
5370
# harness-selftest.c:53:fail:setup
5471
# harness-selftest.c:70:fail:before
5572
# harness-selftest.c:71:fail:Expected 0 (0) == 1 (1)
5673
# harness-selftest.c:58:fail:teardown same-process=1
5774
# fail: Test terminated by assertion
5875
# FAIL fixture.fail
59-
not ok 11 fixture.fail
76+
not ok 16 fixture.fail
6077
# RUN fixture.timeout ...
6178
# harness-selftest.c:53:timeout:setup
6279
# harness-selftest.c:77:timeout:before
6380
# timeout: Test terminated by timeout
6481
# FAIL fixture.timeout
65-
not ok 12 fixture.timeout
82+
not ok 17 fixture.timeout
6683
# RUN fixture_parent.pass ...
6784
# harness-selftest.c:87:pass:setup
6885
# harness-selftest.c:96:pass:before
6986
# harness-selftest.c:98:pass:after
7087
# harness-selftest.c:92:pass:teardown same-process=0
7188
# OK fixture_parent.pass
72-
ok 13 fixture_parent.pass
89+
ok 18 fixture_parent.pass
7390
# RUN fixture_setup_failure.pass ...
7491
# harness-selftest.c:106:pass:setup
7592
# harness-selftest.c:108:pass:Expected 0 (0) == 1 (1)
7693
# pass: Test terminated by assertion
7794
# FAIL fixture_setup_failure.pass
78-
not ok 14 fixture_setup_failure.pass
79-
# FAILED: 8 / 14 tests passed.
95+
not ok 19 fixture_setup_failure.pass
96+
# FAILED: 12 / 19 tests passed.
8097
# 1 skipped test(s) detected. Consider enabling relevant config options to improve coverage.
81-
# Totals: pass:5 fail:6 xfail:1 xpass:1 skip:1 error:0
98+
# Totals: pass:9 fail:7 xfail:1 xpass:1 skip:1 error:0

0 commit comments

Comments
 (0)