Re: [PATCH v7 0/3] scanf: convert self-test to KUnit

Andy Shevchenko
2025-02-11T15:40:42Z

On Tue, Feb 11, 2025 at 10:13:36AM -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:
>
> $ tools/testing/kunit/kunit.py run --arch arm64 --make_options LLVM=1 scanf
>
> Signed-off-by: Tamir Duberstein <tamird@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:

It would be good if you put into cover letter, or even in the respectful patch
the example of the error report for the old code and new code that it will be
clear how it changes.

> 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:92
> 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:92
> 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:92
> 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:92
> vsscanf("403/0/17/1/11e7/1/1fe8/34ba", "%3hx/%1hx/%2hx/%1hx/%4hx/%1hx/%4hx/%4hx", ...) expected 65559 got 1507328
> not ok 5 "/"
> # numbers_list_field_width_val_width: pass:0 fail:5 skip:0 total:5
> not ok 4 numbers_list_field_width_val_width
> # numbers_slice: ASSERTION FAILED at lib/scanf_kunit.c:92
> vsscanf("3c87eac0f4afa1f9231da52", "%1hx%4hx%4hx%4hx%1hx%4hx%4hx%1hx", ...) expected 1257942031 got 2886715518

--
With Best Regards,
Andy Shevchenko