]> www.infradead.org Git - users/dwmw2/linux.git/commit
string: Convert selftest to KUnit
authorKees Cook <keescook@chromium.org>
Fri, 1 Mar 2024 20:27:30 +0000 (12:27 -0800)
committerKees Cook <keescook@chromium.org>
Tue, 5 Mar 2024 09:55:28 +0000 (01:55 -0800)
commit29d8568849fe5937e14f5f7763931bb2decf298d
tree5d5f28ce0924bb42e95160dc089bc75793a70792
parente36b70fb8c707a0688960184380bc151390d671b
string: Convert selftest to KUnit

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

Additional text context is retained for failure reporting. For example,
when forcing a bad match, we can see the loop counters reported for the
memset() tests:

[09:21:52]     # test_memset64: ASSERTION FAILED at lib/string_kunit.c:93
[09:21:52]     Expected v == 0xa2a1a1a1a1a1a1a1ULL, but
[09:21:52]         v == -6799976246779207263 (0xa1a1a1a1a1a1a1a1)
[09:21:52]         0xa2a1a1a1a1a1a1a1ULL == -6727918652741279327 (0xa2a1a1a1a1a1a1a1)
[09:21:52] i:0 j:0 k:0
[09:21:52] [FAILED] test_memset64

Currently passes without problems:

$ ./tools/testing/kunit/kunit.py run string
...
[09:37:40] Starting KUnit Kernel (1/1)...
[09:37:40] ============================================================
[09:37:40] =================== string (6 subtests) ====================
[09:37:40] [PASSED] test_memset16
[09:37:40] [PASSED] test_memset32
[09:37:40] [PASSED] test_memset64
[09:37:40] [PASSED] test_strchr
[09:37:40] [PASSED] test_strnchr
[09:37:40] [PASSED] test_strspn
[09:37:40] ===================== [PASSED] string ======================
[09:37:40] ============================================================
[09:37:40] Testing complete. Ran 6 tests: passed: 6
[09:37:40] Elapsed time: 6.730s total, 0.001s configuring, 6.562s building, 0.131s running

Link: https://lore.kernel.org/r/20240301202732.2688342-1-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
MAINTAINERS
lib/Kconfig.debug
lib/Makefile
lib/string_kunit.c [new file with mode: 0644]
lib/test_string.c [deleted file]