mirror of
https://github.com/torvalds/linux.git
synced 2024-12-13 06:32:50 +00:00
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>
This commit is contained in:
parent
7d005195e9
commit
c0bb2cf40e
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user