1 /* SPDX-License-Identifier: GPL-2.0 */
3 * kselftest.h: kselftest framework return codes to include from
6 * Copyright (c) 2014 Shuah Khan <shuahkh@osg.samsung.com>
7 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
17 /* define kselftest exit codes */
26 unsigned int ksft_pass;
27 unsigned int ksft_fail;
28 unsigned int ksft_xfail;
29 unsigned int ksft_xpass;
30 unsigned int ksft_xskip;
31 unsigned int ksft_error;
34 static struct ksft_count ksft_cnt;
36 static inline int ksft_test_num(void)
38 return ksft_cnt.ksft_pass + ksft_cnt.ksft_fail +
39 ksft_cnt.ksft_xfail + ksft_cnt.ksft_xpass +
40 ksft_cnt.ksft_xskip + ksft_cnt.ksft_error;
43 static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; }
44 static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; }
45 static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; }
46 static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; }
47 static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; }
48 static inline void ksft_inc_error_cnt(void) { ksft_cnt.ksft_error++; }
50 static inline int ksft_get_pass_cnt(void) { return ksft_cnt.ksft_pass; }
51 static inline int ksft_get_fail_cnt(void) { return ksft_cnt.ksft_fail; }
52 static inline int ksft_get_xfail_cnt(void) { return ksft_cnt.ksft_xfail; }
53 static inline int ksft_get_xpass_cnt(void) { return ksft_cnt.ksft_xpass; }
54 static inline int ksft_get_xskip_cnt(void) { return ksft_cnt.ksft_xskip; }
55 static inline int ksft_get_error_cnt(void) { return ksft_cnt.ksft_error; }
57 static inline void ksft_print_header(void)
59 if (!(getenv("KSFT_TAP_LEVEL")))
60 printf("TAP version 13\n");
63 static inline void ksft_print_cnts(void)
65 printf("Pass %d Fail %d Xfail %d Xpass %d Skip %d Error %d\n",
66 ksft_cnt.ksft_pass, ksft_cnt.ksft_fail,
67 ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass,
68 ksft_cnt.ksft_xskip, ksft_cnt.ksft_error);
69 printf("1..%d\n", ksft_test_num());
72 static inline void ksft_print_msg(const char *msg, ...)
82 static inline void ksft_test_result_pass(const char *msg, ...)
89 printf("ok %d ", ksft_test_num());
94 static inline void ksft_test_result_fail(const char *msg, ...)
101 printf("not ok %d ", ksft_test_num());
106 static inline void ksft_test_result_skip(const char *msg, ...)
110 ksft_cnt.ksft_xskip++;
113 printf("ok %d # skip ", ksft_test_num());
118 static inline void ksft_test_result_error(const char *msg, ...)
122 ksft_cnt.ksft_error++;
125 printf("not ok %d # error ", ksft_test_num());
130 static inline int ksft_exit_pass(void)
136 static inline int ksft_exit_fail(void)
138 printf("Bail out!\n");
143 static inline int ksft_exit_fail_msg(const char *msg, ...)
148 printf("Bail out! ");
156 static inline int ksft_exit_xfail(void)
162 static inline int ksft_exit_xpass(void)
168 static inline int ksft_exit_skip(const char *msg, ...)
174 printf("1..%d # Skipped: ", ksft_test_num());
183 #endif /* __KSELFTEST_H */