view tests/test-verify.sh @ 40214:452ab00796c7

Fix undefined behaviour. * lib/bitrotate.h (rotl16, rotr16, rotl8, rotr8): Case x to 'unsigned int', to avoid shift operations on 'int'. * lib/xmemdup0.c (xmemdup0): Don't invoke memcpy with a zero size. * tests/test-count-leading-zeros.c (main): Use a random number that has as many bits as TYPE, not only 2*15 or 2*31 bits. * tests/test-count-trailing-zeros.c (main): Likewise. * tests/test-count-one-bits.c (main): Likewise. * tests/test-memmem.c: Don't include "null-ptr.h". (main): Use zerosize_ptr() instead of null_ptr(). * modules/memmem-tests (Files): Remove tests/null-ptr.h.
author Bruno Haible <bruno@clisp.org>
date Sat, 09 Mar 2019 20:32:25 +0100
parents f2fc38f20336
children
line wrap: on
line source

#!/bin/sh
. "${srcdir=.}/init.sh"

# We are not interested in triggering bugs in the compilers and tools
# (such as gcc 4.3.1 on openSUSE 11.0).
unset MALLOC_PERTURB_

# Rather than figure out how to invoke the compiler with the right
# include path ourselves, we let make do it:
(cd "$initial_cwd_" \
 && rm -f test-verify-try.o \
 && $MAKE test-verify-try.o >/dev/null 2>&1) \
  || skip_ "cannot compile error-free"

# Now, prove that we encounter all expected compilation failures:
: >out
: >err
for i in 1 2 3 4 5; do
  (cd "$initial_cwd_"
   rm -f test-verify-try.o
   $MAKE CFLAGS=-DEXP_FAIL=$i test-verify-try.o) >>out 2>>err \
  && { warn_ "compiler didn't detect verification failure $i"; fail=1; }
done

Exit $fail