Skip to contentSkip to conversation

KUnit test moves / renames

PATCH Superseded David Gow 11 participants 26 messages Oct 11, 2024 – Feb 9, 2025 1 message not in the archive

Subsystems (15)
VFS PowerPC Kselftest Library code +11 more subsystems

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

David Gow

author
#0 lore raw

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 to be applied via mm-nonmm-unstable alongside any lib/ changes[2].

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 +-
 arch/m68k/configs/amiga_defconfig             |   2 +-
 arch/m68k/configs/apollo_defconfig            |   2 +-
 arch/m68k/configs/atari_defconfig             |   2 +-
 arch/m68k/configs/bvme6000_defconfig          |   2 +-
 arch/m68k/configs/hp300_defconfig             |   2 +-
 arch/m68k/configs/mac_defconfig               |   2 +-
 arch/m68k/configs/multi_defconfig             |   2 +-
 arch/m68k/configs/mvme147_defconfig           |   2 +-
 arch/m68k/configs/mvme16x_defconfig           |   2 +-
 arch/m68k/configs/q40_defconfig               |   2 +-
 arch/m68k/configs/sun3_defconfig              |   2 +-
 arch/m68k/configs/sun3x_defconfig             |   2 +-
 arch/powerpc/configs/ppc64_defconfig          |   2 +-
 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                             |  31 ++-
 lib/Makefile                                  |  36 +--
 lib/math/Makefile                             |   5 +-
 lib/math/tests/Makefile                       |   6 +-
 .../{test_div64.c => tests/div64_kunit.c}     |   0
 lib/math/tests/int_log_kunit.c                |  75 ++++++
 .../mul_u64_u64_div_u64_kunit.c}              |   2 +-
 .../rational_kunit.c}                         |   0
 lib/tests/Makefile                            |  39 +++
 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/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
 53 files changed, 474 insertions(+), 150 deletions(-)
 create mode 100644 fs/unicode/tests/.kunitconfig
 rename fs/unicode/{utf8-selftest.c => tests/utf8_kunit.c} (64%)
 rename lib/math/{test_div64.c => tests/div64_kunit.c} (100%)
 create mode 100644 lib/math/tests/int_log_kunit.c
 rename lib/math/{test_mul_u64_u64_div_u64.c => tests/mul_u64_u64_div_u64_kunit.c} (98%)
 rename lib/math/{rational-test.c => tests/rational_kunit.c} (100%)
 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%)
 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%)
Signature · 1 line
2.47.0.rc1.288.g06298d1525-goog
author
#1 lore raw

PATCH 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.

[Rebased on top of mm-nonmm-unstable.]
---
 arch/m68k/configs/amiga_defconfig                           | 2 +-
 arch/m68k/configs/apollo_defconfig                          | 2 +-
 arch/m68k/configs/atari_defconfig                           | 2 +-
 arch/m68k/configs/bvme6000_defconfig                        | 2 +-
 arch/m68k/configs/hp300_defconfig                           | 2 +-
 arch/m68k/configs/mac_defconfig                             | 2 +-
 arch/m68k/configs/multi_defconfig                           | 2 +-
 arch/m68k/configs/mvme147_defconfig                         | 2 +-
 arch/m68k/configs/mvme16x_defconfig                         | 2 +-
 arch/m68k/configs/q40_defconfig                             | 2 +-
 arch/m68k/configs/sun3_defconfig                            | 2 +-
 arch/m68k/configs/sun3x_defconfig                           | 2 +-
 arch/powerpc/configs/ppc64_defconfig                        | 2 +-
 lib/Kconfig.debug                                           | 6 +++---
 lib/math/Makefile                                           | 5 +----
 lib/math/tests/Makefile                                     | 5 ++++-
 lib/math/{test_div64.c => tests/div64_kunit.c}              | 0
 .../mul_u64_u64_div_u64_kunit.c}                            | 2 +-
 lib/math/{rational-test.c => tests/rational_kunit.c}        | 0
 19 files changed, 22 insertions(+), 22 deletions(-)
 rename lib/math/{test_div64.c => tests/div64_kunit.c} (100%)
 rename lib/math/{test_mul_u64_u64_div_u64.c => tests/mul_u64_u64_div_u64_kunit.c} (98%)
 rename lib/math/{rational-test.c => tests/rational_kunit.c} (100%)
