diff options
author | Paul Elder <paul.elder@pitt.edu> | 2017-06-12 09:56:47 +0300 |
---|---|---|
committer | Shuah Khan <shuahkh@osg.samsung.com> | 2017-06-13 21:57:35 +0300 |
commit | b6a4b66d845ae4c7f4eece419269c65ca332ba7b (patch) | |
tree | 7335f683c0e8ad813704aa3eb1922acebe8cfe71 /tools/testing/selftests | |
parent | 34a048cc06802556e5f96f325dc32cc2f6a11225 (diff) | |
download | linux-b6a4b66d845ae4c7f4eece419269c65ca332ba7b.tar.xz |
kselftest: add TAP13 conformant versions of ksft_* functions
Add TAP13 conformat output functions to kselftest.h.
Also add exit functions that output TAP13 exiting text, as well as
functions to keep track of testing progress.
Signed-off-by: Paul Elder <paul.elder@pitt.edu>
Signed-off-by: Alice Ferrazzi <alice.ferrazzi@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r-- | tools/testing/selftests/kselftest.h | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h index ef1c80d67ac7..1d874a50d957 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -31,38 +31,82 @@ struct ksft_count { static struct ksft_count ksft_cnt; +static inline int ksft_test_num(void) +{ + return ksft_cnt.ksft_pass + ksft_cnt.ksft_fail + + ksft_cnt.ksft_xfail + ksft_cnt.ksft_xpass + + ksft_cnt.ksft_xskip; +} + static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; } static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; } static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; } static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; } static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; } +static inline void ksft_print_header(void) +{ + printf("TAP version 13\n"); +} + static inline void ksft_print_cnts(void) { - printf("Pass: %d Fail: %d Xfail: %d Xpass: %d, Xskip: %d\n", - ksft_cnt.ksft_pass, ksft_cnt.ksft_fail, - ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass, - ksft_cnt.ksft_xskip); + printf("1..%d\n", ksft_test_num()); +} + +static inline void ksft_test_result_pass(const char *msg) +{ + ksft_cnt.ksft_pass++; + printf("ok %d %s\n", ksft_test_num(), msg); +} + +static inline void ksft_test_result_fail(const char *msg) +{ + ksft_cnt.ksft_fail++; + printf("not ok %d %s\n", ksft_test_num(), msg); +} + +static inline void ksft_test_result_skip(const char *msg) +{ + ksft_cnt.ksft_xskip++; + printf("ok %d # skip %s\n", ksft_test_num(), msg); } static inline int ksft_exit_pass(void) { + ksft_print_cnts(); exit(KSFT_PASS); } + static inline int ksft_exit_fail(void) { + printf("Bail out!\n"); + ksft_print_cnts(); exit(KSFT_FAIL); } + +static inline int ksft_exit_fail_msg(const char *msg) +{ + printf("Bail out! %s\n", msg); + ksft_print_cnts(); + exit(KSFT_FAIL); +} + static inline int ksft_exit_xfail(void) { + ksft_print_cnts(); exit(KSFT_XFAIL); } + static inline int ksft_exit_xpass(void) { + ksft_print_cnts(); exit(KSFT_XPASS); } + static inline int ksft_exit_skip(void) { + ksft_print_cnts(); exit(KSFT_SKIP); } |