Skip to contentSkip to conversation

lib: Move KUnit tests into tests/ subdirectory

PATCH Superseded Kees Cook 5 participants 7 messages Jul 20, 2024 – Oct 11, 2024

Subsystems (11)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kees Cook

author maintainer
#0 lore raw

PATCH 1/1 lib: Move KUnit tests into tests/ subdirectory

Following from the recent KUnit file naming discussion[1], move all KUnit tests in lib/ into lib/tests/.

---
I can carry this in the hardening tree. To disrupt people as little as possible, I'm hoping to send this either at the end of -rc1 or early in -rc2.
Cc: Andrew Morton <[email protected]>
Cc: Yury Norov <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: David Gow <[email protected]>
Cc: "Jason A. Donenfeld" <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: "Naveen N. Rao" <[email protected]>
Cc: Anil S Keshavamurthy <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Matti Vaittinen <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 MAINTAINERS                            | 18 ++++++-------
 lib/Makefile                           | 35 +-----------------------
 lib/tests/Makefile                     | 37 ++++++++++++++++++++++++++
 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}/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
 26 files changed, 47 insertions(+), 43 deletions(-)
 create mode 100644 lib/tests/Makefile
 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}/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%)
MAINTAINERS +9 -9
index 8754ac2c259d..3f4b9d007cbb 100644
@@ -3737,10 +3737,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
@@ -8618,9 +8618,9 @@ 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:	\b__NO_FORTIFY\b
 
@@ -9246,9 +9246,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
@@ -12347,7 +12347,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
@@ -12697,7 +12697,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]
@@ -12824,7 +12824,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]>
@@ -20498,7 +20498,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 -34
index 3b1769045651..f00fe120ee9e 100644
@@ -49,9 +49,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
@@ -62,22 +60,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_USER_COPY) += test_user_copy.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
@@ -104,10 +97,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
@@ -129,7 +119,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
@@ -366,29 +356,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_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_GENERIC_LIB_DEVMEM_IS_ALLOWED) += devmem_is_allowed.o
 
 obj-$(CONFIG_FIRMWARE_TABLE) += fw_table.o