arch/m68k/configs/amiga_defconfig +1 -1
index d01dc47d52ea..7ba9311c084c 100644
@@ -619,7 +619,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/m68k/configs/apollo_defconfig +1 -1
index 46808e581d7b..273fe4032b85 100644
@@ -576,7 +576,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/m68k/configs/atari_defconfig +1 -1
index 4469a7839c9d..9976cda99fc1 100644
@@ -596,7 +596,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/m68k/configs/bvme6000_defconfig +1 -1
index c0719322c028..f59082c8fe06 100644
@@ -568,7 +568,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/m68k/configs/hp300_defconfig +1 -1
index 8d429e63f8f2..6db3556da9ac 100644
@@ -578,7 +578,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/m68k/configs/mac_defconfig +1 -1
index bafd33da27c1..25c06b5c83ee 100644
@@ -595,7 +595,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/m68k/configs/multi_defconfig +1 -1
index 6f5ca3f85ea1..35e57e0ee139 100644
@@ -681,7 +681,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/m68k/configs/mvme147_defconfig +1 -1
index d16b328c7136..d253b686119a 100644
@@ -567,7 +567,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/m68k/configs/mvme16x_defconfig +1 -1
index 80f6c15a5ed5..62bc6ad63783 100644
@@ -568,7 +568,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/m68k/configs/q40_defconfig +1 -1
index 0e81589f0ee2..caba39c61bac 100644
@@ -585,7 +585,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/m68k/configs/sun3_defconfig +1 -1
index 8cd785290339..a348f645ed55 100644
@@ -565,7 +565,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/m68k/configs/sun3x_defconfig +1 -1
index 78035369f60f..f8b3cfc3275b 100644
@@ -566,7 +566,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
arch/powerpc/configs/ppc64_defconfig +1 -1
index a5e3e7f97f4d..f1f21765c0c1 100644
@@ -435,7 +435,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_LKDTM=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_BACKTRACE_SELF_TEST=m
 CONFIG_TEST_REF_TRACKER=m
 CONFIG_RBTREE_TEST=m
lib/Kconfig.debug +3 -3
index 856bc9f9c069..3ed6cf950f04 100644
@@ -2296,7 +2296,7 @@ config TEST_SORT
 
 	  If unsure, say N.
 
-config TEST_DIV64
+config DIV64_KUNIT_TEST
 	tristate "64bit/32bit division and modulo test"
 	depends on DEBUG_KERNEL || m
 	help
@@ -2306,7 +2306,7 @@ config TEST_DIV64
 
 	  If unsure, say N.
 
-config TEST_MULDIV64
+config MULDIV64_KUNIT_TEST
 	tristate "mul_u64_u64_div_u64() test"
 	depends on DEBUG_KERNEL || m
 	help
