Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add sanitizers (address, thread, and undefined), to have new procrastination options...
authordegomme <augustin.degomme@unibas.ch>
Fri, 24 Jun 2016 13:44:25 +0000 (15:44 +0200)
committerdegomme <augustin.degomme@unibas.ch>
Fri, 24 Jun 2016 13:47:51 +0000 (15:47 +0200)
tools/cmake/GCCFlags.cmake
tools/cmake/Option.cmake
tools/jenkins/Sanitizers.sh [new file with mode: 0755]
tools/tesh/tesh.pl

index c6e21bb..e1539d5 100644 (file)
@@ -163,6 +163,25 @@ if(enable_coverage)
   endif()
 endif()
 
+if(enable_address_sanitizer)
+    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
+    set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fsanitize=address")
+    set(TESH_OPTION --enable-sanitizers)
+endif()
+
+if(enable_thread_sanitizer)
+    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
+    set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fsanitize=thread")
+endif()
+
+if(enable_undefined_sanitizer)
+    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
+    set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fsanitize=undefined")
+endif()
+
 if(NOT $ENV{CFLAGS} STREQUAL "")
   message(STATUS "Add CFLAGS: \"$ENV{CFLAGS}\" to CMAKE_C_FLAGS")
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{CFLAGS}")
index 511f861..5a74f55 100644 (file)
@@ -53,6 +53,12 @@ option(enable_memcheck "Enable memcheck." off)
 mark_as_advanced(enable_memcheck)
 option(enable_memcheck_xml "Enable memcheck with xml output." off)
 mark_as_advanced(enable_memcheck_xml)
+option(enable_address_sanitizer "Whether address sanitizer is turned on." off)
+mark_as_advanced(enable_address_sanitizer)
+option(enable_thread_sanitizer "Whether thread sanitizer is turned on." off)
+mark_as_advanced(enable_thread_sanitizer)
+option(enable_undefined_sanitizer "Whether undefined sanitizer is turned on." off)
+mark_as_advanced(enable_undefined_sanitizer)
 
 # Cmake, Y U NO hide your garbage??
 ###
diff --git a/tools/jenkins/Sanitizers.sh b/tools/jenkins/Sanitizers.sh
new file mode 100755 (executable)
index 0000000..391b788
--- /dev/null
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+set -e
+
+die() {
+    echo "$@"
+    exit 1
+}
+
+do_cleanup() {
+  for d in "$WORKSPACE/build"
+  do
+    if [ -d "$d" ]
+    then
+      rm -rf "$d" || die "Could not remote $d"
+    fi
+  done
+}
+
+### Check the node installation
+
+for pkg in xsltproc
+do
+   if command -v $pkg
+   then 
+      echo "$pkg is installed. Good."
+   else 
+      die "please install $pkg before proceeding" 
+   fi
+done
+
+###¬†Cleanup previous runs
+
+! [ -z "$WORKSPACE" ] || die "No WORKSPACE"
+[ -d "$WORKSPACE" ] || die "WORKSPACE ($WORKSPACE) does not exist"
+
+do_cleanup
+
+for d in "$WORKSPACE/build"
+do
+  mkdir "$d" || die "Could not create $d"
+done
+
+NUMPROC="$(nproc)" || NUMPROC=1
+
+cd $WORKSPACE/build
+
+ctest -D ExperimentalStart || true
+
+cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=ON \
+      -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \
+      -Denable_jedule=ON -Denable_mallocators=ON \
+      -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_model-checking=ON \
+      -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_smpi_ISP_testsuite=ON -Denable_coverage=OFF -Denable_address_sanitizer=ON $WORKSPACE
+
+make -j$NUMPROC
+ctest -D ExperimentalTest || true
+
+if [ -f Testing/TAG ] ; then
+   xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults_address.xml
+   mv CTestResults_address.xml $WORKSPACE
+fi
+
+make clean
+
+export TSAN_OPTIONS="memory_limit_mb=1500"
+
+ctest -D ExperimentalStart || true
+
+cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=ON \
+      -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \
+      -Denable_jedule=ON -Denable_mallocators=ON \
+      -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_model-checking=ON \
+      -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_smpi_ISP_testsuite=ON -Denable_coverage=OFF -Denable_address_sanitizer=OFF -Denable_thread_sanitizer=ON  $WORKSPACE
+
+make -j$NUMPROC
+ctest -D ExperimentalTest || true
+
+if [ -f Testing/TAG ] ; then
+   xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults_thread.xml
+   mv CTestResults_thread.xml $WORKSPACE
+fi
+
+make clean
+
+ctest -D ExperimentalStart || true
+
+cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=ON \
+      -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \
+      -Denable_jedule=ON -Denable_mallocators=ON \
+      -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_model-checking=ON \
+      -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_smpi_ISP_testsuite=ON -Denable_coverage=OFF -Denable_address_sanitizer=OFF -Denable_thread_sanitizer=OFF -Denable_undefined_sanitizer=ON  $WORKSPACE
+
+make -j$NUMPROC
+ctest -D ExperimentalTest || true
+
+if [ -f Testing/TAG ] ; then
+   xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults_undefined.xml
+   mv CTestResults_undefined.xml $WORKSPACE
+fi
+
+
index cb4c46f..b238b4d 100755 (executable)
@@ -35,6 +35,7 @@ they produce the expected output and return the expected value.
   --cfg arg           : add parameter --cfg=arg to each command line
   --log arg           : add parameter --log=arg to each command line
   --enable-coverage   : ignore output lines starting with "profiling:"
+  --enable-sanitizers : ignore output lines starting with containing warnings
 
 =head1 TEST SUITE FILE SYTAX
 
@@ -239,6 +240,7 @@ BEGIN {
 }
 
 my $enable_coverage        = 0;
+my $enable_sanitizers        = 0;
 my $diff_tool              = 0;
 my $diff_tool_tmp_fh       = 0;
 my $diff_tool_tmp_filename = 0;
@@ -307,6 +309,7 @@ GetOptions(
     'cfg=s' => sub { $opts{'cfg'} .= " --cfg=$_[1]" },
     'log=s' => sub { $opts{'log'} .= " --log=$_[1]" },
     'enable-coverage+' => \$enable_coverage,
+    'enable-sanitizers+' => \$enable_sanitizers,
 );
 
 $tesh_file = pop @ARGV;
@@ -314,6 +317,7 @@ $tesh_name = $tesh_file;
 $tesh_name =~ s|^.*?/([^/]*)$|$1|;
 
 print "Enable coverage\n" if ($enable_coverage);
+print "Enable sanitizers\n" if ($enable_sanitizers);
 
 if ($diff_tool) {
     use File::Temp qw/ tempfile /;
@@ -425,9 +429,11 @@ sub analyze_result {
         chomp $got;
         print $diff_tool_tmp_fh "> $got\n" if ($diff_tool);
 
-        unless ( $enable_coverage and $got =~ /^profiling:/ ) {
+        unless (( $enable_coverage and $got =~ /^profiling:/ ) or
+            ( $enable_sanitizers and $got =~ m/WARNING: ASan doesn't fully support/))
+        {
             push @got, $got;
-        }
+        } 
     }
 
     # How did the child process terminate?