Skip to contentSkip to conversation

string: Convert selftests to KUnit

PATCH Superseded Kees Cook 1 participant 4 messages Feb 29, 2024 Library code

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

cover string: Convert selftests to KUnit

Hi,

I realized the string selftests hadn't been converted to KUnit yet. Do that.

-Kees

Kees Cook (2):
string: Convert selftest to KUnit
string: Convert helpers selftest to KUnit

 MAINTAINERS                                   |   4 +-
 lib/Kconfig.debug                             |  12 +-
 lib/Makefile                                  |   4 +-
 ...tring_helpers.c => string_helpers_kunit.c} | 160 +++++++++--------
 lib/{test_string.c => string_kunit.c}         | 166 ++++++------------
 5 files changed, 154 insertions(+), 192 deletions(-)
 rename lib/{test-string_helpers.c => string_helpers_kunit.c} (79%)
 rename lib/{test_string.c => string_kunit.c} (54%)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 string: Convert selftest to KUnit

Convert test_string.c to KUnit so it can be easily run with everything else.

---
Cc: Andy Shevchenko <[email protected]>
Cc: [email protected]

---
 MAINTAINERS                           |   2 +-
 lib/Kconfig.debug                     |   6 +-
 lib/Makefile                          |   2 +-
 lib/{test_string.c => string_kunit.c} | 166 +++++++++-----------------
 4 files changed, 61 insertions(+), 115 deletions(-)
 rename lib/{test_string.c => string_kunit.c} (54%)
MAINTAINERS +1 -1
index cd651c4df019..9f1f68cccd6a 100644
@@ -8976,9 +8976,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/test-string_helpers.c
-F:	lib/test_string.c
 F:	scripts/coccinelle/api/string_choices.cocci
 
 GENERIC UIO DRIVER FOR PCI DEVICES
lib/Kconfig.debug +4 -2
index 4e2febe3b568..406cdf353488 100644
@@ -2352,8 +2352,10 @@ config ASYNC_RAID6_TEST
 config TEST_HEXDUMP
 	tristate "Test functions located in the hexdump module at runtime"
 
-config STRING_SELFTEST
-	tristate "Test string functions at runtime"
+config STRING_KUNIT_TEST
+	tristate "KUnit test string functions at runtime" if !KUNIT_ALL_TESTS
+	depends on KUNIT
+	default KUNIT_ALL_TESTS
 
 config TEST_STRING_HELPERS
 	tristate "Test functions located in the string_helpers module at runtime"
lib/Makefile +1 -1
index eae87c41b22b..946277c37831 100644
@@ -49,7 +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_SELFTEST) += test_string.o
+obj-$(CONFIG_STRING_KUNIT_TEST) += string_kunit.o
 obj-y += string_helpers.o
 obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
 obj-y += hexdump.o
lib/string_kunit.c renamed from lib/test_string.c +55 -111

293 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#2 lore raw

PATCH 2/2 string: Convert helpers selftest to KUnit

In reply to Kees Cook

Convert test-string_helpers.c to KUnit so it can be easily run with everything else.

---
Cc: Andy Shevchenko <[email protected]>
Cc: [email protected]

---
 MAINTAINERS                                   |   2 +-
 lib/Kconfig.debug                             |   6 +-
 lib/Makefile                                  |   2 +-
 ...tring_helpers.c => string_helpers_kunit.c} | 160 ++++++++++--------
 4 files changed, 93 insertions(+), 77 deletions(-)
 rename lib/{test-string_helpers.c => string_helpers_kunit.c} (79%)
MAINTAINERS +1 -1
index 9f1f68cccd6a..f3f26d2d4ffb 100644
@@ -8978,7 +8978,7 @@ F:	include/linux/string_helpers.h
 F:	lib/string.c
 F:	lib/string_kunit.c
 F:	lib/string_helpers.c
-F:	lib/test-string_helpers.c
+F:	lib/string_helpers_kunit.c
 F:	scripts/coccinelle/api/string_choices.cocci
 
 GENERIC UIO DRIVER FOR PCI DEVICES
lib/Kconfig.debug +4 -2
index 406cdf353488..5429e6f170f3 100644
@@ -2357,8 +2357,10 @@ config STRING_KUNIT_TEST
 	depends on KUNIT
 	default KUNIT_ALL_TESTS
 
-config TEST_STRING_HELPERS
-	tristate "Test functions located in the string_helpers module at runtime"
+config STRING_HELPERS_KUNIT_TEST
+	tristate "KUnit test string helpers at runtime" if !KUNIT_ALL_TESTS
+	depends on KUNIT
+	default KUNIT_ALL_TESTS
 
 config TEST_KSTRTOX
 	tristate "Test kstrto*() family of functions at runtime"
lib/Makefile +1 -1
index 946277c37831..97c42e38046f 100644
@@ -51,7 +51,7 @@ obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \
 	 generic-radix-tree.o bitmap-str.o
 obj-$(CONFIG_STRING_KUNIT_TEST) += string_kunit.o
 obj-y += string_helpers.o
-obj-$(CONFIG_TEST_STRING_HELPERS) += test-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
lib/string_helpers_kunit.c renamed from lib/test-string_helpers.c +87 -73

321 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#3 lore raw

Re: [PATCH 2/2] string: Convert helpers selftest to KUnit

Quoted 2 lines · Kees Cook

Convert test-string_helpers.c to KUnit so it can be easily run with everything else.

Gah, I will send a v2. I thought I was doing this on top of the get_size() change, but I didn't...

Signature · 1 line
Kees Cook