CI: Add memleak checking using valgrind (#5350)
authorLoïc Blot <nerzhul@users.noreply.github.com>
Mon, 6 Mar 2017 19:34:02 +0000 (20:34 +0100)
committerGitHub <noreply@github.com>
Mon, 6 Mar 2017 19:34:02 +0000 (20:34 +0100)
Add a new step to check memleaks on our current unit tests suite

.travis.yml
util/travis/before_install.sh
util/travis/script.sh

index 534479efb7aa8b3b3b9c6fde77449f1ce76d855e..3274aedafd7df35e4dc1575723f56bc3d7f369c2 100644 (file)
@@ -22,6 +22,10 @@ matrix:
     - env: PLATFORM=Unix COMPILER=clang
       compiler: clang
       os: linux
+    - env: PLATFORM=Unix COMPILER=clang VALGRIND=1
+      compiler: clang
+      os: linux
+      dist: trusty
     - env: PLATFORM=Unix COMPILER=g++-6
       compiler: gcc
       os: linux
index 89137198451ff493bf2a15f37b50efaadd731d18..ea85b3db6d4e03ffdabef68d6a15cd36b3ce7024 100755 (executable)
@@ -18,6 +18,9 @@ if [[ $PLATFORM == "Unix" ]]; then
                # Linking to LevelDB is broken, use a custom build
                wget http://minetest.kitsunemimi.pw/libleveldb-1.18-ubuntu12.04.7z
                sudo 7z x -o/usr libleveldb-1.18-ubuntu12.04.7z
+               if [[ "$VALGRIND" == "1" ]]; then
+                       sudo apt-get install valgrind
+               fi
        else
                brew update
                brew install freetype gettext hiredis irrlicht jpeg leveldb libogg libvorbis luajit
index 24a74d18606c251b5b8fc4db20443d6e764d2007..84ea578a5aa0e6a8c43698354329660ed1add978 100755 (executable)
@@ -24,8 +24,15 @@ if [[ $PLATFORM == "Unix" ]]; then
                -DBUILD_SERVER=TRUE \
                $CMAKE_FLAGS ..
        make -j2
+
        echo "Running unit tests."
-       ../bin/minetest --run-unittests && exit 0
+       CMD="../bin/minetest --run-unittests"
+       if [[ "$VALGRIND" == "1" ]]; then
+               valgrind --leak-check=full --leak-check-heuristics=all --undef-value-errors=no --error-exitcode=9 ${CMD} && exit 0
+       else
+               ${CMD} && exit 0
+       fi
+
 elif [[ $PLATFORM == Win* ]]; then
        [[ $CC == "clang" ]] && exit 1 # Not supposed to happen
        # We need to have our build directory outside of the minetest directory because