@@ -2993,7 +2993,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 +1 -4
index 3ef11305f8d2..1c489501ff57 100644
@@ -5,7 +5,4 @@ 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 +4 -1
index 6a169123320a..f9a0a0e6b73a 100644
@@ -1,3 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
-obj-$(CONFIG_INT_POW_TEST) += int_pow_kunit.o
+obj-$(CONFIG_DIV64_KUNIT_TEST)    += div64_kunit.o
+obj-$(CONFIG_INT_POW_KUNIT_TEST)  += int_pow_kunit.o
+obj-$(CONFIG_MULDIV64_KUNIT_TEST) += mul_u64_u64_div_u64_kunit.o
+obj-$(CONFIG_RATIONAL_KUNIT_TEST) += rational_kunit.o
lib/math/tests/div64_kunit.c renamed from lib/math/test_div64.c +0 -0
similarity index 100%
rename from lib/math/test_div64.c
rename to lib/math/tests/div64_kunit.c
lib/math/tests/mul_u64_u64_div_u64_kunit.c renamed from lib/math/test_mul_u64_u64_div_u64.c +1 -1
similarity index 98%
rename from lib/math/test_mul_u64_u64_div_u64.c
rename to lib/math/tests/mul_u64_u64_div_u64_kunit.c
index 58d058de4e73..f61f571a0a2e 100644
@@ -49,7 +49,7 @@ static test_params test_values[] = {
  *
  * #!/bin/sh
  * sed -ne 's/^{ \+\(.*\), \+\(.*\), \+\(.*\), \+\(.*\) },$/\1 \2 \3 \4/p' \
- *     lib/math/test_mul_u64_u64_div_u64.c |
+ *     lib/math/tests/mul_u64_u64_div_u64_kunit.c |
  * while read a b c r; do
  *   expected=$( printf "obase=16; ibase=16; %X * %X / %X\n" $a $b $c | bc )
  *   given=$( printf "%X\n" $r )
lib/math/tests/rational_kunit.c renamed from lib/math/rational-test.c +0 -0
similarity index 100%
rename from lib/math/rational-test.c
rename to lib/math/tests/rational_kunit.c
Signature · 1 line
2.47.0.rc1.288.g06298d1525-goog
author
#7 lore raw

PATCH 2/6 lib/math: Add int_log test suite

In reply to David Gow

From: 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.

[Rebased on top of mm-nonmm-unstable]
---
 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
index 3ed6cf950f04..6571243ac232 100644
@@ -3009,6 +3009,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
index f9a0a0e6b73a..89a266241e98 100644
@@ -2,5 +2,6 @@
 
 obj-$(CONFIG_DIV64_KUNIT_TEST)    += div64_kunit.o
 obj-$(CONFIG_INT_POW_KUNIT_TEST)  += int_pow_kunit.o
+obj-$(CONFIG_INT_LOG_KUNIT_TEST)  += int_log_kunit.o
 obj-$(CONFIG_MULDIV64_KUNIT_TEST) += mul_u64_u64_div_u64_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.rc1.288.g06298d1525-goog
author
#8 lore raw

PATCH 3/6 lib: Move KUnit tests into tests/ subdirectory

In reply to David Gow

From: 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                           | 36 +-----------------------
 lib/tests/Makefile                     | 38 ++++++++++++++++++++++++++
 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
 lib/{ => tests}/usercopy_kunit.c       |  0
 27 files changed, 49 insertions(+), 44 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%)
 rename lib/{ => tests}/usercopy_kunit.c (100%)
MAINTAINERS +10 -9
index f1e1cd652699..bbba5c760533 100644
@@ -3929,10 +3929,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
@@ -8911,9 +8911,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
 
@@ -9578,9 +9579,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
@@ -12741,7 +12742,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
@@ -13091,7 +13092,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]
@@ -13219,7 +13220,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]>
@@ -21199,7 +21200,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 -35
index 53f82de7cbe2..7f2ddbf03fe9 100644
@@ -51,9 +51,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
@@ -64,22 +62,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
@@ -105,10 +98,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
@@ -130,7 +120,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
@@ -367,30 +357,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_USERCOPY_KUNIT_TEST) += usercopy_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 +38 -0
new file mode 100644
index 000000000000..41689f0b7c97
@@ -0,0 +1,38 @@
+# 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
+obj-$(CONFIG_USERCOPY_KUNIT_TEST) += usercopy_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
lib/tests/usercopy_kunit.c renamed from lib/usercopy_kunit.c +0 -0
similarity index 100%
rename from lib/usercopy_kunit.c
rename to lib/tests/usercopy_kunit.c
Signature · 1 line
2.47.0.rc1.288.g06298d1525-goog
author
#18 lore raw

PATCH 4/6 lib/tests/kfifo_kunit.c: add tests for the kfifo structure

In reply to David Gow

