Skip to content

Commit 4acf1de

Browse files
committed
kunit: memcpy: Split slow memcpy tests into MEMCPY_SLOW_KUNIT_TEST
Since the long memcpy tests may stall a system for tens of seconds in virtualized architecture environments, split those tests off under CONFIG_MEMCPY_SLOW_KUNIT_TEST so they can be separately disabled. Reported-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] Reviewed-by: Nick Desaulniers <[email protected]> Reviewed-and-tested-by: Guenter Roeck <[email protected]> Reviewed-by: David Gow <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: [email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 42633ed commit 4acf1de

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/Kconfig.debug

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,6 +2566,15 @@ config MEMCPY_KUNIT_TEST
25662566

25672567
If unsure, say N.
25682568

2569+
config MEMCPY_SLOW_KUNIT_TEST
2570+
bool "Include exhaustive memcpy tests"
2571+
depends on MEMCPY_KUNIT_TEST
2572+
default y
2573+
help
2574+
Some memcpy tests are quite exhaustive in checking for overlaps
2575+
and bit ranges. These can be very slow, so they are split out
2576+
as a separate config, in case they need to be disabled.
2577+
25692578
config IS_SIGNED_TYPE_KUNIT_TEST
25702579
tristate "Test is_signed_type() macro" if !KUNIT_ALL_TESTS
25712580
depends on KUNIT

lib/memcpy_kunit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ static void set_random_nonzero(struct kunit *test, u8 *byte)
309309

310310
static void init_large(struct kunit *test)
311311
{
312+
if (!IS_ENABLED(CONFIG_MEMCPY_SLOW_KUNIT_TEST))
313+
kunit_skip(test, "Slow test skipped. Enable with CONFIG_MEMCPY_SLOW_KUNIT_TEST=y");
312314

313315
/* Get many bit patterns. */
314316
get_random_bytes(large_src, ARRAY_SIZE(large_src));

0 commit comments

Comments
 (0)