summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorShuah Khan <shuahkh@osg.samsung.com>2017-08-04 15:07:19 -0600
committerShuah Khan <shuahkh@osg.samsung.com>2017-08-09 10:39:05 -0600
commitc0bb2cf40e42b2fe5c8aa1c4f6f4d09c98839d91 (patch)
treec2b7e7ac624bc43c0de04d51f5dca308ad931679 /tools
parent7d005195e9eb6518017e02c1468e3de693cc7442 (diff)
downloadop-kernel-dev-c0bb2cf40e42b2fe5c8aa1c4f6f4d09c98839d91.zip
op-kernel-dev-c0bb2cf40e42b2fe5c8aa1c4f6f4d09c98839d91.tar.gz
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')
-rw-r--r--tools/testing/selftests/kselftest.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
index 45bf259..e2714d0 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();
OpenPOWER on IntegriCloud