All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Tamir Duberstein <tamird@gmail.com>
Cc: David Gow <davidgow@google.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Shuah Khan <shuah@kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v6 2/2] scanf: break kunit into test cases
Date: Tue, 11 Feb 2025 12:54:02 +0100	[thread overview]
Message-ID: <Z6s6WsIw3VCGys6K@pathway.suse.cz> (raw)
In-Reply-To: <20250210-scanf-kunit-convert-v6-2-4d583d07f92d@gmail.com>

On Mon 2025-02-10 13:13:49, Tamir Duberstein wrote:
> Use `suite_init` and move some tests into `scanf_test_cases`. This
> gives us nicer output in the event of a failure.

Hmm, simulate the following failure in the original test module:


diff --git a/lib/test_scanf.c b/lib/test_scanf.c
index 44f8508c9d88..3ec12328cc4c 100644
--- a/lib/test_scanf.c
+++ b/lib/test_scanf.c
@@ -564,7 +564,7 @@ static void __init numbers_list_field_width_val_h(const char *delim)
 	numbers_list_val_width(unsigned short,	"%hu",	     delim, "hu", check_ushort);
 	numbers_list_val_width(short,		"%hd",	     delim, "hd", check_short);
 	numbers_list_val_width(short,		"%hd",	     delim, "hi", check_short);
-	numbers_list_val_width(unsigned short,	"%hx",	     delim, "hx", check_ushort);
+	numbers_list_val_width(unsigned short,	"%hx",	     delim, "hx", check_uint);
 	numbers_list_val_width(unsigned short,	"0x%hx",     delim, "hx", check_ushort);
 	numbers_list_val_width(short,		"0x%hx",     delim, "hi", check_short);
 }

and I got:


[  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


When I tried to do the same in the new module:

diff --git a/lib/scanf_kunit.c b/lib/scanf_kunit.c
index e45f3c4f0437..692eb8cbbeab 100644
--- a/lib/scanf_kunit.c
+++ b/lib/scanf_kunit.c
@@ -546,7 +546,7 @@ static void numbers_list_field_width_val_h(struct kunit *test, const char *delim
 	numbers_list_val_width(unsigned short,	"%hu",	     delim, "hu", check_ushort);
 	numbers_list_val_width(short,		"%hd",	     delim, "hd", check_short);
 	numbers_list_val_width(short,		"%hd",	     delim, "hi", check_short);
-	numbers_list_val_width(unsigned short,	"%hx",	     delim, "hx", check_ushort);
+	numbers_list_val_width(unsigned short,	"%hx",	     delim, "hx", check_uint);
 	numbers_list_val_width(unsigned short,	"0x%hx",     delim, "hx", check_ushort);
 	numbers_list_val_width(short,		"0x%hx",     delim, "hi", check_short);
 }

then I got:

[ 6625.895391] KTAP version 1
[ 6625.895928] 1..1
[ 6625.896494]     KTAP version 1
[ 6625.896852]     # Subtest: scanf
[ 6625.897191]     # module: scanf_kunit
[ 6625.897198]     1..10
[ 6625.903479]     ok 1 numbers_simple
[ 6625.903490]         KTAP version 1
[ 6625.904352]         # Subtest: numbers_list
[ 6625.905623]         ok 1 " "
[ 6625.907654]         ok 2 ":"
[ 6625.909654]         ok 3 ","
[ 6625.911564]         ok 4 "-"
[ 6625.913632]         ok 5 "/"
[ 6625.914020]     # numbers_list: pass:5 fail:0 skip:0 total:5
[ 6625.914370]     ok 2 numbers_list
[ 6625.914964]         KTAP version 1
[ 6625.915871]         # Subtest: numbers_list_field_width_typemax
[ 6625.917527]         ok 1 " "
[ 6625.919366]         ok 2 ":"
[ 6625.921586]         ok 3 ","
[ 6625.923240]         ok 4 "-"
[ 6625.925226]         ok 5 "/"
[ 6625.925622]     # numbers_list_field_width_typemax: pass:5 fail:0 skip:0 total:5
[ 6625.925973]     ok 3 numbers_list_field_width_typemax
[ 6625.926709]         KTAP version 1
[ 6625.927613]         # Subtest: numbers_list_field_width_val_width
[ 6625.928546]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1044578334 (0x3e43001e)
                       *pval == 837828163 (0x31f03e43)
               vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.929225]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 837828163 (0x31f03e43)
                       *pval == 0 (0x0)
               vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.932202]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 12784 (0x31f0)
                       *pval == 2624608151 (0x9c705797)
               vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.934982]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 0 (0x0)
                       *pval == 1966080 (0x1e0000)
               vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.935004]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1469513728 (0x57970000)
                       *pval == 837828163 (0x31f03e43)
               vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.935025]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 2624608151 (0x9c705797)
                       *pval == 0 (0x0)
               vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.935046]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 469802096 (0x1c009c70)
                       *pval == 2624608151 (0x9c705797)
               vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.938161]         not ok 1 " "
[ 6625.952074]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 131073 (0x20001)
                       *pval == 65538 (0x10002)
               vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.952098]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 65538 (0x10002)
                       *pval == 1038822 (0xfd9e6)
               vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.952121]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 3655729153 (0xd9e60001)
                       *pval == 3848735038 (0xe567093e)
               vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.952143]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1038822 (0xfd9e6)
                       *pval == 65542 (0x10006)
               vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.960548]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 155058191 (0x93e000f)
                       *pval == 65538 (0x10002)
               vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.960579]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 3848735038 (0xe567093e)
                       *pval == 1038822 (0xfd9e6)
               vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.960604]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 50390375 (0x300e567)
                       *pval == 3848735038 (0xe567093e)
               vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.969351]         not ok 2 ":"
