diff mbox series

[kvm-unit-tests,v2,3/5] lib: Introduce report_pass and report_fail

Message ID 20211005090921.1816373-4-scgl@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests,v2,1/5] s390x: Add specification exception test | expand

Commit Message

Janis Schoetterl-Glausch Oct. 5, 2021, 9:09 a.m. UTC
These functions can be used instead of report(1/true/0/false, ...)
and read a bit nicer.

Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
---
There is probably a better name than report_passed() for the function
without a message...

 lib/libcflat.h |  6 +++++-
 lib/report.c   | 20 +++++++++++++++++++-
 x86/vmx.h      |  6 +++---
 3 files changed, 27 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/lib/libcflat.h b/lib/libcflat.h
index 39f4552..9bb7e08 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -106,7 +106,11 @@  extern void report_skip(const char *msg_fmt, ...)
 					__attribute__((format(printf, 1, 2)));
 extern void report_info(const char *msg_fmt, ...)
 					__attribute__((format(printf, 1, 2)));
-extern void report_pass(void);
+extern void report_pass(const char *msg_fmt, ...)
+					__attribute__((format(printf, 1, 2)));
+extern void report_fail(const char *msg_fmt, ...)
+					__attribute__((format(printf, 1, 2)));
+extern void report_passed(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 2255dc3..8e9bff5 100644
--- a/lib/report.c
+++ b/lib/report.c
@@ -19,7 +19,7 @@  static struct spinlock lock;
 
 #define PREFIX_DELIMITER ": "
 
-void report_pass(void)
+void report_passed(void)
 {
 	spin_lock(&lock);
 	tests++;
@@ -112,6 +112,24 @@  void report(bool pass, const char *msg_fmt, ...)
 	va_end(va);
 }
 
+void report_pass(const char *msg_fmt, ...)
+{
+	va_list va;
+
+	va_start(va, msg_fmt);
+	va_report(msg_fmt, true, false, false, va);
+	va_end(va);
+}
+
+void report_fail(const char *msg_fmt, ...)
+{
+	va_list va;
+
+	va_start(va, msg_fmt);
+	va_report(msg_fmt, false, false, false, va);
+	va_end(va);
+}
+
 void report_xfail(bool xfail, bool pass, const char *msg_fmt, ...)
 {
 	va_list va;
diff --git a/x86/vmx.h b/x86/vmx.h
index ebd014c..fd0174a 100644
--- a/x86/vmx.h
+++ b/x86/vmx.h
@@ -928,7 +928,7 @@  do { \
 		dump_stack(); \
 		__abort_test(); \
 	} \
-	report_pass(); \
+	report_passed(); \
 } while (0)
 
 #define TEST_ASSERT_MSG(cond, fmt, args...) \
@@ -939,7 +939,7 @@  do { \
 		dump_stack(); \
 		__abort_test(); \
 	} \
-	report_pass(); \
+	report_passed(); \
 } while (0)
 
 #define __TEST_EQ(a, b, a_str, b_str, assertion, fmt, args...) \
@@ -964,7 +964,7 @@  do { \
 		if (assertion) \
 			__abort_test(); \
 	} \
-	report_pass(); \
+	report_passed(); \
 } while (0)
 
 #define TEST_ASSERT_EQ(a, b) __TEST_EQ(a, b, #a, #b, 1, "")