lib/tests/Makefile new file +37 -0
new file mode 100644
index 000000000000..c6a14cc8663e
@@ -0,0 +1,37 @@
+# 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
+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
+
lib/tests/bitfield_kunit.c renamed from lib/bitfield_kunit.c +0 -0
similarity index 100%
rename from lib/bitfield_kunit.c
rename to lib/tests/bitfield_kunit.c
lib/tests/checksum_kunit.c renamed from lib/checksum_kunit.c +0 -0
similarity index 100%
rename from lib/checksum_kunit.c
rename to lib/tests/checksum_kunit.c
lib/tests/cmdline_kunit.c renamed from lib/cmdline_kunit.c +0 -0
similarity index 100%
rename from lib/cmdline_kunit.c
rename to lib/tests/cmdline_kunit.c
lib/tests/cpumask_kunit.c renamed from lib/cpumask_kunit.c +0 -0
similarity index 100%
rename from lib/cpumask_kunit.c
rename to lib/tests/cpumask_kunit.c
lib/tests/fortify_kunit.c renamed from lib/fortify_kunit.c +0 -0
similarity index 100%
rename from lib/fortify_kunit.c
rename to lib/tests/fortify_kunit.c
lib/tests/hashtable_test.c renamed from lib/hashtable_test.c +0 -0
similarity index 100%
rename from lib/hashtable_test.c
rename to lib/tests/hashtable_test.c
lib/tests/is_signed_type_kunit.c renamed from lib/is_signed_type_kunit.c +0 -0
similarity index 100%
rename from lib/is_signed_type_kunit.c
rename to lib/tests/is_signed_type_kunit.c
lib/tests/kunit_iov_iter.c renamed from lib/kunit_iov_iter.c +0 -0
similarity index 100%
rename from lib/kunit_iov_iter.c
rename to lib/tests/kunit_iov_iter.c
lib/tests/list-test.c renamed from lib/list-test.c +0 -0
similarity index 100%
rename from lib/list-test.c
rename to lib/tests/list-test.c
lib/tests/memcpy_kunit.c renamed from lib/memcpy_kunit.c +0 -0
similarity index 100%
rename from lib/memcpy_kunit.c
rename to lib/tests/memcpy_kunit.c
lib/tests/overflow_kunit.c renamed from lib/overflow_kunit.c +0 -0
similarity index 100%
rename from lib/overflow_kunit.c
rename to lib/tests/overflow_kunit.c
lib/tests/siphash_kunit.c renamed from lib/siphash_kunit.c +0 -0
similarity index 100%
rename from lib/siphash_kunit.c
rename to lib/tests/siphash_kunit.c
lib/tests/slub_kunit.c renamed from lib/slub_kunit.c +0 -0
similarity index 100%
rename from lib/slub_kunit.c
rename to lib/tests/slub_kunit.c
lib/tests/stackinit_kunit.c renamed from lib/stackinit_kunit.c +0 -0
similarity index 100%
rename from lib/stackinit_kunit.c
rename to lib/tests/stackinit_kunit.c
lib/tests/string_helpers_kunit.c renamed from lib/string_helpers_kunit.c +0 -0
similarity index 100%
rename from lib/string_helpers_kunit.c
rename to lib/tests/string_helpers_kunit.c
lib/tests/string_kunit.c renamed from lib/string_kunit.c +0 -0
similarity index 100%
rename from lib/string_kunit.c
rename to lib/tests/string_kunit.c
lib/tests/test_bits.c renamed from lib/test_bits.c +0 -0
similarity index 100%
rename from lib/test_bits.c
rename to lib/tests/test_bits.c
lib/tests/test_fprobe.c renamed from lib/test_fprobe.c +0 -0
similarity index 100%
rename from lib/test_fprobe.c
rename to lib/tests/test_fprobe.c
lib/tests/test_hash.c renamed from lib/test_hash.c +0 -0
similarity index 100%
rename from lib/test_hash.c
rename to lib/tests/test_hash.c
lib/tests/test_kprobes.c renamed from lib/test_kprobes.c +0 -0
similarity index 100%
rename from lib/test_kprobes.c
rename to lib/tests/test_kprobes.c
lib/tests/test_linear_ranges.c renamed from lib/test_linear_ranges.c +0 -0
similarity index 100%
rename from lib/test_linear_ranges.c
rename to lib/tests/test_linear_ranges.c
lib/tests/test_list_sort.c renamed from lib/test_list_sort.c +0 -0
similarity index 100%
rename from lib/test_list_sort.c
rename to lib/tests/test_list_sort.c
lib/tests/test_sort.c renamed from lib/test_sort.c +0 -0
similarity index 100%
rename from lib/test_sort.c
rename to lib/tests/test_sort.c
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Kees Cook
Quoted 5 lines · On Sat, 20 Jul 2024 11:10:30 -0700 Kees Cook <[email protected]> wrote:

Following from the recent KUnit file naming discussion[1], move all KUnit tests in lib/ into lib/tests/.

This looks good to me.

For kprobes and fprobe tests.

BTW, should we also rename the file from tests/test_foo.c to tests/foo_kunit.c ?

Thank you,

Quoted 374 lines

---
I can carry this in the hardening tree. To disrupt people as little as possible, I'm hoping to send this either at the end of -rc1 or early in -rc2.
Cc: Andrew Morton <[email protected]>
Cc: Yury Norov <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: David Gow <[email protected]>
Cc: "Jason A. Donenfeld" <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: "Naveen N. Rao" <[email protected]>
Cc: Anil S Keshavamurthy <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Matti Vaittinen <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 MAINTAINERS                            | 18 ++++++-------
 lib/Makefile                           | 35 +-----------------------
 lib/tests/Makefile                     | 37 ++++++++++++++++++++++++++
 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}/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
 26 files changed, 47 insertions(+), 43 deletions(-)
 create mode 100644 lib/tests/Makefile
 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}/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%)
MAINTAINERS +9 -9
index 8754ac2c259d..3f4b9d007cbb 100644
@@ -3737,10 +3737,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
@@ -8618,9 +8618,9 @@ 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:	\b__NO_FORTIFY\b
 
