From bea215ed20cfcf5425e74b7492bf9cbecb087bd4 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Tue, 29 Jul 2025 11:28:23 +0200 Subject: [PATCH 1/2] build: add valgrind test option to build script Add the option -x which tells the script to run the tests under valgrind. Signed-off-by: Daniel Wagner --- scripts/build.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index c4849e70d..cf28df6a9 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -13,6 +13,7 @@ usage() { echo " -c [gcc]|clang compiler to use" echo " -m [meson]|muon use meson or muon" echo " -t [armhf]|ppc64le|s390x cross compile target" + echo " -x run test with valgrind" echo "" echo "configs with meson:" echo " [default] default settings" @@ -33,7 +34,9 @@ BUILDTYPE=release CROSS_TARGET=armhf CC=${CC:-"gcc"} -while getopts "b:c:m:t:" o; do +use_valgrind=0 + +while getopts "b:c:m:t:x" o; do case "${o}" in b) BUILDTYPE="${OPTARG}" @@ -47,6 +50,9 @@ while getopts "b:c:m:t:" o; do t) CROSS_TARGET="${OPTARG}" ;; + x) + use_valgrind=1 + ;; *) usage exit 1 @@ -125,8 +131,17 @@ build_meson() { } test_meson() { - "${MESON}" test \ - -C "${BUILDDIR}" + local args=(-C "${BUILDDIR}") + + if [ "${use_valgrind:-0}" -eq 1 ]; then + if command -v valgrind >/dev/null 2>&1; then + args+=(--wrapper valgrind) + else + echo "Warning: valgrind requested but not found; running without it." >&2 + fi + fi + + "${MESON}" test "${args[@]}" } test_meson_coverage() { From 058429ac7c16fdc85e23d65de47fdb4506022ee1 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Tue, 29 Jul 2025 11:31:14 +0200 Subject: [PATCH 2/2] build: run tests with valgrind for default builds Let's try to catch memory leaks early by enabling the default builds to run their tests with valgrind enabled. Signed-off-by: Daniel Wagner --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10a358a84..d9c678da5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v4 - name: build run: | - scripts/build.sh -b ${{ matrix.buildtype }} -c ${{ matrix.compiler }} + scripts/build.sh -b ${{ matrix.buildtype }} -c ${{ matrix.compiler }} -x - uses: actions/upload-artifact@v4 name: upload logs if: failure()