Skip to content

Commit 8080428

Browse files
melverpaulmckrcu
authored andcommitted
kcsan: test: Use kunit_skip() to skip tests
Use the new kunit_skip() to skip tests if requirements were not met. Signed-off-by: Marco Elver <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent e807042 commit 8080428

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

kernel/kcsan/kcsan_test.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
#include <linux/types.h>
3030
#include <trace/events/printk.h>
3131

32+
#define KCSAN_TEST_REQUIRES(test, cond) do { \
33+
if (!(cond)) \
34+
kunit_skip((test), "Test requires: " #cond); \
35+
} while (0)
36+
3237
#ifdef CONFIG_CC_HAS_TSAN_COMPOUND_READ_BEFORE_WRITE
3338
#define __KCSAN_ACCESS_RW(alt) (KCSAN_ACCESS_COMPOUND | KCSAN_ACCESS_WRITE)
3439
#else
@@ -642,8 +647,7 @@ static void test_read_plain_atomic_write(struct kunit *test)
642647
};
643648
bool match_expect = false;
644649

645-
if (IS_ENABLED(CONFIG_KCSAN_IGNORE_ATOMICS))
646-
return;
650+
KCSAN_TEST_REQUIRES(test, !IS_ENABLED(CONFIG_KCSAN_IGNORE_ATOMICS));
647651

648652
begin_test_checks(test_kernel_read, test_kernel_write_atomic);
649653
do {
@@ -665,8 +669,7 @@ static void test_read_plain_atomic_rmw(struct kunit *test)
665669
};
666670
bool match_expect = false;
667671

668-
if (IS_ENABLED(CONFIG_KCSAN_IGNORE_ATOMICS))
669-
return;
672+
KCSAN_TEST_REQUIRES(test, !IS_ENABLED(CONFIG_KCSAN_IGNORE_ATOMICS));
670673

671674
begin_test_checks(test_kernel_read, test_kernel_atomic_rmw);
672675
do {

0 commit comments

Comments
 (0)