@@ -9246,9 +9246,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
@@ -12347,7 +12347,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
@@ -12697,7 +12697,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]
@@ -12824,7 +12824,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]>
@@ -20498,7 +20498,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 -34
index 3b1769045651..f00fe120ee9e 100644
@@ -49,9 +49,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
@@ -62,22 +60,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_USER_COPY) += test_user_copy.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
@@ -104,10 +97,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
@@ -129,7 +119,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
@@ -366,29 +356,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_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_GENERIC_LIB_DEVMEM_IS_ALLOWED) += devmem_is_allowed.o
 
 obj-$(CONFIG_FIRMWARE_TABLE) += fw_table.o
lib/tests/Makefile new file +37 -0
new file mode 100644
index 000000000000..c6a14cc8663e
@@ -0,0 +1,37 @@
+# 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
+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
+
lib/tests/bitfield_kunit.c renamed from lib/bitfield_kunit.c +0 -0
similarity index 100%
rename from lib/bitfield_kunit.c
rename to lib/tests/bitfield_kunit.c
lib/tests/checksum_kunit.c renamed from lib/checksum_kunit.c +0 -0
similarity index 100%
rename from lib/checksum_kunit.c
rename to lib/tests/checksum_kunit.c
lib/tests/cmdline_kunit.c renamed from lib/cmdline_kunit.c +0 -0
similarity index 100%
rename from lib/cmdline_kunit.c
rename to lib/tests/cmdline_kunit.c
lib/tests/cpumask_kunit.c renamed from lib/cpumask_kunit.c +0 -0
similarity index 100%
rename from lib/cpumask_kunit.c
rename to lib/tests/cpumask_kunit.c
lib/tests/fortify_kunit.c renamed from lib/fortify_kunit.c +0 -0
similarity index 100%
rename from lib/fortify_kunit.c
rename to lib/tests/fortify_kunit.c
lib/tests/hashtable_test.c renamed from lib/hashtable_test.c +0 -0
similarity index 100%
rename from lib/hashtable_test.c
rename to lib/tests/hashtable_test.c
lib/tests/is_signed_type_kunit.c renamed from lib/is_signed_type_kunit.c +0 -0
similarity index 100%
rename from lib/is_signed_type_kunit.c
rename to lib/tests/is_signed_type_kunit.c
lib/tests/kunit_iov_iter.c renamed from lib/kunit_iov_iter.c +0 -0
similarity index 100%
rename from lib/kunit_iov_iter.c
rename to lib/tests/kunit_iov_iter.c
lib/tests/list-test.c renamed from lib/list-test.c +0 -0
similarity index 100%
rename from lib/list-test.c
rename to lib/tests/list-test.c
lib/tests/memcpy_kunit.c renamed from lib/memcpy_kunit.c +0 -0
similarity index 100%
rename from lib/memcpy_kunit.c
rename to lib/tests/memcpy_kunit.c
lib/tests/overflow_kunit.c renamed from lib/overflow_kunit.c +0 -0
similarity index 100%
rename from lib/overflow_kunit.c
rename to lib/tests/overflow_kunit.c
lib/tests/siphash_kunit.c renamed from lib/siphash_kunit.c +0 -0
similarity index 100%
rename from lib/siphash_kunit.c
rename to lib/tests/siphash_kunit.c
lib/tests/slub_kunit.c renamed from lib/slub_kunit.c +0 -0
similarity index 100%
rename from lib/slub_kunit.c
rename to lib/tests/slub_kunit.c
lib/tests/stackinit_kunit.c renamed from lib/stackinit_kunit.c +0 -0
similarity index 100%
rename from lib/stackinit_kunit.c
rename to lib/tests/stackinit_kunit.c
lib/tests/string_helpers_kunit.c renamed from lib/string_helpers_kunit.c +0 -0
similarity index 100%
rename from lib/string_helpers_kunit.c
rename to lib/tests/string_helpers_kunit.c
lib/tests/string_kunit.c renamed from lib/string_kunit.c +0 -0
similarity index 100%
rename from lib/string_kunit.c
rename to lib/tests/string_kunit.c
lib/tests/test_bits.c renamed from lib/test_bits.c +0 -0
similarity index 100%
rename from lib/test_bits.c
rename to lib/tests/test_bits.c
lib/tests/test_fprobe.c renamed from lib/test_fprobe.c +0 -0
similarity index 100%
rename from lib/test_fprobe.c
rename to lib/tests/test_fprobe.c
lib/tests/test_hash.c renamed from lib/test_hash.c +0 -0
similarity index 100%
rename from lib/test_hash.c
rename to lib/tests/test_hash.c
lib/tests/test_kprobes.c renamed from lib/test_kprobes.c +0 -0
similarity index 100%
rename from lib/test_kprobes.c
rename to lib/tests/test_kprobes.c
lib/tests/test_linear_ranges.c renamed from lib/test_linear_ranges.c +0 -0
similarity index 100%
rename from lib/test_linear_ranges.c
rename to lib/tests/test_linear_ranges.c
lib/tests/test_list_sort.c renamed from lib/test_list_sort.c +0 -0
similarity index 100%
rename from lib/test_list_sort.c
rename to lib/tests/test_list_sort.c
lib/tests/test_sort.c renamed from lib/test_sort.c +0 -0
similarity index 100%
rename from lib/test_sort.c
rename to lib/tests/test_sort.c
Signature · 1 line
2.34.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#3 lore raw
In reply to Kees Cook
Quoted 10 lines · Kees Cook

