[PATCH] Valgrind support for test suite

Simon Richter <[email protected]>
Newsgroups gmane.linux.debian.devel.dpkg.general
Message-ID <[email protected]>
---
 tests/Makefile |  4 ++++
 tests/Test.mk  | 17 +++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index 5d8309608..5d3f30ee2 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -141,6 +141,10 @@ test:: $(test_targets)
 $(test_targets)::
 	$(MAKE) -C $(subst -test,,$@) test
 
+memtest:: export DPKG_WRAPPER=valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes
+memtest:: export DPKG_BUILDTREE=$(realpath ..)
+memtest:: $(test_targets)
+
 installtest: $(test_targets)
 
 .PHONY: test $(test_targets)
diff --git a/tests/Test.mk b/tests/Test.mk
index 3c020af2c..1f46a59af 100644
--- a/tests/Test.mk
+++ b/tests/Test.mk
@@ -21,6 +21,11 @@ ifdef DPKG_BUILDTREE
 DPKG_PATH := $(DPKG_BUILDTREE)/src:$(DPKG_BUILDTREE)/utils:$(DPKG_BUILDTREE)/scripts:$(DPKG_PATH)
 endif
 
+## Wrapper support (default none) ##
+
+DPKG_WRAPPER ?=
+export DPKG_WRAPPER
+
 DPKG_ENV = \
   PATH=$(DPKG_PATH) \
   $(DPKG_MAINTSCRIPT_DEBUG)
@@ -77,21 +82,21 @@ endif
 DPKG_ADMINDIR = $(CURDIR)/../dpkgdb
 DPKG_COMMON_OPTIONS = --admindir="$(DPKG_ADMINDIR)"
 
-DPKG = dpkg $(DPKG_COMMON_OPTIONS) $(DPKG_OPTIONS)
+DPKG = $(DPKG_WRAPPER) dpkg $(DPKG_COMMON_OPTIONS) $(DPKG_OPTIONS)
 DPKG_INSTALL = $(BEROOT) $(DPKG) -i
 DPKG_UNPACK = $(BEROOT) $(DPKG) --unpack
 DPKG_CONFIGURE = $(BEROOT) $(DPKG) --configure
 DPKG_REMOVE = $(BEROOT) $(DPKG) -r
 DPKG_PURGE = $(BEROOT) $(DPKG) -P
 DPKG_VERIFY = $(DPKG) -V
-DPKG_DEB = dpkg-deb $(DPKG_DEB_OPTIONS)
-DPKG_DIVERT = dpkg-divert $(DPKG_COMMON_OPTIONS) $(DPKG_DIVERT_OPTIONS)
+DPKG_DEB = $(DPKG_WRAPPER) dpkg-deb $(DPKG_DEB_OPTIONS)
+DPKG_DIVERT = $(DPKG_WRAPPER) dpkg-divert $(DPKG_COMMON_OPTIONS) $(DPKG_DIVERT_OPTIONS)
 DPKG_DIVERT_ADD = $(BEROOT) $(DPKG_DIVERT) --add
 DPKG_DIVERT_DEL = $(BEROOT) $(DPKG_DIVERT) --remove
-DPKG_SPLIT = dpkg-split $(DPKG_SPLIT_OPTIONS)
+DPKG_SPLIT = $(DPKG_WRAPPER) dpkg-split $(DPKG_SPLIT_OPTIONS)
 DPKG_BUILD_DEB = $(DPKG_DEB) -b
-DPKG_QUERY = dpkg-query $(DPKG_COMMON_OPTIONS) $(DPKG_QUERY_OPTIONS)
-DPKG_TRIGGER = dpkg-trigger $(DPKG_COMMON_OPTIONS) $(DPKG_TRIGGER_OPTIONS)
+DPKG_QUERY = $(DPKG_WRAPPER) dpkg-query $(DPKG_COMMON_OPTIONS) $(DPKG_QUERY_OPTIONS)
+DPKG_TRIGGER = $(DPKG_WRAPPER) dpkg-trigger $(DPKG_COMMON_OPTIONS) $(DPKG_TRIGGER_OPTIONS)
 
 PKG_STATUS = $(DPKG_QUERY) -f '$${Status}' -W
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.