+2021-01-02 Bruno Haible <bruno@clisp.org>
+
+ valgrind-tests: Disable valgrind if it would cause all tests to fail.
+ Suggested by Simon Josefsson <simon@josefsson.org> in
+ <https://lists.gnu.org/archive/html/help-gsasl/2021-01/msg00004.html>.
+ * m4/valgrind-tests.m4 (gl_VALGRIND_TESTS): Test $VALGRIND on an
+ executable produced by the current compiler. Set VALGRIND to empty if it
+ does not work. Don't set VALGRIND to empty if it merely does not accept
+ the --error-exitcode=1 --leak-check=full options.
+
2021-01-02 Bruno Haible <bruno@clisp.org>
valgrind-tests: Really enable the valgrind options test.
-# valgrind-tests.m4 serial 5
+# valgrind-tests.m4 serial 6
dnl Copyright (C) 2008-2021 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
if test "$opt_valgrind_tests" = "yes" && test "$cross_compiling" = no; then
AC_CHECK_PROGS([VALGRIND], [valgrind])
- if test "$VALGRIND"; then
+ if test -n "$VALGRIND"; then
+ dnl On Ubuntu 16.04, /usr/bin/valgrind works only on 64-bit executables
+ dnl but fails on 32-bit executables (with exit code 1) and on x86_64-x32
+ dnl executables (with exit code 126).
+ AC_CACHE_CHECK([whether valgrind works on executables produced by the compiler],
+ [gl_cv_prog_valgrind_works],
+ [AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[int main () { return 0; }]])],
+ [$VALGRIND ./conftest$ac_exeext 2>/dev/null
+ if test $? = 0; then
+ gl_cv_prog_valgrind_works=yes
+ else
+ gl_cv_prog_valgrind_works=no
+ fi
+ ],
+ [gl_cv_prog_valgrind_works=no])
+ ])
+ if test $gl_cv_prog_valgrind_works != yes; then
+ VALGRIND=
+ fi
+ fi
+
+ if test -n "$VALGRIND"; then
AC_CACHE_CHECK([for valgrind options for tests],
[gl_cv_opt_valgrind_tests],
[gl_valgrind_opts='-q --error-exitcode=1 --leak-check=full'
])
if test "$gl_cv_opt_valgrind_tests" != no; then
VALGRIND="$VALGRIND $gl_cv_opt_valgrind_tests"
- else
- VALGRIND=
fi
fi
fi