Following from the recent KUnit file naming discussion[1], move all KUnit tests in lib/ into lib/tests/.

---
I can carry this in the hardening tree. To disrupt people as little as possible, I'm hoping to send this either at the end of -rc1 or early in -rc2.

Thanks.

I'm happy if you want to rename list-test.c -> list_kunit.c, too.

Cheers
-- David

Quoted 374 lines
Cc Andrew Morton <[email protected]>
Cc Yury Norov <[email protected]>
Cc Rasmus Villemoes <[email protected]>
Cc David Gow <[email protected]>
Cc "Jason A. Donenfeld" <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc "Naveen N. Rao" <[email protected]>
Cc Anil S Keshavamurthy <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Mark Brown <[email protected]>
Cc Matti Vaittinen <[email protected]>
---
 MAINTAINERS                            | 18 ++++++-------
 lib/Makefile                           | 35 +-----------------------
 lib/tests/Makefile                     | 37 ++++++++++++++++++++++++++
 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}/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
 26 files changed, 47 insertions(+), 43 deletions(-)
 create mode 100644 lib/tests/Makefile
 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}/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%)
MAINTAINERS +9 -9
index 8754ac2c259d..3f4b9d007cbb 100644
@@ -3737,10 +3737,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
@@ -8618,9 +8618,9 @@ 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:     \b__NO_FORTIFY\b
 
@@ -9246,9 +9246,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
@@ -12347,7 +12347,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
@@ -12697,7 +12697,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]
@@ -12824,7 +12824,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]>
@@ -20498,7 +20498,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 -34
index 3b1769045651..f00fe120ee9e 100644
@@ -49,9 +49,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
@@ -62,22 +60,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_USER_COPY) += test_user_copy.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
@@ -104,10 +97,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
@@ -129,7 +119,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
@@ -366,29 +356,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_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_GENERIC_LIB_DEVMEM_IS_ALLOWED) += devmem_is_allowed.o
 
 obj-$(CONFIG_FIRMWARE_TABLE) += fw_table.o
