• [PATCH] Valgrind support for test suite

    From Simon Richter@21:1/5 to All on Sun Mar 17 00:40:02 2024
    ---
    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
  • From Guillem Jover@21:1/5 to All on Wed Mar 20 01:20:01 2024
    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