summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kselftest.h
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@pitt.edu>2017-06-28 17:40:20 +0300
committerShuah Khan <shuahkh@osg.samsung.com>2017-07-01 01:14:55 +0300
commit151b2732111f0743e764a7bc62d4f580341a62f3 (patch)
tree8040c7e514545b2e04512f4499f88286151ec2ae /tools/testing/selftests/kselftest.h
parent796a3bae2fba6810427efdb314a1c126c9490fb3 (diff)
downloadlinux-151b2732111f0743e764a7bc62d4f580341a62f3.tar.xz
kselftest: make ksft_* output functions variadic
Make the ksft_* output functions variadic to allow string formatting directly in these functions. Signed-off-by: Paul Elder <paul.elder@pitt.edu> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing/selftests/kselftest.h')
-rw-r--r--tools/testing/selftests/kselftest.h55
1 files changed, 43 insertions, 12 deletions
diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
index be01f2d15472..a00844e4c915 100644
--- a/tools/testing/selftests/kselftest.h
+++ b/tools/testing/selftests/kselftest.h
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <unistd.h>
+#include <stdarg.h>
/* define kselftest exit codes */
#define KSFT_PASS 0
@@ -54,22 +55,40 @@ static inline void ksft_print_cnts(void)
printf("1..%d\n", ksft_test_num());
}
-static inline void ksft_test_result_pass(const char *msg)
+static inline void ksft_test_result_pass(const char *msg, ...)
{
+ va_list args;
+
ksft_cnt.ksft_pass++;
- printf("ok %d %s\n", ksft_test_num(), msg);
+
+ va_start(args, msg);
+ printf("ok %d ", ksft_test_num());
+ vprintf(msg, args);
+ va_end(args);
}
-static inline void ksft_test_result_fail(const char *msg)
+static inline void ksft_test_result_fail(const char *msg, ...)
{
+ va_list args;
+
ksft_cnt.ksft_fail++;
- printf("not ok %d %s\n", ksft_test_num(), msg);
+
+ va_start(args, msg);
+ printf("not ok %d ", ksft_test_num());
+ vprintf(msg, args);
+ va_end(args);
}
-static inline void ksft_test_result_skip(const char *msg)
+static inline void ksft_test_result_skip(const char *msg, ...)
{
+ va_list args;
+
ksft_cnt.ksft_xskip++;
- printf("ok %d # skip %s\n", ksft_test_num(), msg);
+
+ va_start(args, msg);
+ printf("ok %d # skip ", ksft_test_num());
+ vprintf(msg, args);
+ va_end(args);
}
static inline int ksft_exit_pass(void)
@@ -85,9 +104,15 @@ static inline int ksft_exit_fail(void)
exit(KSFT_FAIL);
}
-static inline int ksft_exit_fail_msg(const char *msg)
+static inline int ksft_exit_fail_msg(const char *msg, ...)
{
- printf("Bail out! %s\n", msg);
+ va_list args;
+
+ va_start(args, msg);
+ printf("Bail out! ");
+ vprintf(msg, args);
+ va_end(args);
+
ksft_print_cnts();
exit(KSFT_FAIL);
}
@@ -104,12 +129,18 @@ static inline int ksft_exit_xpass(void)
exit(KSFT_XPASS);
}
-static inline int ksft_exit_skip(const char *msg)
+static inline int ksft_exit_skip(const char *msg, ...)
{
- if (msg)
- printf("1..%d # Skipped: %s\n", ksft_test_num(), msg);
- else
+ if (msg) {
+ va_list args;
+
+ va_start(args, msg);
+ printf("1..%d # Skipped: ", ksft_test_num());
+ vprintf(msg, args);
+ va_end(args);
+ } else {
ksft_print_cnts();
+ }
exit(KSFT_SKIP);
}