• Willy Tarreau's avatar
    selftests/nolibc: Add 7 tests for memcmp() · c80b5a0a
    Willy Tarreau authored
    
    
    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: default avatarWilly Tarreau <w@1wt.eu>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    c80b5a0a
nolibc-test.c 23.3 KB