diff options
author | Kees Cook <keescook@chromium.org> | 2019-04-24 16:12:37 -0700 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2019-04-25 13:15:46 -0600 |
commit | 5821ba969511daf27fa917515904f7b823259cf7 (patch) | |
tree | 37b040c435d57a2e3485d297c42eb877cda6d7a7 /tools/testing/selftests/kselftest.h | |
parent | f41c322f17ec4aa809222dc352439d80862c175b (diff) | |
download | linux-stable-5821ba969511daf27fa917515904f7b823259cf7.tar.gz linux-stable-5821ba969511daf27fa917515904f7b823259cf7.tar.bz2 linux-stable-5821ba969511daf27fa917515904f7b823259cf7.zip |
selftests: Add test plan API to kselftest.h and adjust callers
The test plan for TAP needs to be declared immediately after the header.
This adds the test plan API to kselftest.h and updates all callers to
declare their expected test counts.
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests/kselftest.h')
-rw-r--r-- | tools/testing/selftests/kselftest.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h index 7f078e79a9fa..ec15c4f6af55 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -33,6 +33,7 @@ struct ksft_count { }; static struct ksft_count ksft_cnt; +static unsigned int ksft_plan; static inline int ksft_test_num(void) { @@ -61,13 +62,21 @@ static inline void ksft_print_header(void) printf("TAP version 13\n"); } +static inline void ksft_set_plan(unsigned int plan) +{ + ksft_plan = plan; + printf("1..%d\n", ksft_plan); +} + static inline void ksft_print_cnts(void) { + if (ksft_plan != ksft_test_num()) + printf("# Planned tests != run tests (%u != %u)\n", + ksft_plan, ksft_test_num()); printf("# Pass %d Fail %d Xfail %d Xpass %d Skip %d Error %d\n", ksft_cnt.ksft_pass, ksft_cnt.ksft_fail, ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass, ksft_cnt.ksft_xskip, ksft_cnt.ksft_error); - printf("1..%d\n", ksft_test_num()); } static inline void ksft_print_msg(const char *msg, ...) @@ -172,7 +181,7 @@ static inline int ksft_exit_skip(const char *msg, ...) va_list args; va_start(args, msg); - printf("not ok %d # SKIP ", ksft_test_num()); + printf("not ok %d # SKIP ", 1 + ksft_test_num()); vprintf(msg, args); va_end(args); } else { |