diffutils/tests/strip-trailing-cr
Jim Meyering b33a919934 tests: strip-trailing-cr: avoid failure with ASAN
Valgrind cannot operate on an ASAN-compiled binary.
* tests/strip-trailing-cr (valgrind): Define as no-op when diff
was compiled with sanitizer support.
2018-12-29 08:14:03 -08:00

26 lines
593 B
Bash
Executable File

#!/bin/sh
# Before diff-3.7, this would provoke a UMR
. "${srcdir=.}/init.sh"; path_prepend_ ../src
fail=0
require_valgrind_
printf '\r' > r || framework_failure_
echo b > b || framework_failure_
# Use valgrind only when no Sanitizer is in use:
ASAN_OPTIONS=help=true diff --help 2>&1 |grep Sanitizer > /dev/null \
&& eval 'valgrind() { "$@"; }' \
|| eval 'valgrind() { env valgrind --quiet --error-exitcode=3 "$@"; }'
for opt in '' u c Dfoo; do
returns_ 1 valgrind \
diff -a$opt --strip-trailing-cr r b > out 2> err || fail=1
done
compare /dev/null err || fail=1
Exit $fail