From: 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
index 6571243ac232..134d077562a9 100644
@@ -2673,6 +2673,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
index 41689f0b7c97..380f95b003fc 100644
@@ -22,6 +22,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.rc1.288.g06298d1525-goog
author
#19 lore raw

PATCH 5/6 unicode: kunit: refactor selftest to kunit tests

In reply to David Gow

From: 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
new file mode 100644
index 000000000000..62dd5c171f9c
@@ -0,0 +1,3 @@
+CONFIG_KUNIT=y
+CONFIG_UNICODE=y
+CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST=y
fs/unicode/Kconfig +3 -2
index da786a687fdc..4ad2c36550f1 100644
@@ -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
index e309afe2b2bb..37bbcbc628a1 100644
@@ -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
index 768f8ab448b8..7b998c99c88d 100644
@@ -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

246 lines not on this page · raw message

Signature · 1 line
2.47.0.rc1.288.g06298d1525-goog
author
#21 lore raw

PATCH 6/6 unicode: kunit: change tests filename and path

In reply to David Gow

From: 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
index 37bbcbc628a1..d95be7fb9f6b 100644
@@ -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
similarity index 100%
rename from fs/unicode/.kunitconfig
rename to fs/unicode/tests/.kunitconfig
fs/unicode/tests/utf8_kunit.c renamed from fs/unicode/utf8-selftest.c +0 -0
similarity index 100%
rename from fs/unicode/utf8-selftest.c
rename to fs/unicode/tests/utf8_kunit.c
Signature · 1 line
2.47.0.rc1.288.g06298d1525-goog
#2 lore raw

Re: [PATCH 1/6] lib: math: Move kunit tests into tests/ subdir

In reply to David Gow

Hi David,

Quoted 10 lines · David Gow

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.

Quoted 7 lines
[Rebased on top of mm-nonmm-unstable.]

Thanks for your patch!

Quoted 11 lines
arch/m68k/configs/amiga_defconfig +1 -1
@@ -619,7 +619,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m

[...]

Quoted 12 lines
lib/Kconfig.debug +1 -1
@@ -2296,7 +2296,7 @@ config TEST_SORT
 
          If unsure, say N.
 
-config TEST_DIV64
+config DIV64_KUNIT_TEST
        tristate "64bit/32bit division and modulo test"
        depends on DEBUG_KERNEL || m
        help

lib/Kconfig.debug config TEST_DIV64 · line 2312

Quoted 8 lines
lib/Kconfig.debug +1 -1
@@ -2306,7 +2306,7 @@ config TEST_DIV64
 
          If unsure, say N.
 
-config TEST_MULDIV64
+config MULDIV64_KUNIT_TEST
        tristate "mul_u64_u64_div_u64() test"
        depends on DEBUG_KERNEL || m
        help

This conflicts with "[PATCH] m68k: defconfig: Update defconfigs for v6.12-rc1"[1]. Of course the proper way forward would be to add "default KUNIT_ALL_TESTS" to all tests that still lack it, so I can just never queue that patch ;-)

lib/Kconfig.debug config TEST_OBJPOOL · line 2999

Quoted 9 lines
lib/Kconfig.debug +1 -1
@@ -2993,7 +2993,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

[1] https://lore.kernel.org/all/4092672cb64b86ec3f300b4cf0ea0c2db2b52e2e.1727699197.git.geert@linux-m68k.org/

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Acked-by on v1 3/6
#9 lore raw

Re: [PATCH 3/6] lib: Move KUnit tests into tests/ subdirectory

In reply to David Gow
Quoted 10 lines · David Gow

From: Kees Cook <[email protected]>

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

Quoted 3 lines
[Rebased onto mm-nonmm-unstable, moved usercopy_kunit]
#10 lore raw

Re: [PATCH 3/6] lib: Move KUnit tests into tests/ subdirectory

In reply to David Gow
Quoted 30 lines · David Gow

From: Kees Cook <[email protected]>

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

 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%)
