]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
ci: test Valgrind
authorSam James <sam@gentoo.org>
Wed, 10 Apr 2024 10:43:10 +0000 (11:43 +0100)
committerLasse Collin <lasse.collin@tukaani.org>
Wed, 10 Apr 2024 21:15:35 +0000 (00:15 +0300)
Using `--trace-children=yes` has a trade-off here, as it makes
`test_scripts.sh` pretty slow when calling various non-xz utilities.

But I also feel like it's not useless to have Valgrind used there and it's
not easy to exclude Valgrind just for that one test...

I did consider using AX_VALGRIND_CHECK [0][1] but I couldn't get it working
immediately with some conditionally-built tests and I wondered if it was
worth spending time on at least while we're debating xz's future build
system situation.

[0] https://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html
[1] https://tecnocode.co.uk/2014/12/23/automatically-valgrinding-code-with-ax_valgrind_check/

.github/workflows/ci.yml
build-aux/ci_build.sh

index cbf3b7d9ce297a6b5123e933af91981b275b446f..9aa4f9aa706896d210fe2f48935826d0d4b86548 100644 (file)
@@ -37,7 +37,7 @@ jobs:
         if: ${{ matrix.os == 'ubuntu-latest' && matrix.build_system == 'autotools' }}
         run: |
             sudo apt-get update
-            sudo apt-get install -y autoconf automake build-essential po4a autopoint gcc-multilib doxygen musl-tools
+            sudo apt-get install -y autoconf automake build-essential po4a autopoint gcc-multilib doxygen musl-tools valgrind
 
       # Install Autotools on Mac
       - name: Install Dependencies
@@ -89,6 +89,15 @@ jobs:
             ./build-aux/ci_build.sh -b autotools -p test -f "-fsanitize=address,undefined" -d sandbox
             cd ../xz_build && make distclean
 
+      - name: Build with Valgrind
+        if: ${{ matrix.os == 'ubuntu-latest' && matrix.build_system == 'autotools' }}
+        run: ./build-aux/ci_build.sh -b autotools -p build -d sandbox
+      - name: Test with Valgrind
+        if: ${{ matrix.os == 'ubuntu-latest' && matrix.build_system == 'autotools' }}
+        run: |
+            ./build-aux/ci_build.sh -b autotools -p test -d sandbox -w "valgrind --quiet --trace-children=yes --exit-on-first-error=yes --error-exitcode=1"
+            cd ../xz_build && make distclean
+
       - name: Build with musl libc
         if: ${{ matrix.os == 'ubuntu-latest'}}
         run: ./build-aux/ci_build.sh -b ${{ matrix.build_system }} -p build -m "/usr/bin/musl-gcc"
index 9e2a7f8b25201c8fbcb88ef1cd36f6f52659fc20..e6926d3ecde0783ca8803f71427cc87b0bca754a 100755 (executable)
@@ -53,7 +53,7 @@ ARTIFACTS_DIR_NAME="output"
 # Parse arguments #
 ###################
 
-while getopts a:b:c:d:l:m:n:s:p:f:h opt; do
+while getopts a:b:c:d:l:m:n:s:p:f:w:h opt; do
        # b option can have either value "autotools" OR "cmake"
        case ${opt} in
        h)
@@ -108,6 +108,8 @@ while getopts a:b:c:d:l:m:n:s:p:f:h opt; do
                CFLAGS="$OPTARG"
                export CFLAGS
        ;;
+       w) WRAPPER="$OPTARG"
+       ;;
        esac
 done
 
@@ -260,7 +262,7 @@ then
        autotools)
                cd "$DEST_DIR"
                # If the tests fail, copy the test logs into the artifacts folder
-               if make check
+               if make check LOG_COMPILER="$WRAPPER"
                then
                        :
                else
@@ -271,7 +273,7 @@ then
        ;;
        cmake)
                cd "$DEST_DIR"
-               if make test
+               if ${WRAPPER} make test
                then
                        :
                else