From 09342fcc9efb3f6c28a1c602ad5f949cc806657e Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Mon, 22 Feb 2016 18:04:28 +0000 Subject: [PATCH] Alter xtf_success() to take a string to print ... to be consistent with the rest of the reporting interface. Every reporting function is modified to accept NULL if there is nothing interesting to print. Signed-off-by: Andrew Cooper --- common/report.c | 63 ++++++++++++++++++++++++------------ include/xtf/report.h | 2 +- tests/example/main.c | 4 +-- tests/selftest/main.c | 2 +- tests/swint-emulation/main.c | 2 +- 5 files changed, 46 insertions(+), 27 deletions(-) diff --git a/common/report.c b/common/report.c index 1aaf6e6..685542c 100644 --- a/common/report.c +++ b/common/report.c @@ -35,53 +35,74 @@ static void set_status(enum test_status s) status = s; } -void xtf_success(void) +void xtf_success(const char *fmt, ...) { set_status(STATUS_SUCCESS); + + if ( fmt ) + { + va_list args; + + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); + } } void xtf_warning(const char *fmt, ...) { - va_list args; - warnings = true; - va_start(args, fmt); - vprintk(fmt, args); - va_end(args); + if ( fmt ) + { + va_list args; + + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); + } } void xtf_skip(const char *fmt, ...) { - va_list args; - set_status(STATUS_SKIP); - va_start(args, fmt); - vprintk(fmt, args); - va_end(args); + if ( fmt ) + { + va_list args; + + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); + } } void xtf_error(const char *fmt, ...) { - va_list args; - set_status(STATUS_ERROR); - va_start(args, fmt); - vprintk(fmt, args); - va_end(args); + if ( fmt ) + { + va_list args; + + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); + } } void xtf_failure(const char *fmt, ...) { - va_list args; - set_status(STATUS_FAILURE); - va_start(args, fmt); - vprintk(fmt, args); - va_end(args); + if ( fmt ) + { + va_list args; + + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); + } } void xtf_report_status(void) diff --git a/include/xtf/report.h b/include/xtf/report.h index 14e6396..6ec5047 100644 --- a/include/xtf/report.h +++ b/include/xtf/report.h @@ -26,7 +26,7 @@ /** * Report test success. */ -void xtf_success(void); +void xtf_success(const char *fmt, ...) __printf(1, 2); /** * Report a test warning. diff --git a/tests/example/main.c b/tests/example/main.c index 7cbe5c5..1a34726 100644 --- a/tests/example/main.c +++ b/tests/example/main.c @@ -12,9 +12,7 @@ void test_main(void) { - printk("Hello World\n"); - - xtf_success(); + xtf_success("Hello World\n"); } /* diff --git a/tests/selftest/main.c b/tests/selftest/main.c index d04935c..6f982ec 100644 --- a/tests/selftest/main.c +++ b/tests/selftest/main.c @@ -237,7 +237,7 @@ void test_main(void) #endif test_unhandled_exception_hook(); - xtf_success(); + xtf_success(NULL); } /* diff --git a/tests/swint-emulation/main.c b/tests/swint-emulation/main.c index e24b2a0..6efe54c 100644 --- a/tests/swint-emulation/main.c +++ b/tests/swint-emulation/main.c @@ -370,7 +370,7 @@ void test_main(void) xtf_exlog_stop(); - xtf_success(); + xtf_success(NULL); } /* -- 2.39.5