Skip to content

Commit 617f55e

Browse files
committed
lib: overflow: Convert to Kunit
Convert overflow unit tests to KUnit, for better integration into the kernel self test framework. Includes a rename of test_overflow.c to overflow_kunit.c, and CONFIG_TEST_OVERFLOW to CONFIG_OVERFLOW_KUNIT_TEST. $ ./tools/testing/kunit/kunit.py run overflow ... [14:33:51] Starting KUnit Kernel (1/1)... [14:33:51] ============================================================ [14:33:51] ================== overflow (11 subtests) ================== [14:33:51] [PASSED] u8_overflow_test [14:33:51] [PASSED] s8_overflow_test [14:33:51] [PASSED] u16_overflow_test [14:33:51] [PASSED] s16_overflow_test [14:33:51] [PASSED] u32_overflow_test [14:33:51] [PASSED] s32_overflow_test [14:33:51] [PASSED] u64_overflow_test [14:33:51] [PASSED] s64_overflow_test [14:33:51] [PASSED] overflow_shift_test [14:33:51] [PASSED] overflow_allocation_test [14:33:51] [PASSED] overflow_size_helpers_test [14:33:51] ==================== [PASSED] overflow ===================== [14:33:51] ============================================================ [14:33:51] Testing complete. Passed: 11, Failed: 0, Crashed: 0, Skipped: 0, Errors: 0 [14:33:51] Elapsed time: 12.525s total, 0.001s configuring, 12.402s building, 0.101s running Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Nick Desaulniers <ndesaulniers@google.com> Co-developed-by: Vitor Massaru Iha <vitor@massaru.org> Signed-off-by: Vitor Massaru Iha <vitor@massaru.org> Link: https://lore.kernel.org/lkml/20200720224418.200495-1-vitor@massaru.org/ Co-developed-by: Daniel Latypov <dlatypov@google.com> Signed-off-by: Daniel Latypov <dlatypov@google.com> Link: https://lore.kernel.org/linux-kselftest/20210503211536.1384578-1-dlatypov@google.com/ Acked-by: Nick Desaulniers <ndesaulniers@google.com> Link: https://lore.kernel.org/lkml/CAKwvOdm62iA1dNiC6Q11UJ-MnTqtc4kXkm-ubPaFMK824_k0nw@mail.gmail.com Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: David Gow <davidgow@google.com> Link: https://lore.kernel.org/lkml/CABVgOS=TWVh649_Vjo3wnMu9gZnq66gkV-LtGgsksAWMqc+MSA@mail.gmail.com
1 parent 230f6fa commit 617f55e

3 files changed

Lines changed: 263 additions & 309 deletions

File tree

lib/Kconfig.debug

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,9 +2214,6 @@ config TEST_UUID
22142214
config TEST_XARRAY
22152215
tristate "Test the XArray code at runtime"
22162216

2217-
config TEST_OVERFLOW
2218-
tristate "Test check_*_overflow() functions at runtime"
2219-
22202217
config TEST_RHASHTABLE
22212218
tristate "Perform selftest on resizable hash table"
22222219
help
@@ -2501,6 +2498,19 @@ config MEMCPY_KUNIT_TEST
25012498

25022499
If unsure, say N.
25032500

2501+
config OVERFLOW_KUNIT_TEST
2502+
tristate "Test check_*_overflow() functions at runtime" if !KUNIT_ALL_TESTS
2503+
depends on KUNIT
2504+
default KUNIT_ALL_TESTS
2505+
help
2506+
Builds unit tests for the check_*_overflow(), size_*(), allocation, and
2507+
related functions.
2508+
2509+
For more information on KUnit and unit tests in general please refer
2510+
to the KUnit documentation in Documentation/dev-tools/kunit/.
2511+
2512+
If unsure, say N.
2513+
25042514
config TEST_UDELAY
25052515
tristate "udelay test driver"
25062516
help

lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o
7777
obj-$(CONFIG_TEST_MIN_HEAP) += test_min_heap.o
7878
obj-$(CONFIG_TEST_LKM) += test_module.o
7979
obj-$(CONFIG_TEST_VMALLOC) += test_vmalloc.o
80-
obj-$(CONFIG_TEST_OVERFLOW) += test_overflow.o
8180
obj-$(CONFIG_TEST_RHASHTABLE) += test_rhashtable.o
8281
obj-$(CONFIG_TEST_SORT) += test_sort.o
8382
obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
@@ -363,6 +362,7 @@ obj-$(CONFIG_BITS_TEST) += test_bits.o
363362
obj-$(CONFIG_CMDLINE_KUNIT_TEST) += cmdline_kunit.o
364363
obj-$(CONFIG_SLUB_KUNIT_TEST) += slub_kunit.o
365364
obj-$(CONFIG_MEMCPY_KUNIT_TEST) += memcpy_kunit.o
365+
obj-$(CONFIG_OVERFLOW_KUNIT_TEST) += overflow_kunit.o
366366

367367
obj-$(CONFIG_GENERIC_LIB_DEVMEM_IS_ALLOWED) += devmem_is_allowed.o
368368

0 commit comments

Comments
 (0)