kunit: memcpy: Mark tests as slow using test attributes
authorRae Moar <rmoar@google.com>
Tue, 25 Jul 2023 21:25:17 +0000 (21:25 +0000)
committerShuah Khan <skhan@linuxfoundation.org>
Wed, 26 Jul 2023 19:29:28 +0000 (13:29 -0600)
Mark slow memcpy KUnit tests using test attributes.

Tests marked as slow are as follows: memcpy_large_test, memmove_test,
memmove_large_test, and memmove_overlap_test. These tests were the slowest
of the memcpy tests and relatively slower to most other KUnit tests. Most
of these tests are already skipped when CONFIG_MEMCPY_SLOW_KUNIT_TEST is
not enabled.

These tests can now be filtered using the KUnit test attribute filtering
feature. Example: --filter "speed>slow". This will run only the tests that
have speeds faster than slow. The slow attribute will also be outputted in
KTAP.

Note: This patch is intended to replace the use of
CONFIG_MEMCPY_SLOW_KUNIT_TEST and to potentially deprecate this feature.
This patch does not remove the config option but does add a note to the
config definition commenting on this future shift.

Reviewed-by: David Gow <davidgow@google.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Rae Moar <rmoar@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
lib/Kconfig.debug
lib/memcpy_kunit.c

index 550cb96..1b3894e 100644 (file)
@@ -2701,6 +2701,9 @@ config MEMCPY_SLOW_KUNIT_TEST
          and bit ranges. These can be very slow, so they are split out
          as a separate config, in case they need to be disabled.
 
+         Note this config option will be replaced by the use of KUnit test
+         attributes.
+
 config IS_SIGNED_TYPE_KUNIT_TEST
        tristate "Test is_signed_type() macro" if !KUNIT_ALL_TESTS
        depends on KUNIT
index 887926f..440aee7 100644 (file)
@@ -551,10 +551,10 @@ static void strtomem_test(struct kunit *test)
 static struct kunit_case memcpy_test_cases[] = {
        KUNIT_CASE(memset_test),
        KUNIT_CASE(memcpy_test),
-       KUNIT_CASE(memcpy_large_test),
-       KUNIT_CASE(memmove_test),
-       KUNIT_CASE(memmove_large_test),
-       KUNIT_CASE(memmove_overlap_test),
+       KUNIT_CASE_SLOW(memcpy_large_test),
+       KUNIT_CASE_SLOW(memmove_test),
+       KUNIT_CASE_SLOW(memmove_large_test),
+       KUNIT_CASE_SLOW(memmove_overlap_test),
        KUNIT_CASE(strtomem_test),
        {}
 };