KUnit test moves / renames
Subsystems (11)
v2 cover KUnit test moves / renames
As discussed in [1], the KUnit test naming scheme has changed to avoid name conflicts (and tab-completion woes) with the files being tested. These renames and moves have caused a nasty set of merge conflicts, so this series collates and rebases them all on top of v6.13-rc1, to be applied minimising any further conflicts. [2,3]
Thanks to everyone whose patches appear here, and everyone who reviewed on the original series. I hope I didn't break them too much during the rebase!
Bruno Sobreira França (1):
lib/math: Add int_log test suite
Diego Vieira (1):
lib/tests/kfifo_kunit.c: add tests for the kfifo structure
Gabriela Bittencourt (2):
unicode: kunit: refactor selftest to kunit tests
unicode: kunit: change tests filename and path
Kees Cook (1):
lib: Move KUnit tests into tests/ subdirectory
Luis Felipe Hernandez (1):
lib: math: Move kunit tests into tests/ subdir
MAINTAINERS | 19 +-
fs/unicode/Kconfig | 5 +-
fs/unicode/Makefile | 2 +-
fs/unicode/tests/.kunitconfig | 3 +
.../{utf8-selftest.c => tests/utf8_kunit.c} | 149 ++++++------
fs/unicode/utf8-norm.c | 2 +-
lib/Kconfig.debug | 27 ++-
lib/Makefile | 39 +--
lib/math/Makefile | 4 +-
lib/math/tests/Makefile | 4 +-
lib/math/tests/int_log_kunit.c | 75 ++++++
.../rational_kunit.c} | 0
lib/tests/Makefile | 41 ++++
lib/{ => tests}/bitfield_kunit.c | 0
lib/{ => tests}/checksum_kunit.c | 0
lib/{ => tests}/cmdline_kunit.c | 0
lib/{ => tests}/cpumask_kunit.c | 0
lib/{ => tests}/crc16_kunit.c | 0
lib/{ => tests}/fortify_kunit.c | 0
lib/{ => tests}/hashtable_test.c | 0
lib/{ => tests}/is_signed_type_kunit.c | 0
lib/tests/kfifo_kunit.c | 224 ++++++++++++++++++
lib/{ => tests}/kunit_iov_iter.c | 0
lib/{ => tests}/list-test.c | 0
lib/{ => tests}/memcpy_kunit.c | 0
lib/{ => tests}/overflow_kunit.c | 0
lib/{ => tests}/siphash_kunit.c | 0
lib/{ => tests}/slub_kunit.c | 0
lib/{ => tests}/stackinit_kunit.c | 0
lib/{ => tests}/string_helpers_kunit.c | 0
lib/{ => tests}/string_kunit.c | 0
lib/{ => tests}/test_bits.c | 0
lib/{ => tests}/test_fprobe.c | 0
lib/{ => tests}/test_hash.c | 0
lib/{ => tests}/test_kprobes.c | 0
lib/{ => tests}/test_linear_ranges.c | 0
lib/{ => tests}/test_list_sort.c | 0
lib/{ => tests}/test_sort.c | 0
lib/{ => tests}/usercopy_kunit.c | 0
lib/{ => tests}/util_macros_kunit.c | 0
40 files changed, 459 insertions(+), 135 deletions(-)
create mode 100644 fs/unicode/tests/.kunitconfig
rename fs/unicode/{utf8-selftest.c => tests/utf8_kunit.c} (64%)
create mode 100644 lib/math/tests/int_log_kunit.c
rename lib/math/{rational-test.c => tests/rational_kunit.c} (100%)
rename lib/{ => tests}/bitfield_kunit.c (100%)
rename lib/{ => tests}/checksum_kunit.c (100%)
rename lib/{ => tests}/cmdline_kunit.c (100%)
rename lib/{ => tests}/cpumask_kunit.c (100%)
rename lib/{ => tests}/crc16_kunit.c (100%)
rename lib/{ => tests}/fortify_kunit.c (100%)
rename lib/{ => tests}/hashtable_test.c (100%)
rename lib/{ => tests}/is_signed_type_kunit.c (100%)
create mode 100644 lib/tests/kfifo_kunit.c
rename lib/{ => tests}/kunit_iov_iter.c (100%)
rename lib/{ => tests}/list-test.c (100%)
rename lib/{ => tests}/memcpy_kunit.c (100%)
rename lib/{ => tests}/overflow_kunit.c (100%)
rename lib/{ => tests}/siphash_kunit.c (100%)
rename lib/{ => tests}/slub_kunit.c (100%)
rename lib/{ => tests}/stackinit_kunit.c (100%)
rename lib/{ => tests}/string_helpers_kunit.c (100%)
rename lib/{ => tests}/string_kunit.c (100%)
rename lib/{ => tests}/test_bits.c (100%)
rename lib/{ => tests}/test_fprobe.c (100%)
rename lib/{ => tests}/test_hash.c (100%)
rename lib/{ => tests}/test_kprobes.c (100%)
rename lib/{ => tests}/test_linear_ranges.c (100%)
rename lib/{ => tests}/test_list_sort.c (100%)
rename lib/{ => tests}/test_sort.c (100%)
rename lib/{ => tests}/usercopy_kunit.c (100%)
rename lib/{ => tests}/util_macros_kunit.c (100%)Signature · 1 line
2.47.0.338.g60cca15819-goog
PATCH v2 1/6 lib: math: Move kunit tests into tests/ subdir
From: Luis Felipe Hernandez <[email protected]>
This patch is a follow-up task from a discussion stemming from point 3 in a recent patch introducing the int_pow kunit test [1] and documentation regarding kunit test style and nomenclature [2].
Colocate all kunit test suites in lib/math/tests/ and follow recommended naming convention for files <suite>_kunit.c and kconfig entries CONFIG_<name>_KUNIT_TEST.
---
lib/Kconfig.debug | 2 +-
lib/math/Makefile | 4 ++--
lib/math/tests/Makefile | 3 ++-
lib/math/{rational-test.c => tests/rational_kunit.c} | 0
4 files changed, 5 insertions(+), 4 deletions(-)
rename lib/math/{rational-test.c => tests/rational_kunit.c} (100%)lib/Kconfig.debug +1 -1
@@ -3145,7 +3145,7 @@ config TEST_OBJPOOL If unsure, say N. -config INT_POW_TEST +config INT_POW_KUNIT_TEST tristate "Integer exponentiation (int_pow) test" if !KUNIT_ALL_TESTS depends on KUNIT default KUNIT_ALL_TESTS
lib/math/Makefile +2 -2
@@ -5,7 +5,7 @@ obj-$(CONFIG_CORDIC) += cordic.o obj-$(CONFIG_PRIME_NUMBERS) += prime_numbers.o obj-$(CONFIG_RATIONAL) += rational.o -obj-$(CONFIG_INT_POW_TEST) += tests/int_pow_kunit.o obj-$(CONFIG_TEST_DIV64) += test_div64.o obj-$(CONFIG_TEST_MULDIV64) += test_mul_u64_u64_div_u64.o -obj-$(CONFIG_RATIONAL_KUNIT_TEST) += rational-test.o + +obj-y += tests/
lib/math/tests/Makefile +2 -1
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_INT_POW_TEST) += int_pow_kunit.o +obj-$(CONFIG_INT_POW_KUNIT_TEST) += int_pow_kunit.o +obj-$(CONFIG_RATIONAL_KUNIT_TEST) += rational_kunit.o
lib/math/tests/rational_kunit.c renamed from lib/math/rational-test.c +0 -0
Signature · 1 line
2.47.0.338.g60cca15819-goog
PATCH v2 2/6 lib/math: Add int_log test suite
In reply to David GowFrom: Bruno Sobreira França <[email protected]>
This commit introduces KUnit tests for the intlog2 and intlog10 functions, which compute logarithms in base 2 and base 10, respectively. The tests cover a range of inputs to ensure the correctness of these functions across common and edge cases.
--- lib/Kconfig.debug | 11 +++++ lib/math/tests/Makefile | 1 + lib/math/tests/int_log_kunit.c | 75 ++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 lib/math/tests/int_log_kunit.c
lib/Kconfig.debug +11 -0
@@ -3161,6 +3161,17 @@ config INT_POW_KUNIT_TEST If unsure, say N +config INT_LOG_KUNIT_TEST + tristate "Integer log (int_log) test" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This option enables the KUnit test suite for the int_log library, which + provides two functions to compute the integer logarithm in base 2 and + base 10, called respectively as intlog2 and intlog10. + + If unsure, say N + endif # RUNTIME_TESTING_MENU config ARCH_USE_MEMTEST
lib/math/tests/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_INT_POW_KUNIT_TEST) += int_pow_kunit.o +obj-$(CONFIG_INT_LOG_KUNIT_TEST) += int_log_kunit.o obj-$(CONFIG_RATIONAL_KUNIT_TEST) += rational_kunit.o
lib/math/tests/int_log_kunit.c new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
2.47.0.338.g60cca15819-goog
PATCH v2 3/6 lib: Move KUnit tests into tests/ subdirectory
In reply to David GowFrom: Kees Cook <[email protected]>
Following from the recent KUnit file naming discussion[1], move all KUnit tests in lib/ into lib/tests/.
---
MAINTAINERS | 19 ++++++------
lib/Makefile | 39 +------------------------
lib/tests/Makefile | 40 ++++++++++++++++++++++++++
lib/{ => tests}/bitfield_kunit.c | 0
lib/{ => tests}/checksum_kunit.c | 0
lib/{ => tests}/cmdline_kunit.c | 0
lib/{ => tests}/cpumask_kunit.c | 0
lib/{ => tests}/crc16_kunit.c | 0
lib/{ => tests}/fortify_kunit.c | 0
lib/{ => tests}/hashtable_test.c | 0
lib/{ => tests}/is_signed_type_kunit.c | 0
lib/{ => tests}/kunit_iov_iter.c | 0
lib/{ => tests}/list-test.c | 0
lib/{ => tests}/memcpy_kunit.c | 0
lib/{ => tests}/overflow_kunit.c | 0
lib/{ => tests}/siphash_kunit.c | 0
lib/{ => tests}/slub_kunit.c | 0
lib/{ => tests}/stackinit_kunit.c | 0
lib/{ => tests}/string_helpers_kunit.c | 0
lib/{ => tests}/string_kunit.c | 0
lib/{ => tests}/test_bits.c | 0
lib/{ => tests}/test_fprobe.c | 0
lib/{ => tests}/test_hash.c | 0
lib/{ => tests}/test_kprobes.c | 0
lib/{ => tests}/test_linear_ranges.c | 0
lib/{ => tests}/test_list_sort.c | 0
lib/{ => tests}/test_sort.c | 0
lib/{ => tests}/usercopy_kunit.c | 0
lib/{ => tests}/util_macros_kunit.c | 0
29 files changed, 51 insertions(+), 47 deletions(-)
rename lib/{ => tests}/bitfield_kunit.c (100%)
rename lib/{ => tests}/checksum_kunit.c (100%)
rename lib/{ => tests}/cmdline_kunit.c (100%)
rename lib/{ => tests}/cpumask_kunit.c (100%)
rename lib/{ => tests}/crc16_kunit.c (100%)
rename lib/{ => tests}/fortify_kunit.c (100%)
rename lib/{ => tests}/hashtable_test.c (100%)
rename lib/{ => tests}/is_signed_type_kunit.c (100%)
rename lib/{ => tests}/kunit_iov_iter.c (100%)
rename lib/{ => tests}/list-test.c (100%)
rename lib/{ => tests}/memcpy_kunit.c (100%)
rename lib/{ => tests}/overflow_kunit.c (100%)
rename lib/{ => tests}/siphash_kunit.c (100%)
rename lib/{ => tests}/slub_kunit.c (100%)
rename lib/{ => tests}/stackinit_kunit.c (100%)
rename lib/{ => tests}/string_helpers_kunit.c (100%)
rename lib/{ => tests}/string_kunit.c (100%)
rename lib/{ => tests}/test_bits.c (100%)
rename lib/{ => tests}/test_fprobe.c (100%)
rename lib/{ => tests}/test_hash.c (100%)
rename lib/{ => tests}/test_kprobes.c (100%)
rename lib/{ => tests}/test_linear_ranges.c (100%)
rename lib/{ => tests}/test_list_sort.c (100%)
rename lib/{ => tests}/test_sort.c (100%)
rename lib/{ => tests}/usercopy_kunit.c (100%)
rename lib/{ => tests}/util_macros_kunit.c (100%)MAINTAINERS +10 -9
@@ -3966,10 +3966,10 @@ F: include/vdso/bits.h F: lib/bitmap-str.c F: lib/bitmap.c F: lib/cpumask.c -F: lib/cpumask_kunit.c F: lib/find_bit.c F: lib/find_bit_benchmark.c F: lib/test_bitmap.c +F: lib/tests/cpumask_kunit.c F: tools/include/linux/bitfield.h F: tools/include/linux/bitmap.h F: tools/include/linux/bits.h
@@ -8972,9 +8972,10 @@ L: [email protected] S: Supported T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening F: include/linux/fortify-string.h -F: lib/fortify_kunit.c -F: lib/memcpy_kunit.c F: lib/test_fortify/* +F: lib/tests/fortify_kunit.c +F: lib/tests/memcpy_kunit.c +F: scripts/test_fortify.sh K: \bunsafe_memcpy\b K: \b__NO_FORTIFY\b
@@ -9655,9 +9656,9 @@ F: include/linux/string.h F: include/linux/string_choices.h F: include/linux/string_helpers.h F: lib/string.c -F: lib/string_kunit.c F: lib/string_helpers.c -F: lib/string_helpers_kunit.c +F: lib/tests/string_helpers_kunit.c +F: lib/tests/string_kunit.c F: scripts/coccinelle/api/string_choices.cocci GENERIC UIO DRIVER FOR PCI DEVICES
@@ -12868,7 +12869,7 @@ F: Documentation/trace/kprobes.rst F: include/asm-generic/kprobes.h F: include/linux/kprobes.h F: kernel/kprobes.c -F: lib/test_kprobes.c +F: lib/tests/test_kprobes.c F: samples/kprobes KS0108 LCD CONTROLLER DRIVER
@@ -13198,7 +13199,7 @@ M: Mark Brown <[email protected]> R: Matti Vaittinen <[email protected]> F: include/linux/linear_range.h F: lib/linear_ranges.c -F: lib/test_linear_ranges.c +F: lib/tests/test_linear_ranges.c LINUX FOR POWER MACINTOSH L: [email protected]
@@ -13326,7 +13327,7 @@ M: David Gow <[email protected]> L: [email protected] L: [email protected] S: Maintained -F: lib/list-test.c +F: lib/tests/list-test.c LITEX PLATFORM M: Karol Gugala <[email protected]>
@@ -21490,7 +21491,7 @@ M: Jason A. Donenfeld <[email protected]> S: Maintained F: include/linux/siphash.h F: lib/siphash.c -F: lib/siphash_kunit.c +F: lib/tests/siphash_kunit.c SIS 190 ETHERNET DRIVER M: Francois Romieu <[email protected]>
lib/Makefile +1 -38
@@ -52,9 +52,7 @@ obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \ percpu-refcount.o rhashtable.o base64.o \ once.o refcount.o rcuref.o usercopy.o errseq.o bucket_locks.o \ generic-radix-tree.o bitmap-str.o -obj-$(CONFIG_STRING_KUNIT_TEST) += string_kunit.o obj-y += string_helpers.o -obj-$(CONFIG_STRING_HELPERS_KUNIT_TEST) += string_helpers_kunit.o obj-y += hexdump.o obj-$(CONFIG_TEST_HEXDUMP) += test_hexdump.o obj-y += kstrtox.o
@@ -65,22 +63,17 @@ obj-$(CONFIG_TEST_DHRY) += test_dhry.o obj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o obj-$(CONFIG_TEST_BITOPS) += test_bitops.o CFLAGS_test_bitops.o += -Werror -obj-$(CONFIG_CPUMASK_KUNIT_TEST) += cpumask_kunit.o obj-$(CONFIG_TEST_SYSCTL) += test_sysctl.o -obj-$(CONFIG_TEST_IOV_ITER) += kunit_iov_iter.o -obj-$(CONFIG_HASH_KUNIT_TEST) += test_hash.o obj-$(CONFIG_TEST_IDA) += test_ida.o obj-$(CONFIG_TEST_UBSAN) += test_ubsan.o CFLAGS_test_ubsan.o += $(call cc-disable-warning, vla) CFLAGS_test_ubsan.o += $(call cc-disable-warning, unused-but-set-variable) UBSAN_SANITIZE_test_ubsan.o := y obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o -obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o obj-$(CONFIG_TEST_MIN_HEAP) += test_min_heap.o obj-$(CONFIG_TEST_LKM) += test_module.o obj-$(CONFIG_TEST_VMALLOC) += test_vmalloc.o obj-$(CONFIG_TEST_RHASHTABLE) += test_rhashtable.o -obj-$(CONFIG_TEST_SORT) += test_sort.o obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o
@@ -98,7 +91,6 @@ obj-$(CONFIG_TEST_XARRAY) += test_xarray.o 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_RUNTIME) += tests/ 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
@@ -107,10 +99,7 @@ obj-$(CONFIG_TEST_MEMINIT) += test_meminit.o obj-$(CONFIG_TEST_LOCKUP) += test_lockup.o obj-$(CONFIG_TEST_HMM) += test_hmm.o obj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o -obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o obj-$(CONFIG_TEST_REF_TRACKER) += test_ref_tracker.o -CFLAGS_test_fprobe.o += $(CC_FLAGS_FTRACE) -obj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o obj-$(CONFIG_TEST_OBJPOOL) += test_objpool.o obj-$(CONFIG_TEST_FPU) += test_fpu.o
@@ -132,7 +121,7 @@ endif obj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any) -obj-y += math/ crypto/ +obj-y += math/ crypto/ tests/ obj-$(CONFIG_GENERIC_IOMAP) += iomap.o obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
@@ -370,32 +359,6 @@ obj-$(CONFIG_OBJAGG) += objagg.o # pldmfw library obj-$(CONFIG_PLDMFW) += pldmfw/ -# KUnit tests -CFLAGS_bitfield_kunit.o := $(DISABLE_STRUCTLEAK_PLUGIN) -obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o -obj-$(CONFIG_CHECKSUM_KUNIT) += checksum_kunit.o -obj-$(CONFIG_UTIL_MACROS_KUNIT) += util_macros_kunit.o -obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o -obj-$(CONFIG_HASHTABLE_KUNIT_TEST) += hashtable_test.o -obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o -obj-$(CONFIG_BITS_TEST) += test_bits.o -obj-$(CONFIG_CMDLINE_KUNIT_TEST) += cmdline_kunit.o -obj-$(CONFIG_SLUB_KUNIT_TEST) += slub_kunit.o -obj-$(CONFIG_MEMCPY_KUNIT_TEST) += memcpy_kunit.o -obj-$(CONFIG_IS_SIGNED_TYPE_KUNIT_TEST) += is_signed_type_kunit.o -CFLAGS_overflow_kunit.o = $(call cc-disable-warning, tautological-constant-out-of-range-compare) -obj-$(CONFIG_OVERFLOW_KUNIT_TEST) += overflow_kunit.o -CFLAGS_stackinit_kunit.o += $(call cc-disable-warning, switch-unreachable) -obj-$(CONFIG_STACKINIT_KUNIT_TEST) += stackinit_kunit.o -CFLAGS_fortify_kunit.o += $(call cc-disable-warning, unsequenced) -CFLAGS_fortify_kunit.o += $(call cc-disable-warning, stringop-overread) -CFLAGS_fortify_kunit.o += $(call cc-disable-warning, stringop-truncation) -CFLAGS_fortify_kunit.o += $(DISABLE_STRUCTLEAK_PLUGIN) -obj-$(CONFIG_FORTIFY_KUNIT_TEST) += fortify_kunit.o -obj-$(CONFIG_SIPHASH_KUNIT_TEST) += siphash_kunit.o -obj-$(CONFIG_USERCOPY_KUNIT_TEST) += usercopy_kunit.o -obj-$(CONFIG_CRC16_KUNIT_TEST) += crc16_kunit.o - obj-$(CONFIG_GENERIC_LIB_DEVMEM_IS_ALLOWED) += devmem_is_allowed.o obj-$(CONFIG_FIRMWARE_TABLE) += fw_table.o
lib/tests/Makefile +40 -0
@@ -1 +1,41 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for tests of kernel library functions. + +# KUnit tests +CFLAGS_bitfield_kunit.o := $(DISABLE_STRUCTLEAK_PLUGIN) +obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o +obj-$(CONFIG_BITS_TEST) += test_bits.o +obj-$(CONFIG_CHECKSUM_KUNIT) += checksum_kunit.o +obj-$(CONFIG_CMDLINE_KUNIT_TEST) += cmdline_kunit.o +obj-$(CONFIG_CPUMASK_KUNIT_TEST) += cpumask_kunit.o +obj-$(CONFIG_CRC16_KUNIT_TEST) += crc16_kunit.o +CFLAGS_fortify_kunit.o += $(call cc-disable-warning, unsequenced) +CFLAGS_fortify_kunit.o += $(call cc-disable-warning, stringop-overread) +CFLAGS_fortify_kunit.o += $(call cc-disable-warning, stringop-truncation) +CFLAGS_fortify_kunit.o += $(DISABLE_STRUCTLEAK_PLUGIN) +obj-$(CONFIG_FORTIFY_KUNIT_TEST) += fortify_kunit.o +CFLAGS_test_fprobe.o += $(CC_FLAGS_FTRACE) +obj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o +obj-$(CONFIG_HASHTABLE_KUNIT_TEST) += hashtable_test.o +obj-$(CONFIG_HASH_KUNIT_TEST) += test_hash.o +obj-$(CONFIG_TEST_IOV_ITER) += kunit_iov_iter.o +obj-$(CONFIG_IS_SIGNED_TYPE_KUNIT_TEST) += is_signed_type_kunit.o +obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o +obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o +obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o +obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o +obj-$(CONFIG_MEMCPY_KUNIT_TEST) += memcpy_kunit.o +CFLAGS_overflow_kunit.o = $(call cc-disable-warning, tautological-constant-out-of-range-compare) +obj-$(CONFIG_OVERFLOW_KUNIT_TEST) += overflow_kunit.o +obj-$(CONFIG_SIPHASH_KUNIT_TEST) += siphash_kunit.o +obj-$(CONFIG_SLUB_KUNIT_TEST) += slub_kunit.o +obj-$(CONFIG_TEST_SORT) += test_sort.o +CFLAGS_stackinit_kunit.o += $(call cc-disable-warning, switch-unreachable) +obj-$(CONFIG_STACKINIT_KUNIT_TEST) += stackinit_kunit.o +obj-$(CONFIG_STRING_KUNIT_TEST) += string_kunit.o +obj-$(CONFIG_STRING_HELPERS_KUNIT_TEST) += string_helpers_kunit.o +obj-$(CONFIG_USERCOPY_KUNIT_TEST) += usercopy_kunit.o +obj-$(CONFIG_UTIL_MACROS_KUNIT) += util_macros_kunit.o + obj-$(CONFIG_TEST_RUNTIME_MODULE) += module/
lib/tests/bitfield_kunit.c renamed from lib/bitfield_kunit.c +0 -0
lib/tests/checksum_kunit.c renamed from lib/checksum_kunit.c +0 -0
lib/tests/cmdline_kunit.c renamed from lib/cmdline_kunit.c +0 -0
lib/tests/cpumask_kunit.c renamed from lib/cpumask_kunit.c +0 -0
lib/tests/crc16_kunit.c renamed from lib/crc16_kunit.c +0 -0
lib/tests/fortify_kunit.c renamed from lib/fortify_kunit.c +0 -0
lib/tests/hashtable_test.c renamed from lib/hashtable_test.c +0 -0
lib/tests/is_signed_type_kunit.c renamed from lib/is_signed_type_kunit.c +0 -0
lib/tests/kunit_iov_iter.c renamed from lib/kunit_iov_iter.c +0 -0
lib/tests/list-test.c renamed from lib/list-test.c +0 -0
lib/tests/memcpy_kunit.c renamed from lib/memcpy_kunit.c +0 -0
lib/tests/overflow_kunit.c renamed from lib/overflow_kunit.c +0 -0
lib/tests/siphash_kunit.c renamed from lib/siphash_kunit.c +0 -0
lib/tests/slub_kunit.c renamed from lib/slub_kunit.c +0 -0
lib/tests/stackinit_kunit.c renamed from lib/stackinit_kunit.c +0 -0
lib/tests/string_helpers_kunit.c renamed from lib/string_helpers_kunit.c +0 -0
lib/tests/string_kunit.c renamed from lib/string_kunit.c +0 -0
lib/tests/test_bits.c renamed from lib/test_bits.c +0 -0
lib/tests/test_fprobe.c renamed from lib/test_fprobe.c +0 -0
lib/tests/test_hash.c renamed from lib/test_hash.c +0 -0
lib/tests/test_kprobes.c renamed from lib/test_kprobes.c +0 -0
lib/tests/test_linear_ranges.c renamed from lib/test_linear_ranges.c +0 -0
lib/tests/test_list_sort.c renamed from lib/test_list_sort.c +0 -0
lib/tests/test_sort.c renamed from lib/test_sort.c +0 -0
lib/tests/usercopy_kunit.c renamed from lib/usercopy_kunit.c +0 -0
lib/tests/util_macros_kunit.c renamed from lib/util_macros_kunit.c +0 -0
Signature · 1 line
2.47.0.338.g60cca15819-goog
PATCH v2 4/6 lib/tests/kfifo_kunit.c: add tests for the kfifo structure
In reply to David GowFrom: Diego Vieira <[email protected]>
Add KUnit tests for the kfifo data structure. They test the vast majority of macros defined in the kfifo header (include/linux/kfifo.h).
These are inspired by the existing tests for the doubly linked list in lib/tests/list-test.c (previously at lib/list-test.c) [1].
Note that this patch depends on the patch that moves the KUnit tests on lib/ into lib/tests/ [2].
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/list-test.c?h=v6.11-rc6
[2] https://lore.kernel.org/all/[email protected]/
--- lib/Kconfig.debug | 14 +++ lib/tests/Makefile | 1 + lib/tests/kfifo_kunit.c | 224 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 lib/tests/kfifo_kunit.c
lib/Kconfig.debug +14 -0
@@ -2681,6 +2681,20 @@ config SYSCTL_KUNIT_TEST If unsure, say N. +config KFIFO_KUNIT_TEST + tristate "KUnit Test for the generic kernel FIFO implementation" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This builds the generic FIFO implementation KUnit test suite. + It tests that the API and basic functionality of the kfifo type + and associated macros. + + For more information on KUnit and unit tests in general please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N. + config LIST_KUNIT_TEST tristate "KUnit Test for Kernel Linked-list structures" if !KUNIT_ALL_TESTS depends on KUNIT
lib/tests/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_TEST_IOV_ITER) += kunit_iov_iter.o obj-$(CONFIG_IS_SIGNED_TYPE_KUNIT_TEST) += is_signed_type_kunit.o obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o +obj-$(CONFIG_KFIFO_KUNIT_TEST) += kfifo_kunit.o obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o obj-$(CONFIG_MEMCPY_KUNIT_TEST) += memcpy_kunit.o
lib/tests/kfifo_kunit.c new file +224 -0
224 lines not on this page · raw message
Signature · 1 line
2.47.0.338.g60cca15819-goog
PATCH v2 5/6 unicode: kunit: refactor selftest to kunit tests
In reply to David GowFrom: Gabriela Bittencourt <[email protected]>
Refactoring 'test' functions into kunit tests, to test utf-8 support in unicode subsystem.
This allows the utf8 tests to be run alongside the KUnit test suite using kunit-tool, quickly compiling and running all desired tests as part of the KUnit test suite, instead of compiling the selftest module and loading it.
The refactoring kept the original testing logic intact, while adopting a testing pattern across different kernel modules and leveraging KUnit's benefits.
--- fs/unicode/.kunitconfig | 3 + fs/unicode/Kconfig | 5 +- fs/unicode/Makefile | 2 +- fs/unicode/utf8-norm.c | 2 +- fs/unicode/utf8-selftest.c | 149 +++++++++++++++++-------------------- 5 files changed, 77 insertions(+), 84 deletions(-) create mode 100644 fs/unicode/.kunitconfig
fs/unicode/.kunitconfig new file +3 -0
@@ -0,0 +1,3 @@ +CONFIG_KUNIT=y +CONFIG_UNICODE=y +CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST=y
fs/unicode/Kconfig +3 -2
@@ -10,6 +10,7 @@ config UNICODE be a separate loadable module that gets requested only when a file system actually use it. -config UNICODE_NORMALIZATION_SELFTEST +config UNICODE_NORMALIZATION_KUNIT_TEST tristate "Test UTF-8 normalization support" - depends on UNICODE + depends on UNICODE && KUNIT + default KUNIT_ALL_TESTS
fs/unicode/Makefile +1 -1
@@ -4,7 +4,7 @@ ifneq ($(CONFIG_UNICODE),) obj-y += unicode.o endif obj-$(CONFIG_UNICODE) += utf8data.o -obj-$(CONFIG_UNICODE_NORMALIZATION_SELFTEST) += utf8-selftest.o +obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) += utf8-selftest.o unicode-y := utf8-norm.o utf8-core.o
fs/unicode/utf8-norm.c +1 -1
@@ -586,7 +586,7 @@ int utf8byte(struct utf8cursor *u8c) } } -#ifdef CONFIG_UNICODE_NORMALIZATION_SELFTEST_MODULE +#if IS_MODULE (CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST )EXPORT_SYMBOL_GPL (utf8version_is_supported);EXPORT_SYMBOL_GPL (utf8nlen);EXPORT_SYMBOL_GPL (utf8ncursor);
fs/unicode/utf8-selftest.c +69 -80
243 lines not on this page · raw message
Signature · 1 line
2.47.0.338.g60cca15819-goog
PATCH v2 6/6 unicode: kunit: change tests filename and path
In reply to David GowFrom: Gabriela Bittencourt <[email protected]>
Change utf8 kunit test filename and path to follow the style convention on Documentation/dev-tools/kunit/style.rst
---
fs/unicode/Makefile | 2 +-
fs/unicode/{ => tests}/.kunitconfig | 0
fs/unicode/{utf8-selftest.c => tests/utf8_kunit.c} | 0
3 files changed, 1 insertion(+), 1 deletion(-)
rename fs/unicode/{ => tests}/.kunitconfig (100%)
rename fs/unicode/{utf8-selftest.c => tests/utf8_kunit.c} (100%)fs/unicode/Makefile +1 -1
@@ -4,7 +4,7 @@ ifneq ($(CONFIG_UNICODE),) obj-y += unicode.o endif obj-$(CONFIG_UNICODE) += utf8data.o -obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) += utf8-selftest.o +obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) += tests/utf8_kunit.o unicode-y := utf8-norm.o utf8-core.o
fs/unicode/tests/.kunitconfig renamed from fs/unicode/.kunitconfig +0 -0
fs/unicode/tests/utf8_kunit.c renamed from fs/unicode/utf8-selftest.c +0 -0
Signature · 1 line
2.47.0.338.g60cca15819-goog
Andy Shevchenko
reviewerQuoted 24 lines · David Gow
As discussed in [1], the KUnit test naming scheme has changed to avoid name conflicts (and tab-completion woes) with the files being tested. These renames and moves have caused a nasty set of merge conflicts, so this series collates and rebases them all on top of v6.13-rc1, to be applied minimising any further conflicts. [2,3]
Thanks to everyone whose patches appear here, and everyone who reviewed on the original series. I hope I didn't break them too much during the rebase!
Bruno Sobreira França (1):
lib/math: Addint_logtest suiteDiego Vieira (1):
lib/tests/kfifo_kunit.c: add tests for the kfifo structureGabriela Bittencourt (2):
unicode: kunit: refactor selftest to kunit tests
unicode: kunit: change tests filename and path
Quoted 5 lines
Kees Cook (1):
lib: Move KUnit tests into tests/ subdirectoryLuis Felipe Hernandez (1):
lib: math: Move kunit tests into tests/ subdir
Can we deduplicate test/kunit in the file names please?
See df7f9acd8646 ("platform/x86: intel: Add 'intel' prefix to the modules automatically") for the details how to achieve that in non-verbose way.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 11 lines · David Gow
As discussed in [1], the KUnit test naming scheme has changed to avoid name conflicts (and tab-completion woes) with the files being tested. These renames and moves have caused a nasty set of merge conflicts, so this series collates and rebases them all on top of v6.13-rc1, to be applied minimising any further conflicts. [2,3]
Thanks to everyone whose patches appear here, and everyone who reviewed on the original series. I hope I didn't break them too much during the rebase!
Hello!
This series looks good to me. Tests are passed both built-in and as modules.
One comment: The second patch in the series "[PATCH v2 2/6] lib/math:
Add int_log test suite" applies with a warning of an extra EOF blank line.
Other than that small nit,
Thanks!
-Rae
Quoted 96 lines
Bruno Sobreira França (1):
lib/math: Addint_logtest suiteDiego Vieira (1):
lib/tests/kfifo_kunit.c: add tests for the kfifo structureGabriela Bittencourt (2):
unicode: kunit: refactor selftest to kunit tests
unicode: kunit: change tests filename and pathKees Cook (1):
lib: Move KUnit tests into tests/ subdirectoryLuis Felipe Hernandez (1):
lib: math: Move kunit tests into tests/ subdirMAINTAINERS | 19 +- fs/unicode/Kconfig | 5 +- fs/unicode/Makefile | 2 +- fs/unicode/tests/.kunitconfig | 3 + .../{utf8-selftest.c => tests/utf8_kunit.c} | 149 ++++++------ fs/unicode/utf8-norm.c | 2 +- lib/Kconfig.debug | 27 ++- lib/Makefile | 39 +-- lib/math/Makefile | 4 +- lib/math/tests/Makefile | 4 +- lib/math/tests/int_log_kunit.c | 75 ++++++ .../rational_kunit.c} | 0 lib/tests/Makefile | 41 ++++ lib/{ => tests}/bitfield_kunit.c | 0 lib/{ => tests}/checksum_kunit.c | 0 lib/{ => tests}/cmdline_kunit.c | 0 lib/{ => tests}/cpumask_kunit.c | 0 lib/{ => tests}/crc16_kunit.c | 0 lib/{ => tests}/fortify_kunit.c | 0 lib/{ => tests}/hashtable_test.c | 0 lib/{ => tests}/is_signed_type_kunit.c | 0 lib/tests/kfifo_kunit.c | 224 ++++++++++++++++++ lib/{ => tests}/kunit_iov_iter.c | 0 lib/{ => tests}/list-test.c | 0 lib/{ => tests}/memcpy_kunit.c | 0 lib/{ => tests}/overflow_kunit.c | 0 lib/{ => tests}/siphash_kunit.c | 0 lib/{ => tests}/slub_kunit.c | 0 lib/{ => tests}/stackinit_kunit.c | 0 lib/{ => tests}/string_helpers_kunit.c | 0 lib/{ => tests}/string_kunit.c | 0 lib/{ => tests}/test_bits.c | 0 lib/{ => tests}/test_fprobe.c | 0 lib/{ => tests}/test_hash.c | 0 lib/{ => tests}/test_kprobes.c | 0 lib/{ => tests}/test_linear_ranges.c | 0 lib/{ => tests}/test_list_sort.c | 0 lib/{ => tests}/test_sort.c | 0 lib/{ => tests}/usercopy_kunit.c | 0 lib/{ => tests}/util_macros_kunit.c | 0 40 files changed, 459 insertions(+), 135 deletions(-) create mode 100644 fs/unicode/tests/.kunitconfig rename fs/unicode/{utf8-selftest.c => tests/utf8_kunit.c} (64%) create mode 100644 lib/math/tests/int_log_kunit.c rename lib/math/{rational-test.c => tests/rational_kunit.c} (100%) rename lib/{ => tests}/bitfield_kunit.c (100%) rename lib/{ => tests}/checksum_kunit.c (100%) rename lib/{ => tests}/cmdline_kunit.c (100%) rename lib/{ => tests}/cpumask_kunit.c (100%) rename lib/{ => tests}/crc16_kunit.c (100%) rename lib/{ => tests}/fortify_kunit.c (100%) rename lib/{ => tests}/hashtable_test.c (100%) rename lib/{ => tests}/is_signed_type_kunit.c (100%) create mode 100644 lib/tests/kfifo_kunit.c rename lib/{ => tests}/kunit_iov_iter.c (100%) rename lib/{ => tests}/list-test.c (100%) rename lib/{ => tests}/memcpy_kunit.c (100%) rename lib/{ => tests}/overflow_kunit.c (100%) rename lib/{ => tests}/siphash_kunit.c (100%) rename lib/{ => tests}/slub_kunit.c (100%) rename lib/{ => tests}/stackinit_kunit.c (100%) rename lib/{ => tests}/string_helpers_kunit.c (100%) rename lib/{ => tests}/string_kunit.c (100%) rename lib/{ => tests}/test_bits.c (100%) rename lib/{ => tests}/test_fprobe.c (100%) rename lib/{ => tests}/test_hash.c (100%) rename lib/{ => tests}/test_kprobes.c (100%) rename lib/{ => tests}/test_linear_ranges.c (100%) rename lib/{ => tests}/test_list_sort.c (100%) rename lib/{ => tests}/test_sort.c (100%) rename lib/{ => tests}/usercopy_kunit.c (100%) rename lib/{ => tests}/util_macros_kunit.c (100%)--
2.47.0.338.g60cca15819-goog