lib/random32: convert selftest to KUnit
Subsystems (4)
PATCH v2 1/1 lib/random32: convert selftest to KUnit
This patch converts the existing prandom selftest (lib/random32.c) to use the KUnit framework (lib/tests/random32_kunit.c). Unlike typical KUnit tests, this file is directly #included into lib/random32.c.
The new test:
- Removes the legacy CONFIG_RANDOM32_SELFTEST from lib/random32.c.
- Adds CONFIG_PRANDOM_KUNIT_TEST (defaulting to KUNIT_ALL_TESTS).
- Moves the test logic to lib/tests/random32_kunit.c.
v2:
- Removes the legacy CONFIG_RANDOM32_SELFTEST from lib/Kconfig.
- Add const to arrays in lib/tests/random32_kunit.c.
This commit is verified by ./tools/testing/kunit/kunit.py run with the .kunit/.kunitconfig:
``` CONFIG_KUNIT=y CONFIG_PRANDOM_KUNIT_TEST=y ```
Signed-off-by Kir Chou <[email protected]>
--- lib/Kconfig | 6 -- lib/Kconfig.debug | 9 ++ lib/random32.c | 173 +----------------------------------- lib/tests/random32_kunit.c | 174 +++++++++++++++++++++++++++++++++++++ 4 files changed, 185 insertions(+), 177 deletions(-) create mode 100644 lib/tests/random32_kunit.c
lib/Kconfig +0 -6
@@ -156,12 +156,6 @@ config AUDIT_COMPAT_GENERIC depends on AUDIT_GENERIC && AUDIT_ARCH_COMPAT_GENERIC && COMPAT default y -config RANDOM32_SELFTEST - bool "PRNG perform self test on init" - help - This option enables the 32 bit PRNG library functions to perform a - self test on initialization. - # # compression support is select'ed if needed #
lib/Kconfig.debug +9 -0
@@ -3354,6 +3354,15 @@ config PRIME_NUMBERS_KUNIT_TEST If unsure, say N +config PRANDOM_KUNIT_TEST + tristate "KUnit test for prandom" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + Enable this option to test the prandom functions at runtime. + + If unsure, say N + endif # RUNTIME_TESTING_MENU config ARCH_USE_MEMTEST
lib/random32.c +2 -171
177 lines not on this page · raw message
lib/tests/random32_kunit.c new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
2.52.0