lib/tests/Makefile new file +37 -0
new file mode 100644
index 000000000000..c6a14cc8663e
@@ -0,0 +1,37 @@
+# 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
+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
+
lib/tests/bitfield_kunit.c renamed from lib/bitfield_kunit.c +0 -0
similarity index 100%
rename from lib/bitfield_kunit.c
rename to lib/tests/bitfield_kunit.c
lib/tests/checksum_kunit.c renamed from lib/checksum_kunit.c +0 -0
similarity index 100%
rename from lib/checksum_kunit.c
rename to lib/tests/checksum_kunit.c
lib/tests/cmdline_kunit.c renamed from lib/cmdline_kunit.c +0 -0
similarity index 100%
rename from lib/cmdline_kunit.c
rename to lib/tests/cmdline_kunit.c
lib/tests/cpumask_kunit.c renamed from lib/cpumask_kunit.c +0 -0
similarity index 100%
rename from lib/cpumask_kunit.c
rename to lib/tests/cpumask_kunit.c
lib/tests/fortify_kunit.c renamed from lib/fortify_kunit.c +0 -0
similarity index 100%
rename from lib/fortify_kunit.c
rename to lib/tests/fortify_kunit.c
lib/tests/hashtable_test.c renamed from lib/hashtable_test.c +0 -0
similarity index 100%
rename from lib/hashtable_test.c
rename to lib/tests/hashtable_test.c
lib/tests/is_signed_type_kunit.c renamed from lib/is_signed_type_kunit.c +0 -0
similarity index 100%
rename from lib/is_signed_type_kunit.c
rename to lib/tests/is_signed_type_kunit.c
lib/tests/kunit_iov_iter.c renamed from lib/kunit_iov_iter.c +0 -0
similarity index 100%
rename from lib/kunit_iov_iter.c
rename to lib/tests/kunit_iov_iter.c
lib/tests/list-test.c renamed from lib/list-test.c +0 -0
similarity index 100%
rename from lib/list-test.c
rename to lib/tests/list-test.c
lib/tests/memcpy_kunit.c renamed from lib/memcpy_kunit.c +0 -0
similarity index 100%
rename from lib/memcpy_kunit.c
rename to lib/tests/memcpy_kunit.c
lib/tests/overflow_kunit.c renamed from lib/overflow_kunit.c +0 -0
similarity index 100%
rename from lib/overflow_kunit.c
rename to lib/tests/overflow_kunit.c
lib/tests/siphash_kunit.c renamed from lib/siphash_kunit.c +0 -0
similarity index 100%
rename from lib/siphash_kunit.c
rename to lib/tests/siphash_kunit.c
lib/tests/slub_kunit.c renamed from lib/slub_kunit.c +0 -0
similarity index 100%
rename from lib/slub_kunit.c
rename to lib/tests/slub_kunit.c
lib/tests/stackinit_kunit.c renamed from lib/stackinit_kunit.c +0 -0
similarity index 100%
rename from lib/stackinit_kunit.c
rename to lib/tests/stackinit_kunit.c
lib/tests/string_helpers_kunit.c renamed from lib/string_helpers_kunit.c +0 -0
similarity index 100%
rename from lib/string_helpers_kunit.c
rename to lib/tests/string_helpers_kunit.c
lib/tests/string_kunit.c renamed from lib/string_kunit.c +0 -0
similarity index 100%
rename from lib/string_kunit.c
rename to lib/tests/string_kunit.c
lib/tests/test_bits.c renamed from lib/test_bits.c +0 -0
similarity index 100%
rename from lib/test_bits.c
rename to lib/tests/test_bits.c
lib/tests/test_fprobe.c renamed from lib/test_fprobe.c +0 -0
similarity index 100%
rename from lib/test_fprobe.c
rename to lib/tests/test_fprobe.c
lib/tests/test_hash.c renamed from lib/test_hash.c +0 -0
similarity index 100%
rename from lib/test_hash.c
rename to lib/tests/test_hash.c
lib/tests/test_kprobes.c renamed from lib/test_kprobes.c +0 -0
similarity index 100%
rename from lib/test_kprobes.c
rename to lib/tests/test_kprobes.c
lib/tests/test_linear_ranges.c renamed from lib/test_linear_ranges.c +0 -0
similarity index 100%
rename from lib/test_linear_ranges.c
rename to lib/tests/test_linear_ranges.c
lib/tests/test_list_sort.c renamed from lib/test_list_sort.c +0 -0
similarity index 100%
rename from lib/test_list_sort.c
rename to lib/tests/test_list_sort.c
lib/tests/test_sort.c renamed from lib/test_sort.c +0 -1
similarity index 100%
rename from lib/test_sort.c
rename to lib/tests/test_sort.c
--

2.34.1

--
You received this message because you are subscribed to the Google Groups "KUnit Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20240720181025.work.002-kees%40kernel.org.

author maintainer
#4 lore raw
Quoted 12 lines · David Gow
Quoted 10 lines · Kees Cook

Following from the recent KUnit file naming discussion[1], move all KUnit tests in lib/ into lib/tests/.

---
I can carry this in the hardening tree. To disrupt people as little as possible, I'm hoping to send this either at the end of -rc1 or early in -rc2.

