1 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2023 Collabora Ltd
5 # Kselftest helpers for outputting in KTAP format. Based on kselftest.h.
10 ksft_cnt
= {"pass": 0, "fail": 0, "skip": 0}
20 print("TAP version 13")
23 def set_plan(num_tests
):
25 ksft_num_tests
= num_tests
26 print("1..{}".format(num_tests
))
31 f
"# Totals: pass:{ksft_cnt['pass']} fail:{ksft_cnt['fail']} xfail:0 xpass:0 skip:{ksft_cnt['skip']} error:0"
39 def _test_print(result
, description
, directive
=None):
41 directive_str
= f
"# {directive}"
45 global ksft_test_number
46 print(f
"{result} {ksft_test_number} {description} {directive_str}")
50 def test_result_pass(description
):
51 _test_print("ok", description
)
55 def test_result_fail(description
):
56 _test_print("not ok", description
)
60 def test_result_skip(description
):
61 _test_print("ok", description
, "SKIP")
65 def test_result(condition
, description
=""):
67 test_result_pass(description
)
69 test_result_fail(description
)
73 if ksft_cnt
["pass"] + ksft_cnt
["skip"] == ksft_num_tests
: