On Mon 2025-02-10 13:23:21, Tamir Duberstein wrote: > This is one of just 3 remaining "Test Module" kselftests (the others > being bitmap and scanf), the rest having been converted to KUnit. > > I tested this using: > > $ tools/testing/kunit/kunit.py run --arch arm64 --make_options LLVM=1 printf > > I have also sent out a series converting scanf[0]. > > Link: > https://lore.kernel.org/all/20250204-scanf-kunit-convert-v3-0-386d7c3ee...@gmail.com/T/#u > [0] > > Signed-off-by: Tamir Duberstein <tam...@gmail.com>
I have just quickly tested this before leaving for a week. And I am fine with the result. I tried to simmulate an error. diff --git a/lib/test_printf.c b/lib/test_printf.c index 59dbe4f9a4cb..d2a1af31a540 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -590,7 +590,7 @@ time_and_date(void) test("15:32:23|0119-00-04", "%ptTtr|%ptTdr", &t, &t); test("2019-01-04 15:32:23", "%ptTs", &t); - test("0119-00-04 15:32:23", "%ptTsr", &t); + test("0119-00-04 15:32:24", "%ptTsr", &t); test("15:32:23|2019-01-04", "%ptTts|%ptTds", &t, &t); test("15:32:23|0119-00-04", "%ptTtrs|%ptTdrs", &t, &t); } The original result was: [ 787.626709] test_printf: loaded. [ 787.627398] test_printf: vsnprintf(buf, 256, "%ptTsr", ...) wrote '0119-00-04 15:32:23', expected '0119-00-04 15:32:24' [ 787.628496] test_printf: kvasprintf(..., "%ptTsr", ...) returned '0119-00-04 15:32:23', expected '0119-00-04 15:32:24' [ 787.629939] test_printf: failed 2 out of 448 tests The new output is: [ 585.652278] KTAP version 1 [ 585.652675] 1..1 [ 585.653085] KTAP version 1 [ 585.653382] # Subtest: printf [ 585.653702] # module: printf_kunit [ 585.653716] 1..28 [ 585.655223] ok 1 test_basic [ 585.655908] ok 2 test_number [ 585.656824] ok 3 test_string [ 585.657522] ok 4 hash_pointer [ 585.658547] ok 5 null_pointer [ 585.659572] ok 6 error_pointer [ 585.661057] ok 7 invalid_pointer [ 585.662290] ok 8 symbol_ptr [ 585.663390] ok 9 kernel_ptr [ 585.665162] ok 10 struct_resource [ 585.666231] ok 11 struct_range [ 585.667257] ok 12 addr [ 585.668399] ok 13 escaped_str [ 585.670212] ok 14 hex_string [ 585.671903] ok 15 mac [ 585.673389] ok 16 ip4 [ 585.674886] ok 17 ip6 [ 585.676255] ok 18 uuid [ 585.677875] ok 19 dentry [ 585.679138] ok 20 struct_va_format [ 585.679783] # time_and_date: EXPECTATION FAILED at lib/printf_kunit.c:97 vsnprintf(buf, 256, "%ptTsr", ...) wrote '0119-00-04 15:32:23', expected '0119-00-04 15:32:24' [ 585.680264] # time_and_date: EXPECTATION FAILED at lib/printf_kunit.c:135 kvasprintf(..., "%ptTsr", ...) returned '0119-00-04 15:32:23', expected '0119-00-04 15:32:24' [ 585.682436] not ok 21 time_and_date [ 585.683115] ok 22 struct_clk [ 585.685807] ok 23 bitmap [ 585.686576] ok 24 netdev_features [ 585.687243] ok 25 flags [ 585.687875] ok 26 errptr [ 585.688930] ok 27 fwnode_pointer [ 585.689544] ok 28 fourcc_pointer [ 585.689886] # printf: ran 448 tests [ 585.690215] # printf: pass:27 fail:1 skip:0 total:28 [ 585.690582] # Totals: pass:27 fail:1 skip:0 total:28 [ 585.691013] not ok 1 printf I still have to look at the implementation before I add an ack. And of course, I am also curious about what other reviewers think about it. And if this is OK for Rasmus. Best Regards, Petr