Skip to content

Commit 97c1f30

Browse files
tamirdkees
authored andcommitted
scanf: convert self-test to KUnit
Convert the scanf() self-test to a KUnit test. In the interest of keeping the patch reasonably-sized this doesn't refactor the tests into proper parameterized tests - it's all one big test case. Reviewed-by: David Gow <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Tested-by: Petr Mladek <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 6340d61 commit 97c1f30

File tree

8 files changed

+134
-141
lines changed

8 files changed

+134
-141
lines changed

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25411,8 +25411,8 @@ R: Sergey Senozhatsky <[email protected]>
2541125411
S: Maintained
2541225412
T: git git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux.git
2541325413
F: Documentation/core-api/printk-formats.rst
25414-
F: lib/test_scanf.c
2541525414
F: lib/tests/printf_kunit.c
25415+
F: lib/tests/scanf_kunit.c
2541625416
F: lib/vsprintf.c
2541725417

2541825418
VT1211 HARDWARE MONITOR DRIVER

lib/Kconfig.debug

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,6 +2436,15 @@ config PRINTF_KUNIT_TEST
24362436

24372437
If unsure, say N.
24382438

2439+
config SCANF_KUNIT_TEST
2440+
tristate "KUnit test scanf() family of functions at runtime" if !KUNIT_ALL_TESTS
2441+
depends on KUNIT
2442+
default KUNIT_ALL_TESTS
2443+
help
2444+
Enable this option to test the scanf functions at runtime.
2445+
2446+
If unsure, say N.
2447+
24392448
config STRING_KUNIT_TEST
24402449
tristate "KUnit test string functions at runtime" if !KUNIT_ALL_TESTS
24412450
depends on KUNIT
@@ -2449,9 +2458,6 @@ config STRING_HELPERS_KUNIT_TEST
24492458
config TEST_KSTRTOX
24502459
tristate "Test kstrto*() family of functions at runtime"
24512460

2452-
config TEST_SCANF
2453-
tristate "Test scanf() family of functions at runtime"
2454-
24552461
config TEST_BITMAP
24562462
tristate "Test bitmap_*() family of functions at runtime"
24572463
help

lib/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ obj-$(CONFIG_TEST_RHASHTABLE) += test_rhashtable.o
7777
obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
7878
obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
7979
obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o
80-
obj-$(CONFIG_TEST_SCANF) += test_scanf.o
8180

8281
obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
8382
ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_KASAN),yy)

lib/tests/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ obj-$(CONFIG_MEMCPY_KUNIT_TEST) += memcpy_kunit.o
3030
CFLAGS_overflow_kunit.o = $(call cc-disable-warning, tautological-constant-out-of-range-compare)
3131
obj-$(CONFIG_OVERFLOW_KUNIT_TEST) += overflow_kunit.o
3232
obj-$(CONFIG_PRINTF_KUNIT_TEST) += printf_kunit.o
33+
obj-$(CONFIG_SCANF_KUNIT_TEST) += scanf_kunit.o
3334
obj-$(CONFIG_SIPHASH_KUNIT_TEST) += siphash_kunit.o
3435
obj-$(CONFIG_SLUB_KUNIT_TEST) += slub_kunit.o
3536
obj-$(CONFIG_TEST_SORT) += test_sort.o

0 commit comments

Comments
 (0)