diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a52f129c24..58e2fd0e45 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() diff --git a/scripts/build.sh b/scripts/build.sh index 3b70f801d5..33a32acf00 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 [arm]|ppc64le|s390x cross compile target" + echo " -x run test with valgrind" echo "" echo "configs with meson:" echo " [default] default settings" @@ -35,7 +36,9 @@ BUILDTYPE=release CROSS_TARGET=arm 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}" @@ -49,6 +52,9 @@ while getopts "b:c:m:t:" o; do t) CROSS_TARGET="${OPTARG}" ;; + x) + use_valgrind=1 + ;; *) usage exit 1 @@ -144,8 +150,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() {