Quoted 8 lines
 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%)

While I support the idea, I think this adds an additional churn in creating a duplicate 'test' in the filenames. Why they all can't be cut while removing? (at least this question is not answered in the commit message)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw

Re: [PATCH 3/6] lib: Move KUnit tests into tests/ subdirectory

Hi Andy,

Quoted 40 lines · Andy Shevchenko
Quoted 30 lines · David Gow

From: Kees Cook <[email protected]>

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

 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%)
Quoted 8 lines
 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%)
Quoted 3 lines

While I support the idea, I think this adds an additional churn in creating a duplicate 'test' in the filenames. Why they all can't be cut while removing? (at least this question is not answered in the commit message)

To avoid duplicate *.ko file names?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Acked-by on the v1 series
#23 lore raw
In reply to David Gow
Quoted 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 to be applied via mm-nonmm-unstable alongside any lib/ changes[2].

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

Quoted 5 lines

Kees Cook (1):
lib: Move KUnit tests into tests/ subdirectory

Luis Felipe Hernandez (1):
lib: math: Move kunit tests into tests/ subdir

These look good to me. Thank you.

thanks,
-- Shuah

#12 lore raw

Re: [PATCH 3/6] lib: Move KUnit tests into tests/ subdirectory

In reply to Geert Uytterhoeven
Quoted 43 lines · Geert Uytterhoeven

Hi Andy,

Quoted 40 lines · Andy Shevchenko
Quoted 38 lines · David Gow

From: Kees Cook <[email protected]>

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

 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%)
 rename lib/{ => tests}/usercopy_kunit.c (100%)
Quoted 5 lines
Quoted 3 lines

While I support the idea, I think this adds an additional churn in creating a duplicate 'test' in the filenames. Why they all can't be cut while removing? (at least this question is not answered in the commit message)

To avoid duplicate *.ko file names?

With what? Sorry, but I don't see how it's a problem. These are test cases. Do they use kernel command line parameters? If so, shouldn't KUnit take care about it in a more proper way?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#13 lore raw

Re: [PATCH 3/6] lib: Move KUnit tests into tests/ subdirectory

Hi Andy,

Quoted 46 lines · Andy Shevchenko
Quoted 45 lines · Geert Uytterhoeven
Quoted 43 lines · Andy Shevchenko
Quoted 30 lines · David Gow

From: Kees Cook <[email protected]>

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

 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%)
Quoted 8 lines
 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%)

While I support the idea, I think this adds an additional churn in creating a duplicate 'test' in the filenames. Why they all can't be cut while removing? (at least this question is not answered in the commit message)

Quoted 5 lines
Quoted 1 line

To avoid duplicate *.ko file names?

With what? Sorry, but I don't see how it's a problem. These are test cases. Do they use kernel command line parameters? If so, shouldn't KUnit take care about it in a more proper way?

If .e.g. lib/list_sort.o could be modular, its module would be called "list_sort.ko", conflicting with the "list_sort.ko" test module.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#14 lore raw

Re: [PATCH 3/6] lib: Move KUnit tests into tests/ subdirectory

Quoted 4 lines · Geert Uytterhoeven
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Geert Uytterhoeven
Quoted 1 line · Andy Shevchenko

On Fri, Oct 11, 2024 at 03:25:07PM +0800, David Gow wrote:

...

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 16 lines
 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%)
Quoted 8 lines
 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%)

While I support the idea, I think this adds an additional churn in creating a duplicate 'test' in the filenames. Why they all can't be cut while removing? (at least this question is not answered in the commit message)

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

To avoid duplicate *.ko file names?

With what? Sorry, but I don't see how it's a problem. These are test cases. Do they use kernel command line parameters? If so, shouldn't KUnit take care about it in a more proper way?

If .e.g. lib/list_sort.o could be modular, its module would be called "list_sort.ko", conflicting with the "list_sort.ko" test module.

Can't this be solved by automatically adding a prefix in Makefile for kunit tests, for example?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#15 lore raw

