Message ID | 20250307-scanf-kunit-convert-v9-0-b98820fa39ff@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | scanf: convert self-test to KUnit | expand |
On Fri 2025-03-07 06:27:33, Tamir Duberstein wrote: > This is one of just 3 remaining "Test Module" kselftests (the others > being bitmap and printf), the rest having been converted to KUnit. In > addition to the enclosed patch, please consider this an RFC on the > removal of the "Test Module" kselftest machinery. > > Tamir Duberstein (6): > scanf: implicate test line in failure messages > scanf: remove redundant debug logs > scanf: convert self-test to KUnit > scanf: break kunit into test cases Kees, could you please take the above 5 patches as well via the tree moving the KUNIT tests to lib/tests ? They seem to be ready for linux-next and the next merge window. > scanf: tidy header `#include`s This one is a bit controversial and might be added later. > scanf: further break kunit into test cases This one was just an attempt. But I personally think that it is not worth it. Best Regards, Petr
On Fri, Mar 14, 2025 at 02:29:40PM +0100, Petr Mladek wrote: > On Fri 2025-03-07 06:27:33, Tamir Duberstein wrote: > > This is one of just 3 remaining "Test Module" kselftests (the others > > being bitmap and printf), the rest having been converted to KUnit. In > > addition to the enclosed patch, please consider this an RFC on the > > removal of the "Test Module" kselftest machinery. > > > > Tamir Duberstein (6): > > scanf: implicate test line in failure messages > > scanf: remove redundant debug logs > > scanf: convert self-test to KUnit > > scanf: break kunit into test cases > > Kees, could you please take the above 5 patches as well > via the tree moving the KUNIT tests to lib/tests ? I think you mean 4? Sure! -Kees > > They seem to be ready for linux-next and the next merge window. > > > scanf: tidy header `#include`s > > This one is a bit controversial and might be added later. > > > scanf: further break kunit into test cases > > This one was just an attempt. But I personally think that > it is not worth it. > > Best Regards, > Petr
On Fri, Mar 14, 2025 at 4:45 PM Kees Cook <kees@kernel.org> wrote: > > On Fri, Mar 14, 2025 at 02:29:40PM +0100, Petr Mladek wrote: > > On Fri 2025-03-07 06:27:33, Tamir Duberstein wrote: > > > This is one of just 3 remaining "Test Module" kselftests (the others > > > being bitmap and printf), the rest having been converted to KUnit. In > > > addition to the enclosed patch, please consider this an RFC on the > > > removal of the "Test Module" kselftest machinery. > > > > > > Tamir Duberstein (6): > > > scanf: implicate test line in failure messages > > > scanf: remove redundant debug logs > > > scanf: convert self-test to KUnit > > > scanf: break kunit into test cases > > > > Kees, could you please take the above 5 patches as well > > via the tree moving the KUNIT tests to lib/tests ? > > I think you mean 4? Sure! 4 by my count as well :) Please let me know if you'd like me to respin with conflicts resolved!
On Fri, 07 Mar 2025 06:27:33 -0500, Tamir Duberstein wrote: > This is one of just 3 remaining "Test Module" kselftests (the others > being bitmap and printf), the rest having been converted to KUnit. In > addition to the enclosed patch, please consider this an RFC on the > removal of the "Test Module" kselftest machinery. > > I tested this using: > > [...] (I had to rebase on the printf move, but I think it got it all.) Applied to for-next/move-kunit-tests, thanks! [1/6] scanf: implicate test line in failure messages https://git.kernel.org/kees/c/5866730da723 [2/6] scanf: remove redundant debug logs https://git.kernel.org/kees/c/6340d61b9005 [3/6] scanf: convert self-test to KUnit https://git.kernel.org/kees/c/97c1f302f2bc [4/6] scanf: break kunit into test cases https://git.kernel.org/kees/c/d62f8c95470c Take care,
On Fri, Mar 14, 2025 at 5:00 PM Kees Cook <kees@kernel.org> wrote: > > On Fri, 07 Mar 2025 06:27:33 -0500, Tamir Duberstein wrote: > > This is one of just 3 remaining "Test Module" kselftests (the others > > being bitmap and printf), the rest having been converted to KUnit. In > > addition to the enclosed patch, please consider this an RFC on the > > removal of the "Test Module" kselftest machinery. > > > > I tested this using: > > > > [...] > > (I had to rebase on the printf move, but I think it got it all.) > > Applied to for-next/move-kunit-tests, thanks! > > [1/6] scanf: implicate test line in failure messages > https://git.kernel.org/kees/c/5866730da723 > [2/6] scanf: remove redundant debug logs > https://git.kernel.org/kees/c/6340d61b9005 > [3/6] scanf: convert self-test to KUnit > https://git.kernel.org/kees/c/97c1f302f2bc > [4/6] scanf: break kunit into test cases > https://git.kernel.org/kees/c/d62f8c95470c Looks good to me. Thanks Kees!
On Fri 2025-03-14 16:50:43, Tamir Duberstein wrote: > On Fri, Mar 14, 2025 at 4:45 PM Kees Cook <kees@kernel.org> wrote: > > > > On Fri, Mar 14, 2025 at 02:29:40PM +0100, Petr Mladek wrote: > > > On Fri 2025-03-07 06:27:33, Tamir Duberstein wrote: > > > > This is one of just 3 remaining "Test Module" kselftests (the others > > > > being bitmap and printf), the rest having been converted to KUnit. In > > > > addition to the enclosed patch, please consider this an RFC on the > > > > removal of the "Test Module" kselftest machinery. > > > > > > > > Tamir Duberstein (6): > > > > scanf: implicate test line in failure messages > > > > scanf: remove redundant debug logs > > > > scanf: convert self-test to KUnit > > > > scanf: break kunit into test cases > > > > > > Kees, could you please take the above 5 patches as well > > > via the tree moving the KUNIT tests to lib/tests ? > > > > I think you mean 4? Sure! > > 4 by my count as well :) > > Please let me know if you'd like me to respin with conflicts resolved! Yes, I meant 4. I am sorry for the confusion. And the list of pushed patches in the later reply looks good. Thanks for help. Best Regards, Petr
This is one of just 3 remaining "Test Module" kselftests (the others being bitmap and printf), the rest having been converted to KUnit. In addition to the enclosed patch, please consider this an RFC on the removal of the "Test Module" kselftest machinery. I tested this using: $ tools/testing/kunit/kunit.py run --arch arm64 --make_options LLVM=1 scanf Failure output before this series: [ 383.100048] test_scanf: vsscanf("1574 9 64ca 935b 7 142d ff58 0", "%4hx %1hx %4hx %4hx %1hx %4hx %4hx %1hx", ...) expected 2472240330 got 1690959881 [ 383.102843] test_scanf: vsscanf("f12:2:d:2:c166:1:36b:1906", "%3hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...) expected 131085 got 851970 [ 383.105376] test_scanf: vsscanf("4,b2fe,3,593,6,0,3bde,0", "%1hx,%4hx,%1hx,%3hx,%1hx,%1hx,%4hx,%1hx", ...) expected 93519875 got 242430 [ 383.105659] test_scanf: vsscanf("6-1-2-1-d9e6-f-93e-e567", "%1hx-%1hx-%1hx-%1hx-%4hx-%1hx-%3hx-%4hx", ...) expected 65538 got 131073 [ 383.106127] test_scanf: vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...) expected 125069 got 3901554741 [ 383.106235] test_scanf: vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...) expected 571539457 got 106936 ... [ 383.106398] test_scanf: failed 6 out of 2545 tests Failure output after this series: # numbers_list_field_width_val_width: ASSERTION FAILED at lib/scanf_kunit.c:94 lib/scanf_kunit.c:555: vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...) expected 837828163 got 1044578334 not ok 1 " " # numbers_list_field_width_val_width: ASSERTION FAILED at lib/scanf_kunit.c:94 lib/scanf_kunit.c:555: vsscanf("dc2:1c:0:3531:2621:5172:1:7", "%3hx:%2hx:%1hx:%4hx:%4hx:%4hx:%1hx:%1hx", ...) expected 892403712 got 28 not ok 2 ":" # numbers_list_field_width_val_width: ASSERTION FAILED at lib/scanf_kunit.c:94 lib/scanf_kunit.c:555: vsscanf("e083,8f6e,b,70ca,1,1,aab1,10e4", "%4hx,%4hx,%1hx,%4hx,%1hx,%1hx,%4hx,%4hx", ...) expected 1892286475 got 757614 not ok 3 "," # numbers_list_field_width_val_width: ASSERTION FAILED at lib/scanf_kunit.c:94 lib/scanf_kunit.c:555: vsscanf("2e72-8435-1-2fc-7cbd-c2f1-7158-2b41", "%4hx-%4hx-%1hx-%3hx-%4hx-%4hx-%4hx-%4hx", ...) expected 50069505 got 99381 not ok 4 "-" # numbers_list_field_width_val_width: ASSERTION FAILED at lib/scanf_kunit.c:94 lib/scanf_kunit.c:555: vsscanf("403/0/17/1/11e7/1/1fe8/34ba", "%3hx/%1hx/%2hx/%1hx/%4hx/%1hx/%4hx/%4hx", ...) expected 65559 got 1507328 not ok 5 "/" Signed-off-by: Tamir Duberstein <tamird@gmail.com> --- Changes in v9: - Use __scanf correctly on `_test`. (Thanks to Petr Mladek). - Split header `#include` cleanup into separate patch. (Petr Mladek) - In "scanf: break kunit into test cases", revert to KUNIT_FAIL. (Petr Mladek) - Rebase on linux-next. - Add provisional patch "scanf: further break kunit into test cases". Please feel free to take this series without this patch if you prefer. - Link to v8: https://lore.kernel.org/r/20250214-scanf-kunit-convert-v8-0-5ea50f95f83c@gmail.com Changes in v8: - Expand "scanf: remove redundant debug logs" commit message. (Andy Shevchenko) - Add patch "implicate test line in failure messages". - Rebase on linux-next, move scanf_kunit.c into lib/tests/. - Link to v7: https://lore.kernel.org/r/20250211-scanf-kunit-convert-v7-0-c057f0a3d9d8@gmail.com Changes in v7: - Remove redundant debug logs. (Petr Mladek) - Drop Petr's Acked-by. - Use original test assertions as KUNIT_*_EQ_MSG produces hard-to-parse messages. The new failure output is: - Link to v6: https://lore.kernel.org/r/20250210-scanf-kunit-convert-v6-0-4d583d07f92d@gmail.com Changes in v6: - s/at boot/at runtime/ for consistency with the printf series. - Go back to kmalloc. (Geert Uytterhoeven) - Link to v5: https://lore.kernel.org/r/20250210-scanf-kunit-convert-v5-0-8e64f3a7de99@gmail.com Changes in v5: - Remove extraneous trailing newlines from failure messages. - Replace `pr_debug` with `kunit_printk`. - Use static char arrays instead of kmalloc. - Drop KUnit boilerplate from CONFIG_SCANF_KUNIT_TEST help text. - Drop arch changes. - Link to v4: https://lore.kernel.org/r/20250207-scanf-kunit-convert-v4-0-a23e2afaede8@gmail.com Changes in v4: - Bake `test` into various macros, greatly reducing diff noise. - Revert control flow changes. - Link to v3: https://lore.kernel.org/r/20250204-scanf-kunit-convert-v3-0-386d7c3ee714@gmail.com Changes in v3: - Reduce diff noise in lib/Makefile. (Petr Mladek) - Split `scanf_test` into a few test cases. New output: : =================== scanf (10 subtests) ==================== : [PASSED] numbers_simple : ====================== numbers_list ======================= : [PASSED] delim=" " : [PASSED] delim=":" : [PASSED] delim="," : [PASSED] delim="-" : [PASSED] delim="/" : ================== [PASSED] numbers_list =================== : ============ numbers_list_field_width_typemax ============= : [PASSED] delim=" " : [PASSED] delim=":" : [PASSED] delim="," : [PASSED] delim="-" : [PASSED] delim="/" : ======== [PASSED] numbers_list_field_width_typemax ========= : =========== numbers_list_field_width_val_width ============ : [PASSED] delim=" " : [PASSED] delim=":" : [PASSED] delim="," : [PASSED] delim="-" : [PASSED] delim="/" : ======= [PASSED] numbers_list_field_width_val_width ======== : [PASSED] numbers_slice : [PASSED] numbers_prefix_overflow : [PASSED] test_simple_strtoull : [PASSED] test_simple_strtoll : [PASSED] test_simple_strtoul : [PASSED] test_simple_strtol : ====================== [PASSED] scanf ====================== : ============================================================ : Testing complete. Ran 22 tests: passed: 22 : Elapsed time: 5.517s total, 0.001s configuring, 5.440s building, 0.067s running - Link to v2: https://lore.kernel.org/r/20250203-scanf-kunit-convert-v2-1-277a618d804e@gmail.com Changes in v2: - Rename lib/{test_scanf.c => scanf_kunit.c}. (Andy Shevchenko) - Link to v1: https://lore.kernel.org/r/20250131-scanf-kunit-convert-v1-1-0976524f0eba@gmail.com --- Tamir Duberstein (6): scanf: implicate test line in failure messages scanf: remove redundant debug logs scanf: convert self-test to KUnit scanf: break kunit into test cases scanf: tidy header `#include`s scanf: further break kunit into test cases MAINTAINERS | 2 +- lib/Kconfig.debug | 12 +- lib/Makefile | 1 - lib/tests/Makefile | 1 + lib/{test_scanf.c => tests/scanf_kunit.c} | 360 ++++++++++++++++-------------- tools/testing/selftests/lib/Makefile | 2 +- tools/testing/selftests/lib/config | 1 - tools/testing/selftests/lib/scanf.sh | 4 - 8 files changed, 201 insertions(+), 182 deletions(-) --- base-commit: 7ec162622e66a4ff886f8f28712ea1b13069e1aa change-id: 20250131-scanf-kunit-convert-f70dc33bb34c Best regards,