2 # SPDX-License-Identifier: GPL-2.0
4 # This tests the operation of lib.sh itself.
35 FAIL_TO_XFAIL
=yes do_test
"txfail" false
57 FAIL_TO_XFAIL
=yes do_test
"xfalse" false
70 xfail_on_slow do_test
"slow_false" false
91 local expect_ret
=$1; shift
92 local expect_retmsg
=$1; shift
93 local -a tests
=( "$@" )
95 local status_names
=(pass fail xfail xpass skip
)
101 # Run this in a subshell, so that our environment is intact.
102 out
=$
(ret_tests_run
"${tests[@]}")
105 (( ret
== expect_ret
))
106 check_err $?
"RET=$ret expected $expect_ret"
108 [[ $out == $expect_retmsg ]]
109 check_err $?
"retmsg=$out expected $expect_retmsg"
111 log_test
"RET $(echo ${tests[@]}) -> ${status_names[$ret]}"
116 ret_subtest
$ksft_pass ""
118 ret_subtest
$ksft_pass "" tpass
119 ret_subtest
$ksft_fail "tfail" tfail
120 ret_subtest
$ksft_xfail "txfail" txfail
122 ret_subtest
$ksft_pass "" tpass tpass
123 ret_subtest
$ksft_fail "tfail" tpass tfail
124 ret_subtest
$ksft_xfail "txfail" tpass txfail
126 ret_subtest
$ksft_fail "tfail" tfail tpass
127 ret_subtest
$ksft_xfail "txfail" txfail tpass
129 ret_subtest
$ksft_fail "tfail" tfail tfail
130 ret_subtest
$ksft_fail "tfail" tfail txfail
132 ret_subtest
$ksft_fail "tfail" txfail tfail
134 ret_subtest
$ksft_xfail "txfail" txfail txfail
137 exit_status_tests_run
()
140 tests_run
> /dev
/null
144 exit_status_subtest
()
146 local expect_exit_status
=$1; shift
147 local tests
=$1; shift
150 local status_names
=(pass fail xfail xpass skip
)
156 # Run this in a subshell, so that our environment is intact.
157 out
=$
(TESTS
="$tests" exit_status_tests_run
)
160 (( exit_status
== expect_exit_status
))
161 check_err $?
"EXIT_STATUS=$exit_status, expected $expect_exit_status"
163 log_test
"EXIT_STATUS $tests$what -> ${status_names[$exit_status]}"
168 exit_status_subtest
$ksft_pass ":"
170 exit_status_subtest
$ksft_pass "pass"
171 exit_status_subtest
$ksft_fail "fail"
172 exit_status_subtest
$ksft_pass "xfail"
173 exit_status_subtest
$ksft_skip "skip"
175 exit_status_subtest
$ksft_pass "pass pass"
176 exit_status_subtest
$ksft_fail "pass fail"
177 exit_status_subtest
$ksft_pass "pass xfail"
178 exit_status_subtest
$ksft_skip "pass skip"
180 exit_status_subtest
$ksft_fail "fail pass"
181 exit_status_subtest
$ksft_pass "xfail pass"
182 exit_status_subtest
$ksft_skip "skip pass"
184 exit_status_subtest
$ksft_fail "fail fail"
185 exit_status_subtest
$ksft_fail "fail xfail"
186 exit_status_subtest
$ksft_fail "fail skip"
188 exit_status_subtest
$ksft_fail "xfail fail"
189 exit_status_subtest
$ksft_fail "skip fail"
191 exit_status_subtest
$ksft_pass "xfail xfail"
192 exit_status_subtest
$ksft_skip "xfail skip"
193 exit_status_subtest
$ksft_skip "skip xfail"
195 exit_status_subtest
$ksft_skip "skip skip"
197 KSFT_MACHINE_SLOW
=yes \
198 exit_status_subtest
$ksft_pass "slow_xfail" ": slow"
200 KSFT_MACHINE_SLOW
=no \
201 exit_status_subtest
$ksft_fail "slow_xfail" ": fast"
204 trap pre_cleanup EXIT