[ 6625.969860]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 3589275648 (0xd5f00000)
                       *pval == 3768047088 (0xe097d5f0)
               vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.972121]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 3768047088 (0xe097d5f0)
                       *pval == 878575619 (0x345e0003)
               vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.972139]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 254103 (0x3e097)
                       *pval == 2832859455 (0xa8da013f)
               vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.976800]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 878575619 (0x345e0003)
                       *pval == 0 (0x0)
               vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.976819]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 20919390 (0x13f345e)
                       *pval == 3768047088 (0xe097d5f0)
               vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.976836]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 2832859455 (0xa8da013f)
                       *pval == 878575619 (0x345e0003)
               vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.976853]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 3691030746 (0xdc00a8da)
                       *pval == 2832859455 (0xa8da013f)
               vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.979505]         not ok 3 ","
[ 6625.989303]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1475084289 (0x57ec0001)
                       *pval == 3243268076 (0xc15057ec)
               vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.989324]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 3243268076 (0xc15057ec)
                       *pval == 21 (0x15)
               vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.989343]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1425744 (0x15c150)
                       *pval == 786439 (0xc0007)
               vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.994177]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 21 (0x15)
                       *pval == 65537 (0x10001)
               vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.994196]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 458752 (0x70000)
                       *pval == 3243268076 (0xc15057ec)
               vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.994214]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 786439 (0xc0007)
                       *pval == 21 (0x15)
               vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.994232]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 3858759692 (0xe600000c)
                       *pval == 786439 (0xc0007)
               vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6626.003487]         not ok 4 "-"
[ 6626.004021]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 3901554741 (0xe88d0035)
                       *pval == 125069 (0x1e88d)
               vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.006206]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 125069 (0x1e88d)
                       *pval == 1821114368 (0x6c8c0000)
               vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.006226]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1 (0x1)
                       *pval == 65543 (0x10007)
               vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.006243]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1821114368 (0x6c8c0000)
                       *pval == 3502806 (0x3572d6)
               vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.006261]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 486540 (0x76c8c)
                       *pval == 125069 (0x1e88d)
               vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.015404]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 65543 (0x10007)
                       *pval == 1821114368 (0x6c8c0000)
               vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.015423]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1828716545 (0x6d000001)
                       *pval == 65543 (0x10007)
               vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.018041]         not ok 5 "/"
[ 6626.022529]     # numbers_list_field_width_val_width: pass:0 fail:5 skip:0 total:5
[ 6626.022535]     not ok 4 numbers_list_field_width_val_width
[ 6626.023220]     # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 106936 (0x1a1b8)
                       *pval == 571539457 (0x22110001)
               vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024017]     # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 571539457 (0x22110001)
                       *pval == 81562 (0x13e9a)
               vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024035]     # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1050288657 (0x3e9a2211)
                       *pval == 91449567 (0x57368df)
               vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024053]     # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 81562 (0x13e9a)
                       *pval == 2713242046 (0xa1b8c9be)
               vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024073]     # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1759444993 (0x68df0001)
                       *pval == 571539457 (0x22110001)
               vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024091]     # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 91449567 (0x57368df)
                       *pval == 81562 (0x13e9a)
               vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024108]     # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1107297651 (0x42000573)
                       *pval == 91449567 (0x57368df)
               vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.026607]     not ok 5 numbers_slice
[ 6626.039801]     ok 6 numbers_prefix_overflow
[ 6626.040522]     ok 7 test_simple_strtoull
[ 6626.041433]     ok 8 test_simple_strtoll
[ 6626.042409]     ok 9 test_simple_strtoul
[ 6626.043153]     ok 10 test_simple_strtol
[ 6626.043161] # scanf: pass:8 fail:2 skip:0 total:10
[ 6626.043166] # Totals: pass:16 fail:6 skip:0 total:22
[ 6626.043170] not ok 1 scanf


I like that the log better points to the test:

[ 6625.927613]         # Subtest: numbers_list_field_width_val_width

But

[ 6625.928546]     # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
                   Expected got == *pval, but
                       got == 1044578334 (0x3e43001e)
                       *pval == 837828163 (0x31f03e43)
               vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)

is much harder to parse than the original

[  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


Also I wonder why the scanned string is different:

               vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
vs.

[  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
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I would expect that the 1st error would be on the same string
in both tests. I wonder why it differs.

Best Regards,
Petr

  reply	other threads:[~2025-02-11 11:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-10 18:13 [PATCH v6 0/2] scanf: convert self-test to KUnit Tamir Duberstein
2025-02-10 18:13 ` [PATCH v6 1/2] " Tamir Duberstein
2025-02-11 11:37   ` Petr Mladek
2025-02-11 11:45     ` Tamir Duberstein
2025-02-11 12:15       ` Andy Shevchenko
2025-02-11 14:48         ` Tamir Duberstein
2025-02-11 16:06       ` Petr Mladek
2025-02-11 16:08         ` Tamir Duberstein
2025-02-10 18:13 ` [PATCH v6 2/2] scanf: break kunit into test cases Tamir Duberstein
2025-02-11 11:54   ` Petr Mladek [this message]
2025-02-11 15:11     ` Tamir Duberstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z6s6WsIw3VCGys6K@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=davidgow@google.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=shuah@kernel.org \
    --cc=tamird@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.