From: Shuah Khan Date: Fri, 4 Aug 2017 21:07:19 +0000 (-0600) Subject: selftests: kselftest framework: add error counter X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c0bb2cf40e42b2fe5c8aa1c4f6f4d09c98839d91;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 --- 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 { unsigned int ksft_xfail; unsigned int ksft_xpass; unsigned int ksft_xskip; + unsigned int ksft_error; }; static struct ksft_count ksft_cnt; @@ -36,7 +37,7 @@ 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; + ksft_cnt.ksft_xskip + ksft_cnt.ksft_error; } 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++; } 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_inc_error_cnt(void) { ksft_cnt.ksft_error++; } static inline int ksft_get_pass_cnt(void) { return ksft_cnt.ksft_pass; } static inline int ksft_get_fail_cnt(void) { return ksft_cnt.ksft_fail; } static inline int ksft_get_xfail_cnt(void) { return ksft_cnt.ksft_xfail; } static inline int ksft_get_xpass_cnt(void) { return ksft_cnt.ksft_xpass; } static inline int ksft_get_xskip_cnt(void) { return ksft_cnt.ksft_xskip; } +static inline int ksft_get_error_cnt(void) { return ksft_cnt.ksft_error; } static inline void ksft_print_header(void) { @@ -58,10 +61,10 @@ static inline void ksft_print_header(void) static inline void ksft_print_cnts(void) { - printf("Pass %d Fail %d Xfail %d Xpass %d Skip %d\n", + 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_xskip, ksft_cnt.ksft_error); printf("1..%d\n", ksft_test_num()); } @@ -111,6 +114,18 @@ static inline void ksft_test_result_skip(const char *msg, ...) va_end(args); } +static inline void ksft_test_result_error(const char *msg, ...) +{ + va_list args; + + ksft_cnt.ksft_error++; + + va_start(args, msg); + printf("not ok %d # error ", ksft_test_num()); + vprintf(msg, args); + va_end(args); +} + static inline int ksft_exit_pass(void) { ksft_print_cnts();