Commit 75d3c57a152192fa48de39c745e712b37aab8161

Steffen Jaeckel 2019-05-21T15:20:46

Merge pull request #282 from libtom/restrict-v-algrind Restrict running Valgrind

diff --git a/.travis.yml b/.travis.yml
index 358f03c..dba45d4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -67,7 +67,14 @@ matrix:
           packages:
             - astyle
 
-    # GCC for the 32-bit architecture (no valgrind yet)
+    # Run always with valgrind (no sanitizer, but debug info)
+    - env: COMPILE_DEBUG=1 BUILDOPTIONS='--with-cc=gcc-4.9 --with-m64 --with-valgrind'
+      addons:
+        apt:
+          packages:
+            - gcc-4.9
+
+    # GCC for the 32-bit architecture (no valgrind)
     - env: BUILDOPTIONS='--with-cc=gcc-5 --with-m32'
       addons:
         apt:
@@ -75,7 +82,7 @@ matrix:
             - libc6-dev-i386
             - gcc-multilib
 
-    # clang for the 32-bit architecture (no valgrind yet)
+    # clang for the 32-bit architecture (no valgrind)
     - env: BUILDOPTIONS='--with-cc=clang-7 --with-m32'
       addons:
         apt:
@@ -83,6 +90,28 @@ matrix:
             - libc6-dev-i386
             - gcc-multilib
 
+    # Test "autotuning", the automatic evaluation and setting of the Toom-Cook cut-offs.
+    #- env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_8BIT  --with-travis-valgrind --make-option=tune'
+    #- env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_16BIT --with-travis-valgrind --make-option=tune'
+    #- env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_32BIT --with-travis-valgrind --make-option=tune'
+    #- env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --with-travis-valgrind --make-option=tune'
+    #- env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_8BIT  --with-travis-valgrind --make-option=tune'
+    #- env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_16BIT --with-travis-valgrind --make-option=tune'
+    #- env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_32BIT --with-travis-valgrind --make-option=tune'
+    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --with-travis-valgrind --make-option=tune'
+
+    # GCC for the x86-64 architecture testing against a different Bigint-implementation
+    # with 333333 different inputs.
+    #- env: BUILDOPTIONS='--with-cc=gcc-5 --test-vs-mtest=333333 --with-travis-valgrind'
+    # ...  and a better random source.
+    - env: BUILDOPTIONS='--with-cc=gcc-5 --test-vs-mtest=333333 --mtest-real-rand --with-travis-valgrind'
+
+    # clang for the x86-64 architecture testing against a different Bigint-implementation
+    # with 333333 different inputs
+    - env: BUILDOPTIONS='--with-cc=clang-7 --test-vs-mtest=333333 --with-travis-valgrind'
+    # ...  and a better random source.
+    #- env: BUILDOPTIONS='--with-cc=clang-7 --test-vs-mtest=333333 --mtest-real-rand --with-travis-valgrind'
+
     # GCC for the x64_32 architecture (32-bit longs and 32-bit pointers)
     # TODO: Probably not possible to run anything in x32 in Travis
     #       but needs to be checked to be sure.
@@ -94,37 +123,32 @@ matrix:
             - gcc-multilib
 
     # GCC for the x86-64 architecture (64-bit longs and 64-bit pointers)
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --with-m64 --with-valgrind'
-    - env: BUILDOPTIONS='--with-cc=gcc-4.7 --with-m64 --with-valgrind'
+    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --with-m64 --with-travis-valgrind'
+    - env: BUILDOPTIONS='--with-cc=gcc-4.7 --with-m64 --with-travis-valgrind'
       addons:
         apt:
           packages:
             - gcc-4.7
-    - env: BUILDOPTIONS='--with-cc=gcc-4.8 --with-m64 --with-valgrind'
+    - env: BUILDOPTIONS='--with-cc=gcc-4.8 --with-m64 --with-travis-valgrind'
       addons:
         apt:
           packages:
             - gcc-4.8
-    - env: BUILDOPTIONS='--with-cc=gcc-4.9 --with-m64 --with-valgrind'
-      addons:
-        apt:
-          packages:
-            - gcc-4.9
 
     # clang for x86-64 architecture (64-bit longs and 64-bit pointers)
-    - env: SANITIZER=1 CONV_WARNINGS=strict BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-valgrind'
-    - env: SANITIZER=1 CONV_WARNINGS=relaxed BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-valgrind'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-6.0 --with-m64 --with-valgrind'
+    - env: SANITIZER=1 CONV_WARNINGS=relaxed BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-travis-valgrind'
+    - env: SANITIZER=1 CONV_WARNINGS=strict BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-travis-valgrind'
+    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-6.0 --with-m64 --with-travis-valgrind'
       addons:
         apt:
           packages:
             - clang-6.0
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-5.0 --with-m64 --with-valgrind'
+    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-5.0 --with-m64 --with-travis-valgrind'
       addons:
         apt:
           packages:
             - clang-5.0
-    - env: BUILDOPTIONS='--with-cc=clang-4.0 --with-m64 --with-valgrind'
+    - env: BUILDOPTIONS='--with-cc=clang-4.0 --with-m64 --with-travis-valgrind'
       addons:
         apt:
           packages:
