selftests/nolibc: Add 7 tests for memcmp()
authorWilly Tarreau <w@1wt.eu>
Fri, 21 Oct 2022 06:03:40 +0000 (08:03 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Fri, 28 Oct 2022 22:17:22 +0000 (15:17 -0700)
commitc80b5a0a22b673d5a02e64626a8dfc2f738be7d9
treefe958a285adaee54e1931e2cd6d013b628971df1
parentb3f4f51ea68a495f8a5956064c33dce711a2df91
selftests/nolibc: Add 7 tests for memcmp()

This adds 7 combinations of input values for memcmp() using signed and
unsigned bytes, which will trigger on the original code before Rasmus'
fix. This is mostly aimed at helping backporters verify their work, and
showing how tests for corner cases can be added to the selftests suite.

Before the fix it reports:
  12 memcmp_20_20 = 0                      [OK]
  13 memcmp_20_60 = -64                    [OK]
  14 memcmp_60_20 = 64                     [OK]
  15 memcmp_20_e0 = 64                    [FAIL]
  16 memcmp_e0_20 = -64                   [FAIL]
  17 memcmp_80_e0 = -96                    [OK]
  18 memcmp_e0_80 = 96                     [OK]

And after:
  12 memcmp_20_20 = 0                      [OK]
  13 memcmp_20_60 = -64                    [OK]
  14 memcmp_60_20 = 64                     [OK]
  15 memcmp_20_e0 = -192                   [OK]
  16 memcmp_e0_20 = 192                    [OK]
  17 memcmp_80_e0 = -96                    [OK]
  18 memcmp_e0_80 = 96                     [OK]

Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/testing/selftests/nolibc/nolibc-test.c