build: use a helper script for all valgrind tests

This commit is contained in:
Pavel Šimerda 2013-07-26 14:16:47 +02:00
parent 7b2a4054b0
commit b38f76cdb4
3 changed files with 29 additions and 1 deletions

2
.gitignore vendored
View file

@ -36,6 +36,8 @@ INSTALL
ABOUT-NLS
*.pc
cscope.*out
valgrind-*.log
man/*.[185]
man/nm-settings.xml
po/*.gmo

View file

@ -646,7 +646,7 @@ AS_IF([test "$with_valgrind" == "yes"],
AM_CONDITIONAL(ENABLE_TESTS, test "$enable_tests" != "no")
AM_CONDITIONAL(RUN_ROOT_TESTS, test "$enable_tests" == "root")
AS_IF([test "$with_valgrind" != "no"],
AC_SUBST(VALGRIND_RULES, "TESTS_ENVIRONMENT = G_SLICE=always-malloc G_DEBUG=gc-friendly \$(LIBTOOL) --mode=execute $with_valgrind --quiet --error-exitcode=1 --leak-check=full --gen-suppressions=all --suppressions=\$(top_srcdir)/valgrind.suppressions"),
AC_SUBST(VALGRIND_RULES, 'TESTS_ENVIRONMENT = "$(top_srcdir)/tools/run-test-valgrind.sh" "$(LIBTOOL)" "$(with_valgrind)" "$(top_srcdir)/valgrind.suppressions"'),
AC_SUBST(VALGRIND_RULES, []))
GTK_DOC_CHECK(1.0)

26
tools/run-test-valgrind.sh Executable file
View file

@ -0,0 +1,26 @@
#!/bin/sh
LIBTOOL="$1"; shift
VALGRIND="$1"; shift
SUPPRESSIONS="$1"; shift
TEST="$1"; shift
LOGFILE="valgrind-`echo "$TEST" | tr -cd '[:alpha:]-'`.log"
export G_SLICE=always-malloc
export G_DEBUG=gc-friendly
$LIBTOOL --mode=execute "$VALGRIND" \
--quiet \
--error-exitcode=1 \
--leak-check=full \
--gen-suppressions=all \
--suppressions="$SUPPRESSIONS" \
--log-file="$LOGFILE" \
"$TEST"
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "Don't forget to check the valgrind log at '$LOGFILE'." >&2
fi
exit $RESULT