Re: [PATCH 3/6] lib: Move KUnit tests into tests/ subdirectory

Le 11/10/2024 à 17:21, Andy Shevchenko a écrit :

Quoted 47 lines

[Vous ne recevez pas souvent de courriers de [email protected]. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]

Quoted 4 lines · Geert Uytterhoeven
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Geert Uytterhoeven
Quoted 1 line · Andy Shevchenko

On Fri, Oct 11, 2024 at 03:25:07PM +0800, David Gow wrote:

...

Quoted 37 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 16 lines

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%)

Quoted 8 lines

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%)

While I support the idea, I think this adds an additional churn in creating a duplicate 'test' in the filenames. Why they all can't be cut while removing? (at least this question is not answered in the commit message)

Quoted 5 lines
Quoted 1 line

To avoid duplicate *.ko file names?

With what? Sorry, but I don't see how it's a problem. These are test cases. Do they use kernel command line parameters? If so, shouldn't KUnit take care about it in a more proper way?

If .e.g. lib/list_sort.o could be modular, its module would be called "list_sort.ko", conflicting with the "list_sort.ko" test module.

But as it is now in lib/tests/, the module will also be installed in tests/ subdir, so it shouldn't clash anymore ?

You'd have:

/lib/modules/lib/list_sort.ko and
/lib/modules/lib/tests/list_sort.ko

Or did I miss something ?

Quoted 7 lines

Can't this be solved by automatically adding a prefix in Makefile for kunit tests, for example?

--
With Best Regards,
Andy Shevchenko

maintainer
#17 lore raw

Re: [PATCH 3/6] lib: Move KUnit tests into tests/ subdirectory

In reply to David Gow
Quoted 4 lines · David Gow

From: Kees Cook <[email protected]>

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

Thanks for picking this up! I hadn't had time to resend it. :)

Signature · 1 line
Kees Cook
#16 lore raw

Re: [PATCH 3/6] lib: Move KUnit tests into tests/ subdirectory

In reply to Christophe Leroy
Quoted 8 lines · Christophe Leroy

Le 11/10/2024 à 17:21, Andy Shevchenko a écrit :

Quoted 7 lines

[Vous ne recevez pas souvent de courriers de [email protected]. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]

Quoted 4 lines · Geert Uytterhoeven
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Geert Uytterhoeven
Quoted 1 line · Andy Shevchenko

On Fri, Oct 11, 2024 at 03:25:07PM +0800, David Gow wrote:

...

Quoted 41 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 16 lines

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%)

Quoted 8 lines

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%)

While I support the idea, I think this adds an additional churn in creating a duplicate 'test' in the filenames. Why they all can't be cut while removing? (at least this question is not answered in the commit message)

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

To avoid duplicate *.ko file names?

With what? Sorry, but I don't see how it's a problem. These are test cases. Do they use kernel command line parameters? If so, shouldn't KUnit take care about it in a more proper way?

If .e.g. lib/list_sort.o could be modular, its module would be called "list_sort.ko", conflicting with the "list_sort.ko" test module.

But as it is now in lib/tests/, the module will also be installed in tests/ subdir, so it shouldn't clash anymore ?

Quoted 6 lines

You'd have:

/lib/modules/lib/list_sort.ko and
/lib/modules/lib/tests/list_sort.ko

Or did I miss something ?

I believe Geert is talking about modprobe list-sort in the userspace. Which one will be loaded?

Quoted 2 lines
Quoted 2 lines

Can't this be solved by automatically adding a prefix in Makefile for kunit tests, for example?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
Acked-by on v1 5/6
#20 lore raw

Re: [PATCH 5/6] unicode: kunit: refactor selftest to kunit tests

In reply to David Gow
Quoted 5 lines · David Gow

From: Gabriela Bittencourt <[email protected]>

Refactoring 'test' functions into kunit tests, to test utf-8 support in unicode subsystem.

Quoted 9 lines

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.

Signature · 1 line
Gabriel Krisman Bertazi
Acked-by on v1 6/6
#22 lore raw

