diff mbox

[kvm-unit-tests,32/32] lib: add report_pass

Message ID 20170421005004.137260-33-dmatlack@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Matlack April 21, 2017, 12:50 a.m. UTC
The assertion macros in the vmx tests only call report() if the test
fails. This avoids a lot of logging (e.g. vmx_ept_access_test_reserved_bits
checks 3460 assertions). However the test runner interprets passing runs
as "skipped" because it looks like no testcases were run. Add a function
called report_pass(), which lets tests report that a test passed without
printing anything to the console.

Signed-off-by: David Matlack <dmatlack@google.com>
---
 lib/libcflat.h | 1 +
 lib/report.c   | 7 +++++++
 x86/vmx.h      | 3 +++
 3 files changed, 11 insertions(+)
diff mbox

Patch

diff --git a/lib/libcflat.h b/lib/libcflat.h
index 7e4bce1dd335..b1ea5e607033 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -104,6 +104,7 @@  extern void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
 extern void report_abort(const char *msg_fmt, ...);
 extern void report_skip(const char *msg_fmt, ...);
 extern void report_info(const char *msg_fmt, ...);
+extern void report_pass(void);
 extern int report_summary(void);
 
 bool simple_glob(const char *text, const char *pattern);
diff --git a/lib/report.c b/lib/report.c
index 1033f1e44e99..aa23b6582512 100644
--- a/lib/report.c
+++ b/lib/report.c
@@ -19,6 +19,13 @@  static struct spinlock lock;
 
 #define PREFIX_DELIMITER ": "
 
+void report_pass(void)
+{
+	spin_lock(&lock);
+	tests++;
+	spin_unlock(&lock);
+}
+
 void report_prefix_pushf(const char *prefix_fmt, ...)
 {
 	va_list va;
diff --git a/x86/vmx.h b/x86/vmx.h
index 2390c4a99901..4194429e07b8 100644
--- a/x86/vmx.h
+++ b/x86/vmx.h
@@ -726,6 +726,7 @@  do { \
 		dump_stack(); \
 		__abort_test(); \
 	} \
+	report_pass(); \
 } while (0)
 
 #define TEST_ASSERT_MSG(cond, fmt, args...) \
@@ -736,6 +737,7 @@  do { \
 		dump_stack(); \
 		__abort_test(); \
 	} \
+	report_pass(); \
 } while (0)
 
 #define __TEST_EQ(a, b, a_str, b_str, assertion, fmt, args...) \
@@ -759,6 +761,7 @@  do { \
 		if (assertion) \
 			__abort_test(); \
 	} \
+	report_pass(); \
 } while (0)
 
 #define TEST_ASSERT_EQ(a, b) __TEST_EQ(a, b, #a, #b, 1, "")