Skip to content

Commit d9d4de2

Browse files
Timur Tabipmladek
authored andcommitted
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 <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Tested-by: Petr Mladek <[email protected]> Acked-by: Marco Elver <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4e89a78 commit d9d4de2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tools/testing/selftests/kselftest_module.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
#define KSTM_MODULE_GLOBALS() \
1313
static unsigned int total_tests __initdata; \
14-
static unsigned int failed_tests __initdata
14+
static unsigned int failed_tests __initdata; \
15+
static unsigned int skipped_tests __initdata
1516

1617
#define KSTM_CHECK_ZERO(x) do { \
1718
total_tests++; \
@@ -21,11 +22,16 @@ static unsigned int failed_tests __initdata
2122
} \
2223
} while (0)
2324

24-
static inline int kstm_report(unsigned int total_tests, unsigned int failed_tests)
25+
static inline int kstm_report(unsigned int total_tests, unsigned int failed_tests,
26+
unsigned int skipped_tests)
2527
{
26-
if (failed_tests == 0)
27-
pr_info("all %u tests passed\n", total_tests);
28-
else
28+
if (failed_tests == 0) {
29+
if (skipped_tests) {
30+
pr_info("skipped %u tests\n", skipped_tests);
31+
pr_info("remaining %u tests passed\n", total_tests);
32+
} else
33+
pr_info("all %u tests passed\n", total_tests);
34+
} else
2935
pr_warn("failed %u out of %u tests\n", failed_tests, total_tests);
3036

3137
return failed_tests ? -EINVAL : 0;
@@ -36,7 +42,7 @@ static int __init __module##_init(void) \
3642
{ \
3743
pr_info("loaded.\n"); \
3844
selftest(); \
39-
return kstm_report(total_tests, failed_tests); \
45+
return kstm_report(total_tests, failed_tests, skipped_tests); \
4046
} \
4147
static void __exit __module##_exit(void) \
4248
{ \

0 commit comments

Comments
 (0)