Re: [PATCH 6/6] unicode: kunit: change tests filename and path

In reply to David Gow
Quoted 5 lines · David Gow

From: Gabriela Bittencourt <[email protected]>

Change utf8 kunit test filename and path to follow the style convention on Documentation/dev-tools/kunit/style.rst

Quoted 8 lines
Signature · 1 line
Gabriel Krisman Bertazi
#3 lore raw

Re: [PATCH 1/6] lib: math: Move kunit tests into tests/ subdir

In reply to Geert Uytterhoeven

Hi all,

Quoted 34 lines · Geert Uytterhoeven
Quoted 33 lines · David Gow

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.

[Rebased on top of mm-nonmm-unstable.]
lib/Kconfig.debug +1 -1
@@ -2296,7 +2296,7 @@ config TEST_SORT
 
          If unsure, say N.
 
-config TEST_DIV64
+config DIV64_KUNIT_TEST
        tristate "64bit/32bit division and modulo test"
        depends on DEBUG_KERNEL || m
        help
@@ -2306,7 +2306,7 @@ config TEST_DIV64
 
          If unsure, say N.
 
Quoted 10 lines

lib/Kconfig.debug config TEST_DIV64 · line 2312

Quoted 5 lines
lib/Kconfig.debug +1 -1
-config TEST_MULDIV64
+config MULDIV64_KUNIT_TEST
        tristate "mul_u64_u64_div_u64() test"
        depends on DEBUG_KERNEL || m
        help

This conflicts with "[PATCH] m68k: defconfig: Update defconfigs for v6.12-rc1"[1]. Of course the proper way forward would be to add "default KUNIT_ALL_TESTS" to all tests that still lack it, so I can just never queue that patch ;-)

What's the status of this series? I am asking because I am wondering if I should queue [1] for v6.13, or just drop it, and send a patch to add "default KUNIT_ALL_TESTS" instead.

I saw the email from Andrew stating he applied it to his tree[2], but that seems to have been dropped silently, and never made it into linux-next?

Thanks!

Quoted 11 lines

lib/Kconfig.debug config TEST_OBJPOOL · line 2999

Quoted 9 lines
lib/Kconfig.debug +1 -1
@@ -2993,7 +2993,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

[1] https://lore.kernel.org/all/4092672cb64b86ec3f300b4cf0ea0c2db2b52e2e.1727699197.git.geert@linux-m68k.org/

[2] https://lore.kernel.org/all/[email protected]/

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer
#4 lore raw

Re: [PATCH 1/6] lib: math: Move kunit tests into tests/ subdir

Quoted 6 lines · On Wed, 6 Nov 2024 09:33:55 +0100 Geert Uytterhoeven <[email protected]>…

Hi all,

Quoted 4 lines

This conflicts with "[PATCH] m68k: defconfig: Update defconfigs for v6.12-rc1"[1]. Of course the proper way forward would be to add "default KUNIT_ALL_TESTS" to all tests that still lack it, so I can just never queue that patch ;-)

Quoted 7 lines

What's the status of this series? I am asking because I am wondering if I should queue [1] for v6.13, or just drop it, and send a patch to add "default KUNIT_ALL_TESTS" instead.

I saw the email from Andrew stating he applied it to his tree[2], but that seems to have been dropped silently, and never made it into linux-next?

Yes, sorry. Believe it or not, I do try to avoid spraying out too many emails. David will recall better than I, but things got messy.
https://lkml.kernel.org/r/[email protected] was perhaps the cause.

I'm sure David can being us up to date.

#5 lore raw

Re: [PATCH 1/6] lib: math: Move kunit tests into tests/ subdir

Hi Andrew,

Quoted 10 lines · Andrew Morton
Quoted 9 lines · On Wed, 6 Nov 2024 09:33:55 +0100 Geert Uytterhoeven <[email protected]>…
Quoted 4 lines

