diff --git a/.travis.yml b/.travis.yml index d0f00c5..67228c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ compiler: before_install: - sudo apt-get update -qq - - sudo apt-get install -qq asciidoc cppcheck libarchive-dev liblzma-dev xz-utils + - sudo apt-get install -qq asciidoc cppcheck libarchive-dev liblzma-dev valgrind xz-utils script: - autoconf --version diff --git a/test/Makefile.am b/test/Makefile.am index 6aebb6f..808e7b3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,8 @@ TESTS = \ compress-file-permissions.sh \ cppcheck-src.sh \ + compression-memcheck.sh \ + decompression-memcheck.sh \ single-file-round-trip.sh \ xz-compatibility-c-option.sh diff --git a/test/compression-memcheck.sh b/test/compression-memcheck.sh new file mode 100755 index 0000000..000829b --- /dev/null +++ b/test/compression-memcheck.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +if which valgrind &> /dev/null ; then + PIXZ=../src/pixz + + INPUT=$(basename $0) + OUTPUT=$INPUT.pixz + + MEMCHECK_OUT=$(mktemp) + + trap "rm -f $OUTPUT $MEMCHECK_OUT" EXIT + + valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --track-origins=yes \ + $PIXZ $INPUT $OUTPUT \ + 2> $MEMCHECK_OUT + + cat $MEMCHECK_OUT + grep -q 'ERROR SUMMARY: 0' $MEMCHECK_OUT +else + echo "no valgrind, skipping test" + exit 77 +fi diff --git a/test/decompression-memcheck.sh b/test/decompression-memcheck.sh new file mode 100755 index 0000000..c43391a --- /dev/null +++ b/test/decompression-memcheck.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +if which valgrind &> /dev/null ; then + PIXZ=../src/pixz + + INPUT=$(basename $0) + OUTPUT=$INPUT.pixz + UNCOMPRESSED=$INPUT.uncompressed + + MEMCHECK_OUT=$(mktemp) + + trap "rm -f $OUTPUT $MEMCHECK_OUT $UNCOMPRESSED" EXIT + + $PIXZ $INPUT $OUTPUT + + valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --track-origins=yes \ + $PIXZ -d $OUTPUT $UNCOMPRESSED \ + 2> $MEMCHECK_OUT + + cat $MEMCHECK_OUT + grep -q 'ERROR SUMMARY: 0' $MEMCHECK_OUT +else + echo "no valgrind, skipping test" + exit 77 +fi