@@ -133,35 +157,14 @@ matrix:
     # GCC for the x86-64 architecture with restricted limb sizes
     # formerly started with the option "--with-low-mp" to testme.sh
     # but testing all three in one run took to long and timed out.
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_8BIT  --with-valgrind'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_16BIT --with-valgrind'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_32BIT --with-valgrind'
+    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_8BIT  --with-travis-valgrind'
+    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_16BIT --with-travis-valgrind'
+    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_32BIT --with-travis-valgrind'
 
     # clang for the x86-64 architecture with restricted limb sizes
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_8BIT  --with-valgrind'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_16BIT --with-valgrind'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_32BIT --with-valgrind'
-
-    # Test "autotuning", the automatic evaluation and setting of the Toom-Cook cut-offs.
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_8BIT  --with-valgrind --make-option=tune'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_16BIT --with-valgrind --make-option=tune'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_32BIT --with-valgrind --make-option=tune'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --with-valgrind --make-option=tune'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_8BIT  --with-valgrind --make-option=tune'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_16BIT --with-valgrind --make-option=tune'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_32BIT --with-valgrind --make-option=tune'
-    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --with-valgrind --make-option=tune'
-
-    # GCC for the x86-64 architecture testing against a different Bigint-implementation
-    # with 333333 different inputs.
-    - env: BUILDOPTIONS='--with-cc=gcc-5 --test-vs-mtest=333333 --with-valgrind'
-    - env: BUILDOPTIONS='--with-cc=clang-7 --test-vs-mtest=333333 --with-valgrind'
-
-    # clang for the x86-64 architecture testing against a different Bigint-implementation
-    # with a better random source.
-    - env: BUILDOPTIONS='--with-cc=gcc-5 --test-vs-mtest=333333 --mtest-real-rand --with-valgrind'
-    - env: BUILDOPTIONS='--with-cc=clang-7 --test-vs-mtest=333333 --mtest-real-rand --with-valgrind'
-
+    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_8BIT  --with-travis-valgrind'
+    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_16BIT --with-travis-valgrind'
+    - env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_32BIT --with-travis-valgrind'
 
 # Notifications go to
 # An email address is also possible.
diff --git a/makefile_include.mk b/makefile_include.mk
index aad3896..cae5ac7 100644
--- a/makefile_include.mk
+++ b/makefile_include.mk
@@ -71,7 +71,7 @@ endif
 ifdef COMPILE_DEBUG
 #debug
 CFLAGS += -g3
-else
+endif
 
 ifdef COMPILE_SIZE
 #for size
@@ -87,7 +87,6 @@ CFLAGS  += -fomit-frame-pointer
 endif
 
 endif # COMPILE_SIZE
-endif # COMPILE_DEBUG
 
 ifneq ($(findstring clang,$(CC)),)
 CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
diff --git a/testme.sh b/testme.sh
index c8237df..306c67d 100755
--- a/testme.sh
+++ b/testme.sh
@@ -61,11 +61,13 @@ _help()
   echo "    --with-valgrind"
   echo "    --with-valgrind=*       Run in valgrind (slow!)."
   echo
-  echo "    --valgrind-options       Additional Valgrind options"
-  echo "                             Some of the options like e.g.:"
-  echo "                             --track-origins=yes add a lot of extra"
-  echo "                             runtime and may trigger the 30 minutes"
-  echo "                             timeout."
+  echo "    --with-travis-valgrind  Run with valgrind on Travis on specific branches."
+  echo
+  echo "    --valgrind-options      Additional Valgrind options"
+  echo "                            Some of the options like e.g.:"
+  echo "                            --track-origins=yes add a lot of extra"
+  echo "                            runtime and may trigger the 30 minutes"
+  echo "                            timeout."
   echo
   echo "Godmode:"
   echo
@@ -126,7 +128,7 @@ _runtest()
     # get switched off without some effort, so we just let it run twice for testing purposes
     _make "$1" "$2" ""
     echo -e "\rRun autotune $1 $2"
-    $_timeout ./etc/tune_it.sh > test_${suffix}.log || _die "running autotune" $?
+    $_timeout $TUNE_CMD > ../test_${suffix}.log || _die "running autotune" $?
   else
     _make "$1" "$2" "test_standalone"
     echo -e "\rRun test $1 $2"
@@ -152,7 +154,7 @@ echo "autotune branch"
     # The shell used for /bin/sh is DASH 0.5.7-4ubuntu1 on the author's machine which fails valgrind, so
     # we just run on instance of etc/tune with the same options as in etc/tune_it.sh
     echo -e "\rRun etc/tune $1 $2 once inside valgrind"
-    $_timeout $VALGRIND_BIN $VALGRIND_OPTS ./etc/tune -t -r 10 -L 3 > test_${suffix}.log || _die "running etc/tune" $?
+    $_timeout $VALGRIND_BIN $VALGRIND_OPTS $TUNE_CMD > test_${suffix}.log || _die "running etc/tune" $?
   else
     _make "$1" "$2" "test_standalone"
     echo -e "\rRun test $1 $2 inside valgrind"
@@ -193,6 +195,7 @@ VALGRIND_OPTS=" --leak-check=full --show-leak-kinds=all --error-exitcode=1 "
 #VALGRIND_OPTS=""
 VALGRIND_BIN=""
 CHECK_FORMAT=""
+TUNE_CMD="./etc/tune -t -r 10 -L 3"
 
 alive_pid=0
 
@@ -232,6 +235,18 @@ do
       fi
       start_alive_printing
     ;;
+    --with-travis-valgrind*)
+      if [[ ("$TRAVIS_BRANCH" == "develop" && "$TRAVIS_PULL_REQUEST" == "false") || "$TRAVIS_BRANCH" == *"valgrind"* || "$TRAVIS_COMMIT_MESSAGE" == *"valgrind"* ]]
+      then
+        if [[ ${1#*d} != "" ]]
+        then
+          VALGRIND_BIN="${1#*=}"
+        else
+          VALGRIND_BIN="valgrind"
+        fi
+        start_alive_printing
+      fi
+    ;;
     --make-option=*)
       MAKE_OPTIONS="$MAKE_OPTIONS ${1#*=}"
     ;;