lib/tests: convert test_memcat_p module to KUnit
Subsystems (2)
PATCH 1/1 lib/tests: convert test_memcat_p module to KUnit
Move lib/test_memcat_p.c to lib/tests/memcat_p_kunit.c and convert it to use KUnit.
This change switches the ad-hoc test code to standard KUnit test cases. The test data remains the same, but the verification logic is updated to use KUNIT_EXPECT_* macros. All allocations are made test managed, so the manual error unwinding paths and the empty module exit hook are no longer needed, and a failure now reports which element mismatched instead of a single pr_err() message.
CONFIG_TEST_MEMCAT_P keeps its name so that the defconfigs enabling it stay valid; it now depends on KUNIT and defaults to KUNIT_ALL_TESTS, like the other lib KUnit tests. Those defconfigs already select KUNIT and KUNIT_ALL_TESTS, so they keep turning the test on unchanged.
--- lib/Kconfig.debug | 4 +- lib/Makefile | 1 - lib/test_memcat_p.c | 116 ------------------------------------- lib/tests/Makefile | 1 + lib/tests/memcat_p_kunit.c | 83 ++++++++++++++++++++++++++ 5 files changed, 87 insertions(+), 118 deletions(-) delete mode 100644 lib/test_memcat_p.c create mode 100644 lib/tests/memcat_p_kunit.c
lib/Kconfig.debug +3 -1
@@ -3314,7 +3314,9 @@ config TEST_DEBUG_VIRTUAL If unsure, say N. config TEST_MEMCAT_P - tristate "Test memcat_p() helper function" + tristate "KUnit test for memcat_p() helper function" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS help Test the memcat_p() helper for correctly merging two pointer arrays together.
lib/Makefile +0 -1
@@ -97,7 +97,6 @@ obj-$(CONFIG_TEST_MAPLE_TREE) += test_maple_tree.o obj-$(CONFIG_TEST_PARMAN) += test_parman.o obj-$(CONFIG_TEST_KMOD) += test_kmod.o obj-$(CONFIG_TEST_DEBUG_VIRTUAL) += test_debug_virtual.o -obj-$(CONFIG_TEST_MEMCAT_P) += test_memcat_p.o obj-$(CONFIG_TEST_OBJAGG) += test_objagg.o obj-$(CONFIG_TEST_MEMINIT) += test_meminit.o obj-$(CONFIG_TEST_LOCKUP) += test_lockup.o
lib/test_memcat_p.c deleted +0 -116
116 lines not on this page · raw message
lib/tests/Makefile +1 -0
@@ -38,6 +38,7 @@ CFLAGS_longest_symbol_kunit.o += $(call cc-disable-warning, missing-prototypes) obj-$(CONFIG_LONGEST_SYM_KUNIT_TEST) += longest_symbol_kunit.o obj-$(CONFIG_MEMCPY_KUNIT_TEST) += memcpy_kunit.o +obj-$(CONFIG_TEST_MEMCAT_P) += memcat_p_kunit.o obj-$(CONFIG_MIN_HEAP_KUNIT_TEST) += min_heap_kunit.o CFLAGS_overflow_kunit.o = $(call cc-disable-warning, tautological-constant-out-of-range-compare) obj-$(CONFIG_OVERFLOW_KUNIT_TEST) += overflow_kunit.o
lib/tests/memcat_p_kunit.c new file +83 -0
83 lines not on this page · raw message
base-commit: 4056b3c9d3c92ea45955641dbafeb9b960e146ef
Signature · 1 line
2.25.1
Andrew Morton
maintainerQuoted 10 lines · On Wed, 14 Oct 2026 11:41:43 +0800 Wang Yibo <[email protected]> wrote:
Move
lib/test_memcat_p.ctolib/tests/memcat_p_kunit.cand convert it to use KUnit.This change switches the ad-hoc test code to standard KUnit test cases. The test data remains the same, but the verification logic is updated to use KUNIT_EXPECT_* macros. All allocations are made test managed, so the manual error unwinding paths and the empty module exit hook are no longer needed, and a failure now reports which element mismatched instead of a single
pr_err()message.
Quoted 4 lines
CONFIG_TEST_MEMCAT_Pkeeps its name so that the defconfigs enabling it stay valid; it now depends on KUNIT and defaults toKUNIT_ALL_TESTS, like the other lib KUnit tests. Those defconfigs already select KUNIT andKUNIT_ALL_TESTS, so they keep turning the test on unchanged.
Thanks. AI review asked a couple of questions:
https://sashiko.dev/#/patchset/[email protected]