This conflicts with "[PATCH] m68k: defconfig: Update defconfigs for v6.12-rc1"[1]. Of course the proper way forward would be to add "default KUNIT_ALL_TESTS" to all tests that still lack it, so I can just never queue that patch ;-)

What's the status of this series? I am asking because I am wondering if I should queue [1] for v6.13, or just drop it, and send a patch to add "default KUNIT_ALL_TESTS" instead.

Quoted 8 lines
Quoted 3 lines

I saw the email from Andrew stating he applied it to his tree[2], but that seems to have been dropped silently, and never made it into linux-next?

Yes, sorry. Believe it or not, I do try to avoid spraying out too many emails. David will recall better than I, but things got messy.
https://lkml.kernel.org/r/[email protected] was perhaps the cause.

Fair enough.

Quoted 1 line

I'm sure David can being us up to date.

Probably the best solution is to respin after v6.13-rc1, to be included in v6.13-rc2.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author
#6 lore raw

Re: [PATCH 1/6] lib: math: Move kunit tests into tests/ subdir

Quoted 23 lines · Geert Uytterhoeven

Hi Andrew,

Quoted 10 lines · Andrew Morton
Quoted 9 lines · On Wed, 6 Nov 2024 09:33:55 +0100 Geert Uytterhoeven <[email protected]>…
Quoted 4 lines

This conflicts with "[PATCH] m68k: defconfig: Update defconfigs for v6.12-rc1"[1]. Of course the proper way forward would be to add "default KUNIT_ALL_TESTS" to all tests that still lack it, so I can just never queue that patch ;-)

What's the status of this series? I am asking because I am wondering if I should queue [1] for v6.13, or just drop it, and send a patch to add "default KUNIT_ALL_TESTS" instead.

Quoted 8 lines
Quoted 3 lines

I saw the email from Andrew stating he applied it to his tree[2], but that seems to have been dropped silently, and never made it into linux-next?

Yes, sorry. Believe it or not, I do try to avoid spraying out too many emails. David will recall better than I, but things got messy.
https://lkml.kernel.org/r/[email protected] was perhaps the cause.

Quoted 7 lines

Fair enough.

Quoted 1 line

I'm sure David can being us up to date.

Probably the best solution is to respin after v6.13-rc1, to be included in v6.13-rc2.

Sorry about the delay, for some reason these were getting caught in my spam filter...

Yeah, I think that's probably best. I'll go through and do a new version post rc1.

In general, my preferred option is to use the 'default KUNIT_ALL_TESTS' where possible. I'm sure there'll be some tests where it makes sense to _not_ enable them by default, but we should where we can. Ultimately, it's up to the test maintainer, though.

-- David

-- David

maintainer
#24 lore raw
In reply to Shuah Khan
Quoted 28 lines · Shuah Khan
Quoted 27 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 to be applied via mm-nonmm-unstable alongside any lib/ changes[2].

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

Quoted 7 lines
Quoted 2 lines

Luis Felipe Hernandez (1):
lib: math: Move kunit tests into tests/ subdir

These look good to me. Thank you.

Shall I carry this in the hardening tree? I didn't see it land in the merge window, and I still don't see it in -next?

-Kees

Signature · 1 line
Kees Cook
#26 lore raw
In reply to a message not in the archive

Hi all,

Quoted 11 lines · On Mon, 10 Feb 2025 04:43:28 +0530 Shuah Khan <[email protected]> wrote:
Quoted 8 lines · Kees Cook
Quoted 6 lines · Shuah Khan
Quoted 5 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 to be applied via mm-nonmm-unstable alongside any lib/ changes[2].

Quoted 6 lines
Quoted 3 lines

Shall I carry this in the hardening tree? I didn't see it land in the merge window, and I still don't see it in -next?

My thinking was that this series would go through Andrew's tree to avoid conflicts. Please take it through yours.

If they have been rebased onto mm-nonmm-unstable, then they really need to go through Andrew' tree (since mm-nonmm-unstable gets rebased often).

Signature · 2 lines
Cheers,
Stephen Rothwell