Quoted 3 lines

Thanks.

I'm happy if you want to rename list-test.c -> list_kunit.c, too.

Sure! I was thinking about doing some separate follow-up changes for individual tests.

-Kees

Signature · 1 line
Kees Cook
maintainer
#5 lore raw
In reply to Kees Cook
Quoted 6 lines · On Sat, 20 Jul 2024 11:10:30 -0700 Kees Cook <[email protected]> wrote:

Following from the recent KUnit file naming discussion[1], move all KUnit tests in lib/ into lib/tests/.

---

I was talking with Masami and asking him where the kunit test code lives and after pointing to lib/ I was disgusted with what I saw. I told him, "why isn't this in its own "tests/" directory"? And he mentioned this patch (which I forgot about).

So yes, please move it.

Thanks,

-- Steve

Quoted 20 lines

I can carry this in the hardening tree. To disrupt people as little as possible, I'm hoping to send this either at the end of -rc1 or early in -rc2.
Cc: Andrew Morton <[email protected]>
Cc: Yury Norov <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: David Gow <[email protected]>
Cc: "Jason A. Donenfeld" <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: "Naveen N. Rao" <[email protected]>
Cc: Anil S Keshavamurthy <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Matti Vaittinen <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

#6 lore raw
In reply to Kees Cook
Quoted 19 lines · Kees Cook

Following from the recent KUnit file naming discussion[1], move all KUnit tests in lib/ into lib/tests/.

---
I can carry this in the hardening tree. To disrupt people as little as possible, I'm hoping to send this either at the end of -rc1 or early in -rc2.
Cc: Andrew Morton <[email protected]>
Cc: Yury Norov <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: David Gow <[email protected]>
Cc: "Jason A. Donenfeld" <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: "Naveen N. Rao" <[email protected]>
Cc: Anil S Keshavamurthy <[email protected]>
Cc: "David S. Miller" <[email protected]>

Quoted 8 lines

Cc: Masami Hiramatsu <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Matti Vaittinen <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---

I've just rebased this and sent it out as part of a series of renames to Andrew:
https://lore.kernel.org/linux-kselftest/[email protected]/T/#u

Hopefully this will be a workable way of getting all of the different renames (and other things entangled with renames) in, but let me know if it causes problems / if I broke it.

Cheers,
-- David

Quoted 357 lines
 MAINTAINERS                            | 18 ++++++-------
 lib/Makefile                           | 35 +-----------------------
 lib/tests/Makefile                     | 37 ++++++++++++++++++++++++++
 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}/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
 26 files changed, 47 insertions(+), 43 deletions(-)
 create mode 100644 lib/tests/Makefile
 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}/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%)
MAINTAINERS +9 -9
index 8754ac2c259d..3f4b9d007cbb 100644
@@ -3737,10 +3737,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
@@ -8618,9 +8618,9 @@ 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:     \b__NO_FORTIFY\b
 
@@ -9246,9 +9246,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
@@ -12347,7 +12347,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
@@ -12697,7 +12697,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]
@@ -12824,7 +12824,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]>
@@ -20498,7 +20498,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 -34
index 3b1769045651..f00fe120ee9e 100644
@@ -49,9 +49,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
@@ -62,22 +60,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_USER_COPY) += test_user_copy.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
@@ -104,10 +97,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
@@ -129,7 +119,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
@@ -366,29 +356,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_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_GENERIC_LIB_DEVMEM_IS_ALLOWED) += devmem_is_allowed.o
 
 obj-$(CONFIG_FIRMWARE_TABLE) += fw_table.o
