Commit f51733e2 authored by Marco Elver's avatar Marco Elver Committed by Linus Torvalds

kfence: test: use kunit_skip() to skip tests

Use the new kunit_skip() to skip tests if requirements were not met.  It
makes it easier to see in KUnit's summary if there were skipped tests.

Link: https://lkml.kernel.org/r/20210922182541.1372400-1-elver@google.comSigned-off-by: default avatarMarco Elver <elver@google.com>
Reviewed-by: default avatarDavid Gow <davidgow@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Aleksandr Nogikh <nogikh@google.com>
Cc: Taras Madan <tarasmadan@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5cc906b4
...@@ -32,6 +32,11 @@ ...@@ -32,6 +32,11 @@
#define arch_kfence_test_address(addr) (addr) #define arch_kfence_test_address(addr) (addr)
#endif #endif
#define KFENCE_TEST_REQUIRES(test, cond) do { \
if (!(cond)) \
kunit_skip((test), "Test requires: " #cond); \
} while (0)
/* Report as observed from console. */ /* Report as observed from console. */
static struct { static struct {
spinlock_t lock; spinlock_t lock;
...@@ -555,8 +560,7 @@ static void test_init_on_free(struct kunit *test) ...@@ -555,8 +560,7 @@ static void test_init_on_free(struct kunit *test)
}; };
int i; int i;
if (!IS_ENABLED(CONFIG_INIT_ON_FREE_DEFAULT_ON)) KFENCE_TEST_REQUIRES(test, IS_ENABLED(CONFIG_INIT_ON_FREE_DEFAULT_ON));
return;
/* Assume it hasn't been disabled on command line. */ /* Assume it hasn't been disabled on command line. */
setup_test_cache(test, size, 0, NULL); setup_test_cache(test, size, 0, NULL);
...@@ -603,10 +607,8 @@ static void test_gfpzero(struct kunit *test) ...@@ -603,10 +607,8 @@ static void test_gfpzero(struct kunit *test)
char *buf1, *buf2; char *buf1, *buf2;
int i; int i;
if (CONFIG_KFENCE_SAMPLE_INTERVAL > 100) { /* Skip if we think it'd take too long. */
kunit_warn(test, "skipping ... would take too long\n"); KFENCE_TEST_REQUIRES(test, CONFIG_KFENCE_SAMPLE_INTERVAL <= 100);
return;
}
setup_test_cache(test, size, 0, NULL); setup_test_cache(test, size, 0, NULL);
buf1 = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY); buf1 = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment