diff options
Diffstat (limited to 'tools/testing/selftests/kselftest.h')
| -rw-r--r-- | tools/testing/selftests/kselftest.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h index c3b6d2604b1e..6d809f08ab7b 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -54,6 +54,7 @@ #include <stdlib.h> #include <unistd.h> #include <stdarg.h> +#include <stdbool.h> #include <string.h> #include <stdio.h> #include <sys/utsname.h> @@ -92,6 +93,14 @@ #endif #define __printf(a, b) __attribute__((format(printf, a, b))) +#ifndef __always_unused +#define __always_unused __attribute__((__unused__)) +#endif + +#ifndef __maybe_unused +#define __maybe_unused __attribute__((__unused__)) +#endif + /* counters */ struct ksft_count { unsigned int ksft_pass; @@ -104,6 +113,7 @@ struct ksft_count { static struct ksft_count ksft_cnt; static unsigned int ksft_plan; +static bool ksft_debug_enabled; static inline unsigned int ksft_test_num(void) { @@ -175,6 +185,18 @@ static inline __printf(1, 2) void ksft_print_msg(const char *msg, ...) va_end(args); } +static inline void ksft_print_dbg_msg(const char *msg, ...) +{ + va_list args; + + if (!ksft_debug_enabled) + return; + + va_start(args, msg); + ksft_print_msg(msg, args); + va_end(args); +} + static inline void ksft_perror(const char *msg) { ksft_print_msg("%s: %s (%d)\n", msg, strerror(errno), errno); @@ -377,6 +399,7 @@ static inline __noreturn void ksft_exit_fail(void) #define ksft_finished() \ ksft_exit(ksft_plan == \ ksft_cnt.ksft_pass + \ + ksft_cnt.ksft_xpass + \ ksft_cnt.ksft_xfail + \ ksft_cnt.ksft_xskip) @@ -453,4 +476,15 @@ static inline int ksft_min_kernel_version(unsigned int min_major, return major > min_major || (major == min_major && minor >= min_minor); } +static inline void ksft_reset_state(void) +{ + ksft_cnt.ksft_pass = 0; + ksft_cnt.ksft_fail = 0; + ksft_cnt.ksft_xfail = 0; + ksft_cnt.ksft_xpass = 0; + ksft_cnt.ksft_xskip = 0; + ksft_cnt.ksft_error = 0; + ksft_plan = 0; +} + #endif /* __KSELFTEST_H */ |
