Skip to content

Commit

Permalink
kcsan: test: Use kunit_skip() to skip tests
Browse files Browse the repository at this point in the history
Use the new kunit_skip() to skip tests if requirements were not met.

Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
  • Loading branch information
Marco Elver authored and Paul E. McKenney committed Sep 13, 2021
1 parent e807042 commit 8080428
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions kernel/kcsan/kcsan_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
#include <linux/types.h>
#include <trace/events/printk.h>

#define KCSAN_TEST_REQUIRES(test, cond) do { \
if (!(cond)) \
kunit_skip((test), "Test requires: " #cond); \
} while (0)

#ifdef CONFIG_CC_HAS_TSAN_COMPOUND_READ_BEFORE_WRITE
#define __KCSAN_ACCESS_RW(alt) (KCSAN_ACCESS_COMPOUND | KCSAN_ACCESS_WRITE)
#else
Expand Down Expand Up @@ -642,8 +647,7 @@ static void test_read_plain_atomic_write(struct kunit *test)
};
bool match_expect = false;

if (IS_ENABLED(CONFIG_KCSAN_IGNORE_ATOMICS))
return;
KCSAN_TEST_REQUIRES(test, !IS_ENABLED(CONFIG_KCSAN_IGNORE_ATOMICS));

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

if (IS_ENABLED(CONFIG_KCSAN_IGNORE_ATOMICS))
return;
KCSAN_TEST_REQUIRES(test, !IS_ENABLED(CONFIG_KCSAN_IGNORE_ATOMICS));

begin_test_checks(test_kernel_read, test_kernel_atomic_rmw);
do {
Expand Down

0 comments on commit 8080428

Please sign in to comment.