]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/nolibc: Use length of 'expected' string to check snprintf() output
authorDavid Laight <david.laight.linux@gmail.com>
Mon, 2 Mar 2026 10:17:57 +0000 (10:17 +0000)
committerThomas Weißschuh <linux@weissschuh.net>
Fri, 20 Mar 2026 16:46:03 +0000 (17:46 +0100)
commitf36e1ec61a6adb135d1b4021bc849c6acb96f50c
treedfa98efc031faf260bc43785ebff6619ebb0fbe7
parent9aa8a4afd4e6407a4d4521c325855c4467a88b73
selftests/nolibc: Use length of 'expected' string to check snprintf() output

Instead of requiring the test cases specifying both the length and
expected output, take the length from the expected output.
Tests that expect the output be truncated are changed to specify
the un-truncated output.

Change the strncmp() to a memcmp() with an extra check that the
output is actually terminated.

Append a '+' to the printed output (after the final ") when the output
is truncated.

Signed-off-by: David Laight <david.laight.linux@gmail.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260302101815.3043-6-david.laight.linux@gmail.com
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
tools/testing/selftests/nolibc/nolibc-test.c