lib/tests/Makefile new file +37 -0
new file mode 100644
index 000000000000..c6a14cc8663e
@@ -0,0 +1,37 @@
+# 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
+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
+
lib/tests/bitfield_kunit.c renamed from lib/bitfield_kunit.c +0 -0
similarity index 100%
rename from lib/bitfield_kunit.c
rename to lib/tests/bitfield_kunit.c
lib/tests/checksum_kunit.c renamed from lib/checksum_kunit.c +0 -0
similarity index 100%
rename from lib/checksum_kunit.c
rename to lib/tests/checksum_kunit.c
lib/tests/cmdline_kunit.c renamed from lib/cmdline_kunit.c +0 -0
similarity index 100%
rename from lib/cmdline_kunit.c
rename to lib/tests/cmdline_kunit.c
lib/tests/cpumask_kunit.c renamed from lib/cpumask_kunit.c +0 -0
similarity index 100%
rename from lib/cpumask_kunit.c
rename to lib/tests/cpumask_kunit.c
lib/tests/fortify_kunit.c renamed from lib/fortify_kunit.c +0 -0
similarity index 100%
rename from lib/fortify_kunit.c
rename to lib/tests/fortify_kunit.c
lib/tests/hashtable_test.c renamed from lib/hashtable_test.c +0 -0
similarity index 100%
rename from lib/hashtable_test.c
rename to lib/tests/hashtable_test.c
lib/tests/is_signed_type_kunit.c renamed from lib/is_signed_type_kunit.c +0 -0
similarity index 100%
rename from lib/is_signed_type_kunit.c
rename to lib/tests/is_signed_type_kunit.c
lib/tests/kunit_iov_iter.c renamed from lib/kunit_iov_iter.c +0 -0
similarity index 100%
rename from lib/kunit_iov_iter.c
rename to lib/tests/kunit_iov_iter.c
lib/tests/list-test.c renamed from lib/list-test.c +0 -0
similarity index 100%
rename from lib/list-test.c
rename to lib/tests/list-test.c
lib/tests/memcpy_kunit.c renamed from lib/memcpy_kunit.c +0 -0
similarity index 100%
rename from lib/memcpy_kunit.c
rename to lib/tests/memcpy_kunit.c
lib/tests/overflow_kunit.c renamed from lib/overflow_kunit.c +0 -0
similarity index 100%
rename from lib/overflow_kunit.c
rename to lib/tests/overflow_kunit.c
lib/tests/siphash_kunit.c renamed from lib/siphash_kunit.c +0 -0
similarity index 100%
rename from lib/siphash_kunit.c
rename to lib/tests/siphash_kunit.c
lib/tests/slub_kunit.c renamed from lib/slub_kunit.c +0 -0
similarity index 100%
rename from lib/slub_kunit.c
rename to lib/tests/slub_kunit.c
lib/tests/stackinit_kunit.c renamed from lib/stackinit_kunit.c +0 -0
similarity index 100%
rename from lib/stackinit_kunit.c
rename to lib/tests/stackinit_kunit.c
lib/tests/string_helpers_kunit.c renamed from lib/string_helpers_kunit.c +0 -0
similarity index 100%
rename from lib/string_helpers_kunit.c
rename to lib/tests/string_helpers_kunit.c
lib/tests/string_kunit.c renamed from lib/string_kunit.c +0 -0
similarity index 100%
rename from lib/string_kunit.c
rename to lib/tests/string_kunit.c
lib/tests/test_bits.c renamed from lib/test_bits.c +0 -0
similarity index 100%
rename from lib/test_bits.c
rename to lib/tests/test_bits.c
lib/tests/test_fprobe.c renamed from lib/test_fprobe.c +0 -0
similarity index 100%
rename from lib/test_fprobe.c
rename to lib/tests/test_fprobe.c
lib/tests/test_hash.c renamed from lib/test_hash.c +0 -0
similarity index 100%
rename from lib/test_hash.c
rename to lib/tests/test_hash.c
lib/tests/test_kprobes.c renamed from lib/test_kprobes.c +0 -0
similarity index 100%
rename from lib/test_kprobes.c
rename to lib/tests/test_kprobes.c
lib/tests/test_linear_ranges.c renamed from lib/test_linear_ranges.c +0 -0
similarity index 100%
rename from lib/test_linear_ranges.c
rename to lib/tests/test_linear_ranges.c
lib/tests/test_list_sort.c renamed from lib/test_list_sort.c +0 -0
similarity index 100%
rename from lib/test_list_sort.c
rename to lib/tests/test_list_sort.c
lib/tests/test_sort.c renamed from lib/test_sort.c +0 -1
similarity index 100%
rename from lib/test_sort.c
rename to lib/tests/test_sort.c
--

2.34.1

--
You received this message because you are subscribed to the Google Groups "KUnit Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20240720181025.work.002-kees%40kernel.org.