| 1 |
# valgrind-tests.m4 serial 3 |
| 2 |
dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. |
| 3 |
dnl This file is free software; the Free Software Foundation |
| 4 |
dnl gives unlimited permission to copy and/or distribute it, |
| 5 |
dnl with or without modifications, as long as this notice is preserved. |
| 6 |
|
| 7 |
dnl From Simon Josefsson |
| 8 |
|
| 9 |
# gl_VALGRIND_TESTS() |
| 10 |
# ------------------- |
| 11 |
# Check if valgrind is available, and set VALGRIND to it if available. |
| 12 |
AC_DEFUN([gl_VALGRIND_TESTS], |
| 13 |
[ |
| 14 |
AC_ARG_ENABLE(valgrind-tests, |
| 15 |
AS_HELP_STRING([--enable-valgrind-tests], |
| 16 |
[run self tests under valgrind]), |
| 17 |
[opt_valgrind_tests=$enableval], [opt_valgrind_tests=yes]) |
| 18 |
|
| 19 |
# Run self-tests under valgrind? |
| 20 |
if test "$opt_valgrind_tests" = "yes" && test "$cross_compiling" = no; then |
| 21 |
AC_CHECK_PROGS(VALGRIND, valgrind) |
| 22 |
fi |
| 23 |
|
| 24 |
OPTS="-q --error-exitcode=1 --leak-check=full" |
| 25 |
|
| 26 |
if test -n "$VALGRIND" \ |
| 27 |
&& $VALGRIND $OPTS $SHELL -c 'exit 0' > /dev/null 2>&1; then |
| 28 |
opt_valgrind_tests=yes |
| 29 |
VALGRIND="$VALGRIND $OPTS" |
| 30 |
else |
| 31 |
opt_valgrind_tests=no |
| 32 |
VALGRIND= |
| 33 |
fi |
| 34 |
|
| 35 |
AC_MSG_CHECKING([whether self tests are run under valgrind]) |
| 36 |
AC_MSG_RESULT($opt_valgrind_tests) |
| 37 |
]) |