2 * kselftest.h: kselftest framework return codes to include from
5 * Copyright (c) 2014 Shuah Khan <shuahkh@osg.samsung.com>
6 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
8 * This file is released under the GPLv2.
17 /* define kselftest exit codes */
22 /* Treat skip as pass */
23 #define KSFT_SKIP KSFT_PASS
27 unsigned int ksft_pass;
28 unsigned int ksft_fail;
29 unsigned int ksft_xfail;
30 unsigned int ksft_xpass;
31 unsigned int ksft_xskip;
32 unsigned int ksft_error;
35 static struct ksft_count ksft_cnt;
37 static inline int ksft_test_num(void)
39 return ksft_cnt.ksft_pass + ksft_cnt.ksft_fail +
40 ksft_cnt.ksft_xfail + ksft_cnt.ksft_xpass +
41 ksft_cnt.ksft_xskip + ksft_cnt.ksft_error;
44 static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; }
45 static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; }
46 static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; }
47 static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; }
48 static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; }
49 static inline void ksft_inc_error_cnt(void) { ksft_cnt.ksft_error++; }
51 static inline int ksft_get_pass_cnt(void) { return ksft_cnt.ksft_pass; }
52 static inline int ksft_get_fail_cnt(void) { return ksft_cnt.ksft_fail; }
53 static inline int ksft_get_xfail_cnt(void) { return ksft_cnt.ksft_xfail; }
54 static inline int ksft_get_xpass_cnt(void) { return ksft_cnt.ksft_xpass; }
55 static inline int ksft_get_xskip_cnt(void) { return ksft_cnt.ksft_xskip; }
56 static inline int ksft_get_error_cnt(void) { return ksft_cnt.ksft_error; }
58 static inline void ksft_print_header(void)
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 */