diff options
author | Shuah Khan <shuahkh@osg.samsung.com> | 2017-08-04 17:07:19 -0400 |
---|---|---|
committer | Shuah Khan <shuahkh@osg.samsung.com> | 2017-08-09 12:39:05 -0400 |
commit | c0bb2cf40e42b2fe5c8aa1c4f6f4d09c98839d91 (patch) | |
tree | c2b7e7ac624bc43c0de04d51f5dca308ad931679 /tools/testing/selftests | |
parent | 7d005195e9eb6518017e02c1468e3de693cc7442 (diff) |
selftests: kselftest framework: add error counter
Some tests track errors in addition to test failures. Add ksft_error
counter, ksft_get_error_cnt(), and ksft_test_result_error() API to
get the counter value and print error message.
Update ksft_print_cnts(), and ksft_test_num() to include error counter.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r-- | tools/testing/selftests/kselftest.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h index 45bf25905279..e2714d0a1452 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h | |||
@@ -28,6 +28,7 @@ struct ksft_count { | |||
28 | unsigned int ksft_xfail; | 28 | unsigned int ksft_xfail; |
29 | unsigned int ksft_xpass; | 29 | unsigned int ksft_xpass; |
30 | unsigned int ksft_xskip; | 30 | unsigned int ksft_xskip; |
31 | unsigned int ksft_error; | ||
31 | }; | 32 | }; |
32 | 33 | ||
33 | static struct ksft_count ksft_cnt; | 34 | static struct ksft_count ksft_cnt; |
@@ -36,7 +37,7 @@ static inline int ksft_test_num(void) | |||
36 | { | 37 | { |
37 | return ksft_cnt.ksft_pass + ksft_cnt.ksft_fail + | 38 | return ksft_cnt.ksft_pass + ksft_cnt.ksft_fail + |
38 | ksft_cnt.ksft_xfail + ksft_cnt.ksft_xpass + | 39 | ksft_cnt.ksft_xfail + ksft_cnt.ksft_xpass + |
39 | ksft_cnt.ksft_xskip; | 40 | ksft_cnt.ksft_xskip + ksft_cnt.ksft_error; |
40 | } | 41 | } |
41 | 42 | ||
42 | static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; } | 43 | static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; } |
@@ -44,12 +45,14 @@ static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; } | |||
44 | static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; } | 45 | static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; } |
45 | static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; } | 46 | static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; } |
46 | static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; } | 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++; } | ||
47 | 49 | ||
48 | static inline int ksft_get_pass_cnt(void) { return ksft_cnt.ksft_pass; } | 50 | static inline int ksft_get_pass_cnt(void) { return ksft_cnt.ksft_pass; } |
49 | static inline int ksft_get_fail_cnt(void) { return ksft_cnt.ksft_fail; } | 51 | static inline int ksft_get_fail_cnt(void) { return ksft_cnt.ksft_fail; } |
50 | static inline int ksft_get_xfail_cnt(void) { return ksft_cnt.ksft_xfail; } | 52 | static inline int ksft_get_xfail_cnt(void) { return ksft_cnt.ksft_xfail; } |
51 | static inline int ksft_get_xpass_cnt(void) { return ksft_cnt.ksft_xpass; } | 53 | static inline int ksft_get_xpass_cnt(void) { return ksft_cnt.ksft_xpass; } |
52 | static inline int ksft_get_xskip_cnt(void) { return ksft_cnt.ksft_xskip; } | 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; } | ||
53 | 56 | ||
54 | static inline void ksft_print_header(void) | 57 | static inline void ksft_print_header(void) |
55 | { | 58 | { |
@@ -58,10 +61,10 @@ static inline void ksft_print_header(void) | |||
58 | 61 | ||
59 | static inline void ksft_print_cnts(void) | 62 | static inline void ksft_print_cnts(void) |
60 | { | 63 | { |
61 | printf("Pass %d Fail %d Xfail %d Xpass %d Skip %d\n", | 64 | printf("Pass %d Fail %d Xfail %d Xpass %d Skip %d Error %d\n", |
62 | ksft_cnt.ksft_pass, ksft_cnt.ksft_fail, | 65 | ksft_cnt.ksft_pass, ksft_cnt.ksft_fail, |
63 | ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass, | 66 | ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass, |
64 | ksft_cnt.ksft_xskip); | 67 | ksft_cnt.ksft_xskip, ksft_cnt.ksft_error); |
65 | printf("1..%d\n", ksft_test_num()); | 68 | printf("1..%d\n", ksft_test_num()); |
66 | } | 69 | } |
67 | 70 | ||
@@ -111,6 +114,18 @@ static inline void ksft_test_result_skip(const char *msg, ...) | |||
111 | va_end(args); | 114 | va_end(args); |
112 | } | 115 | } |
113 | 116 | ||
117 | static inline void ksft_test_result_error(const char *msg, ...) | ||
118 | { | ||
119 | va_list args; | ||
120 | |||
121 | ksft_cnt.ksft_error++; | ||
122 | |||
123 | va_start(args, msg); | ||
124 | printf("not ok %d # error ", ksft_test_num()); | ||
125 | vprintf(msg, args); | ||
126 | va_end(args); | ||
127 | } | ||
128 | |||
114 | static inline int ksft_exit_pass(void) | 129 | static inline int ksft_exit_pass(void) |
115 | { | 130 | { |
116 | ksft_print_cnts(); | 131 | ksft_print_cnts(); |