[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [PATCH] Valgrind support for test suite



Hi!

Thanks for the patch!

I was playing with this the other day, and slightly simplified the patch
as the one attached. But then I wondered whether this makes sense at all,
given that the test suite should be able to run with the leak sanitizer
support, which I've just fixed so that it does not abort the tests and
enabled it by default now again in the CI, matching now the behavior for
the valgrind support (which is non-fatal). In comparison valgrind seems
rather slow against the sanitizer runs. I mean, I guess this can be
merged, but I'm not sure there's much advantage? (Or perhaps just the
wrapper scaffolding, which could be useful for other things, such as
cachegrind, callgrind or massif or similar.)

Thanks,
Guillem
From a079c939bb4c565afb3c19d2eb6f5797836c1236 Mon Sep 17 00:00:00 2001
From: Simon Richter <sjr@debian.org>
Date: Sun, 17 Mar 2024 08:39:21 +0900
Subject: [PATCH] test: Add valgrind support for test suite

[guillem@debian.org:
 - Only export DPKG_WRAPPER in the memtest target.
 - Improve code comment.
 - Make the memtest target depend on test. ]

Signed-off-by: Guillem Jover <guillem@debian.org>
---
 tests/Makefile |  3 +++
 tests/Test.mk  | 15 +++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index bdd9dd318..e50a77d77 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -140,6 +140,9 @@ 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:: test
+
 installtest: $(test_targets)
 
 .PHONY: test $(test_targets)
diff --git a/tests/Test.mk b/tests/Test.mk
index a830d5d49..82b65bc55 100644
--- a/tests/Test.mk
+++ b/tests/Test.mk
@@ -21,6 +21,9 @@ ifdef DPKG_BUILDTREE
 DPKG_PATH := $(DPKG_BUILDTREE)/src:$(DPKG_BUILDTREE)/utils:$(DPKG_BUILDTREE)/scripts:$(DPKG_PATH)
 endif
 
+# Wrapper support, to be used for valgrind for example.
+DPKG_WRAPPER ?=
+
 DPKG_ENV = \
   PATH=$(DPKG_PATH) \
   $(DPKG_MAINTSCRIPT_DEBUG)
@@ -80,21 +83,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
 
-- 
2.43.0


Reply to: