Re: [PATCH v2 next 10/11] selftests/nolibc: Increase coverage of printf format tests
From: Thomas Weißschuh
Date: Wed Feb 18 2026 - 12:41:48 EST
On 2026-02-16 22:54:15+0000, David Laight wrote:
> On Mon, 16 Feb 2026 21:23:50 +0100
> Thomas Weißschuh <linux@xxxxxxxxxxxxxx> wrote:
>
> > On 2026-02-06 19:11:20+0000, david.laight.linux@xxxxxxxxx wrote:
> > > From: David Laight <david.laight.linux@xxxxxxxxx>
> > >
> > > Extra tests include:
> > > - %%, including ignored modifiers.
> > > - Invalid formats copied to output buffer (matches glibc).
> > > - Left aligned output "%-..."
> > > - Zero padding "%0...".
> > > - "(nil)" for NULL pointers (matches glibc).
> > > - Alternate form "%#x" (prepends 0x in non-zero).
> > > - Field precision as well as width, printf("%.0d", 0) is "".
> > > - Variable length width and precision "%*.*d".
> > > - Length qualifiers L and ll.
> > > - Conversion specifiers i and X.
> > > - More 'corner' cases.
> > >
> > > There are no explicit tests of long (l, t or z) because they would
> > > have to differ between 32bit and 64bit.
> > >
> > > Set the expected length to zero for all the non-truncating tests.
> > > (Annoying when a test is changed.)
> > >
> > > Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>
> > > ---
> > >
> > > Changes for v2:
> > > - Formally patch 11.
> > > - Remove broken __attribute__ on expect_vfprintf().
> > > - Add extra test for "#01x".
> > >
> > > tools/testing/selftests/nolibc/nolibc-test.c | 49 +++++++++++++++-----
> > > 1 file changed, 37 insertions(+), 12 deletions(-)
> >
> > (...)
> >
> > > + CASE_TEST(num_pad_trunc);EXPECT_VFPRINTF(40, " 0000000000", "%040d", 5); break; /* max 30 '0' can be added */
> >
> > This fails in 'libc-test' with glibc and musl:
> >
> > 32 num_pad_trunc "00000000000000000000" should be " 0000000000" [FAIL]
>
> I've a plan for that - the test needs skipping.
> I can use a -40 to avoid another parameter.
No magic negative numbers please. Introduce EXPECT_VFPRINTF_COND() which
takes an additional condition parameter.
Thomas