lib/glob: convert selftest to KUnit
Subsystems (3)
PATCH 1/1 lib/glob: convert selftest to KUnit
This patch converts the existing glob selftest (lib/globtest.c) to use the KUnit framework (lib/glob_kunit.c).
The new test:
- Migrates all 64 test cases from the original test to the KUnit suite.
- Removes the custom 'verbose' module parameter as KUnit handles logging.
- Updates Kconfig.debug and Makefile to support the new KUnit test.
- Updates Kconfig and Makefile to remove the original selftest.
- Updates GLOB_SELFTEST to GLOB_KUNIT_TEST for arch/m68k/configs.
This commit is verified by ./tools/testing/kunit/kunit.py run with the .kunit/.kunitconfig:
``` CONFIG_KUNIT=y CONFIG_GLOB_KUNIT_TEST=y ```
--- arch/m68k/configs/amiga_defconfig | 2 +- arch/m68k/configs/apollo_defconfig | 2 +- arch/m68k/configs/atari_defconfig | 2 +- arch/m68k/configs/bvme6000_defconfig | 2 +- arch/m68k/configs/hp300_defconfig | 2 +- arch/m68k/configs/mac_defconfig | 2 +- arch/m68k/configs/multi_defconfig | 2 +- arch/m68k/configs/mvme147_defconfig | 2 +- arch/m68k/configs/mvme16x_defconfig | 2 +- arch/m68k/configs/q40_defconfig | 2 +- arch/m68k/configs/sun3_defconfig | 2 +- arch/m68k/configs/sun3x_defconfig | 2 +- lib/Kconfig | 13 --- lib/Kconfig.debug | 13 +++ lib/Makefile | 2 +- lib/glob_kunit.c | 122 +++++++++++++++++++ lib/globtest.c | 167 --------------------------- 17 files changed, 148 insertions(+), 193 deletions(-) create mode 100644 lib/glob_kunit.c delete mode 100644 lib/globtest.c
arch/m68k/configs/amiga_defconfig +1 -1
@@ -600,7 +600,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
arch/m68k/configs/apollo_defconfig +1 -1
@@ -557,7 +557,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
arch/m68k/configs/atari_defconfig +1 -1
@@ -577,7 +577,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
arch/m68k/configs/bvme6000_defconfig +1 -1
@@ -549,7 +549,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
arch/m68k/configs/hp300_defconfig +1 -1
@@ -559,7 +559,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
arch/m68k/configs/mac_defconfig +1 -1
@@ -576,7 +576,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
arch/m68k/configs/multi_defconfig +1 -1
@@ -663,7 +663,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
arch/m68k/configs/mvme147_defconfig +1 -1
@@ -549,7 +549,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
arch/m68k/configs/mvme16x_defconfig +1 -1
@@ -550,7 +550,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
arch/m68k/configs/q40_defconfig +1 -1
@@ -566,7 +566,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
arch/m68k/configs/sun3_defconfig +1 -1
@@ -547,7 +547,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
arch/m68k/configs/sun3x_defconfig +1 -1
@@ -547,7 +547,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
lib/Kconfig +0 -13
@@ -430,19 +430,6 @@ config GLOB are compiling an out-of tree driver which tells you that it depends on this. -config GLOB_SELFTEST - tristate "glob self-test on init" - depends on GLOB - help - This option enables a simple self-test of the glob_match - function on startup. It is primarily useful for people - working on the code to ensure they haven't introduced any - regressions. - - It only adds a little bit of code and slows kernel boot (or - module load) by a small amount, so you're welcome to play with - it, but you probably don't need it. - # # Netlink attribute parsing support is select'ed if needed #
lib/Kconfig.debug +13 -0
@@ -3354,6 +3354,19 @@ config PRIME_NUMBERS_KUNIT_TEST If unsure, say N +config GLOB_KUNIT_TEST + tristate "Glob matching test" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + select GLOB + help + Enable this option to test the glob functions at runtime. + + This test suite verifies the correctness of glob_match() across various + scenarios, including edge cases. + + If unsure, say N + endif # RUNTIME_TESTING_MENU config ARCH_USE_MEMTEST
lib/Makefile +1 -1
@@ -226,7 +226,7 @@ obj-$(CONFIG_CLOSURES) += closure.o obj-$(CONFIG_DQL) += dynamic_queue_limits.o obj-$(CONFIG_GLOB) += glob.o -obj-$(CONFIG_GLOB_SELFTEST) += globtest.o +obj-$(CONFIG_GLOB_KUNIT_TEST) += glob_kunit.o obj-$(CONFIG_DIMLIB) += dim/ obj-$(CONFIG_SIGNATURE) += digsig.o
lib/glob_kunit.c new file +122 -0
122 lines not on this page · raw message
lib/globtest.c deleted +0 -167
167 lines not on this page · raw message
Signature · 1 line
2.52.0.351.gbe84eed79e-goog
Geert Uytterhoeven
maintainerHi Kir,
Quoted 14 lines · Kir Chou
This patch converts the existing glob selftest (
lib/globtest.c) to use the KUnit framework (lib/glob_kunit.c).The new test:
- Migrates all 64 test cases from the original test to the KUnit suite.
- Removes the custom 'verbose' module parameter as KUnit handles logging.
- UpdatesKconfig.debugandMakefileto support the new KUnit test.
- UpdatesKconfigandMakefileto remove the original selftest.
- UpdatesGLOB_SELFTESTtoGLOB_KUNIT_TESTforarch/m68k/configs.This commit is verified by
./tools/testing/kunit/kunit.py runwith the .kunit/.kunitconfig:
Quoted 6 lines
``` CONFIG_KUNIT=y CONFIG_GLOB_KUNIT_TEST=y ```Signed-off-by Kir Chou <[email protected]>
Thanks for your patch!
arch/m68k/configs/amiga_defconfig CONFIG_CRYPTO_USER_API_AEAD=m · line 603
Quoted 8 lines
arch/m68k/configs/amiga_defconfig +1
-1@@ -600,7 +600,7 @@ CONFIG_CRYPTO_USER_API_AEAD=m CONFIG_PRIME_NUMBERS=m CONFIG_CRC_BENCHMARK=y CONFIG_XZ_DEC_TEST=m -CONFIG_GLOB_SELFTEST=m +CONFIG_GLOB_KUNIT_TEST=m
This is not the correct location for CONFIG_GLOB_KUNIT_TEST. Please run "make savedefconfig" and inspect the resulting defconfig file.
However, given GLOB_KUNIT_TEST defaults to KUNIT_ALL_TESTS, which is set to "m" in the m68k defconfigs, there is no need to add "CONFIG_GLOB_KUNIT_TEST=m" at all.
arch/m68k/configs/amiga_defconfig CONFIG_CRYPTO_USER_API_AEAD=m · line 606
Quoted 3 lines
arch/m68k/configs/amiga_defconfig +0
-0# CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_TEST_LOCKUP=m
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds