aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kselftest_module.h
diff options
context:
space:
mode:
authorTimur Tabi <timur@kernel.org>2021-02-14 10:13:47 -0600
committerPetr Mladek <pmladek@suse.com>2021-02-15 11:07:42 +0100
commitd9d4de2309cd1721421c6488f1bb5744d2c83a39 (patch)
tree8b1cb32f56dd71a62343df380e33b54f447e89cf /tools/testing/selftests/kselftest_module.h
parentlib: use KSTM_MODULE_GLOBALS macro in kselftest drivers (diff)
downloadlinux-dev-d9d4de2309cd1721421c6488f1bb5744d2c83a39.tar.xz
linux-dev-d9d4de2309cd1721421c6488f1bb5744d2c83a39.zip
kselftest: add support for skipped tests
Update the kselftest framework to allow client drivers to specify that some tests were skipped. Signed-off-by: Timur Tabi <timur@kernel.org> Reviewed-by: Petr Mladek <pmladek@suse.com> Tested-by: Petr Mladek <pmladek@suse.com> Acked-by: Marco Elver <elver@google.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20210214161348.369023-3-timur@kernel.org
Diffstat (limited to 'tools/testing/selftests/kselftest_module.h')
-rw-r--r--tools/testing/selftests/kselftest_module.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/testing/selftests/kselftest_module.h b/tools/testing/selftests/kselftest_module.h
index e8eafaf0941a..e2ea41de3f35 100644
--- a/tools/testing/selftests/kselftest_module.h
+++ b/tools/testing/selftests/kselftest_module.h
@@ -11,7 +11,8 @@
#define KSTM_MODULE_GLOBALS() \
static unsigned int total_tests __initdata; \
-static unsigned int failed_tests __initdata
+static unsigned int failed_tests __initdata; \
+static unsigned int skipped_tests __initdata
#define KSTM_CHECK_ZERO(x) do { \
total_tests++; \
@@ -21,11 +22,16 @@ static unsigned int failed_tests __initdata
} \
} while (0)
-static inline int kstm_report(unsigned int total_tests, unsigned int failed_tests)
+static inline int kstm_report(unsigned int total_tests, unsigned int failed_tests,
+ unsigned int skipped_tests)
{
- if (failed_tests == 0)
- pr_info("all %u tests passed\n", total_tests);
- else
+ if (failed_tests == 0) {
+ if (skipped_tests) {
+ pr_info("skipped %u tests\n", skipped_tests);
+ pr_info("remaining %u tests passed\n", total_tests);
+ } else
+ pr_info("all %u tests passed\n", total_tests);
+ } else
pr_warn("failed %u out of %u tests\n", failed_tests, total_tests);
return failed_tests ? -EINVAL : 0;
@@ -36,7 +42,7 @@ static int __init __module##_init(void) \
{ \
pr_info("loaded.\n"); \
selftest(); \
- return kstm_report(total_tests, failed_tests); \
+ return kstm_report(total_tests, failed_tests, skipped_tests); \
} \
static void __exit __module##_exit(void) \
{ \