summaryrefslogtreecommitdiff
path: root/m4/ax_valgrind_check.m4
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2017-09-26 02:33:21 +0300
committerPeter Simons <simons@cryp.to>2017-09-27 16:43:00 +0200
commitf6fc9a8162a845847beaa3caeba498fa348beed1 (patch)
tree852b912eab4b196d6c57808b516d9bb622ba3bb0 /m4/ax_valgrind_check.m4
parent37a75750d646bf578c281ca1be18e8a29bb7cc73 (diff)
downloadautoconf-archive-f6fc9a8162a845847beaa3caeba498fa348beed1.tar.gz
ax_valgrind_check: run check-valgrind recursively
Switch check-valgrind and check-valgrind-$TOOL into recursive Automake targets. It is still required to put @VALGRIND_CHECK_RULES@ into each directory with tests, but it is now possible to run `make check-valgrind' from top-level directory. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Diffstat (limited to 'm4/ax_valgrind_check.m4')
-rw-r--r--m4/ax_valgrind_check.m432
1 files changed, 18 insertions, 14 deletions
diff --git a/m4/ax_valgrind_check.m4 b/m4/ax_valgrind_check.m4
index 1c1c0cd..6b4b29a 100644
--- a/m4/ax_valgrind_check.m4
+++ b/m4/ax_valgrind_check.m4
@@ -36,21 +36,19 @@
# AX_VALGRIND_DFLT([sgcheck], [off])
# AX_VALGRIND_CHECK
#
-# Makefile.am:
+# in each Makefile.am with tests:
#
# @VALGRIND_CHECK_RULES@
# VALGRIND_SUPPRESSIONS_FILES = my-project.supp
# EXTRA_DIST = my-project.supp
#
-# This results in a "check-valgrind" rule being added to any Makefile.am
-# which includes "@VALGRIND_CHECK_RULES@" (assuming the module has been
-# configured with --enable-valgrind). Running `make check-valgrind` in
-# that directory will run the module's test suite (`make check`) once for
-# each of the available Valgrind tools (out of memcheck, helgrind and drd)
-# while the sgcheck will be skipped unless enabled again on the
-# commandline with --enable-valgrind-sgcheck. The results for each check
-# will be output to test-suite-$toolname.log. The target will succeed if
-# there are zero errors and fail otherwise.
+# This results in a "check-valgrind" rule being added. Running `make
+# check-valgrind` in that directory will recursively run the module's test
+# suite (`make check`) once for each of the available Valgrind tools (out
+# of memcheck, helgrind and drd) while the sgcheck will be skipped unless
+# enabled again on the commandline with --enable-valgrind-sgcheck. The
+# results for each check will be output to test-suite-$toolname.log. The
+# target will succeed if there are zero errors and fail otherwise.
#
# Alternatively, a "check-valgrind-$TOOL" rule will be added, for $TOOL in
# memcheck, helgrind, drd and sgcheck. These are useful because often only
@@ -67,7 +65,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 15
+#serial 16
dnl Configured tools
m4_define([valgrind_tool_list], [[memcheck], [helgrind], [drd], [sgcheck]])
@@ -79,6 +77,10 @@ AC_DEFUN([AX_VALGRIND_DFLT],[
m4_define([en_dflt_valgrind_$1], [$2])
])dnl
+AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
+m4_foreach([vgtool], [valgrind_tool_list],
+ [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
+
AC_DEFUN([AX_VALGRIND_CHECK],[
dnl Check for --enable-valgrind
AC_ARG_ENABLE([valgrind],
@@ -175,7 +177,7 @@ valgrind_quiet_ = $(valgrind_quiet_$(AM_DEFAULT_VERBOSITY))
valgrind_quiet_0 = --quiet
valgrind_v_use = $(valgrind_v_use_$(V))
valgrind_v_use_ = $(valgrind_v_use_$(AM_DEFAULT_VERBOSITY))
-valgrind_v_use_0 = @echo " USE " $(patsubst check-valgrind-%,%,$''@):;
+valgrind_v_use_0 = @echo " USE " $(patsubst check-valgrind-%-am,%,$''@):;
# Support running with and without libtool.
ifneq ($(LIBTOOL),)
@@ -185,7 +187,7 @@ valgrind_lt =
endif
# Use recursive makes in order to ignore errors during check
-check-valgrind:
+check-valgrind-am:
ifeq ($(VALGRIND_ENABLED),yes)
$(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) -k \
$(foreach tool, $(valgrind_enabled_tools), check-valgrind-$(tool))
@@ -205,13 +207,15 @@ VALGRIND_LOG_COMPILER = \
$(VALGRIND) $(VALGRIND_SUPPRESSIONS) --error-exitcode=1 $(VALGRIND_FLAGS)
define valgrind_tool_rule =
-check-valgrind-$(1):
+check-valgrind-$(1)-am:
ifeq ($$(VALGRIND_ENABLED)-$$(ENABLE_VALGRIND_$(1)),yes-yes)
+ifneq ($$(TESTS),)
$$(valgrind_v_use)$$(MAKE) check-TESTS \
TESTS_ENVIRONMENT="$$(VALGRIND_TESTS_ENVIRONMENT)" \
LOG_COMPILER="$$(VALGRIND_LOG_COMPILER)" \
LOG_FLAGS="$$(valgrind_$(1)_flags)" \
TEST_SUITE_LOG=test-suite-$(1).log
+endif
else ifeq ($$(VALGRIND_ENABLED),yes)
@echo "Need to reconfigure with --enable-valgrind-$(1)"
else