Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cleanup Sanitizer jenkins script to allow separate launch
[simgrid.git] / tools / jenkins / Sanitizers.sh
1 #!/bin/sh
2
3 set -e
4
5 die() {
6     echo "$@"
7     exit 1
8 }
9
10 do_cleanup() {
11   for d in "$WORKSPACE/build"
12   do
13     if [ -d "$d" ]
14     then
15       rm -rf "$d" || die "Could not remote $d"
16     fi
17   done
18 }
19
20 if [ -z "$1" ]
21   then
22     echo "No Sanitizer type selected - run Address"
23     SANITIZER="address"
24 else
25     SANITIZER=$1
26 fi
27
28
29 if [ "${SANITIZER}" = "address" ]
30 then
31     SANITIZER_OPTIONS="-Denable_address_sanitizer=ON -Denable_undefined_sanitizer=OFF -Denable_thread_sanitizer=OFF"
32 elif [ "${SANITIZER}" = "thread" ]
33 then
34     export TSAN_OPTIONS="memory_limit_mb=1500"
35     SANITIZER_OPTIONS="-Denable_address_sanitizer=OFF -Denable_undefined_sanitizer=OFF -Denable_thread_sanitizer=ON"
36 elif [ "${SANITIZER}" = "undefined" ]
37 then
38     export UBSAN_OPTIONS="print_stacktrace=1"
39     SANITIZER_OPTIONS="-Denable_address_sanitizer=OFF -Denable_undefined_sanitizer=ON -Denable_thread_sanitizer=OFF"
40 else
41     die "Unknown Sanitizer type selected  ${SANITIZER} - Exiting"
42 fi
43
44
45
46 ### Check the node installation
47
48 for pkg in xsltproc
49 do
50    if command -v $pkg
51    then 
52       echo "$pkg is installed. Good."
53    else 
54       die "please install $pkg before proceeding" 
55    fi
56 done
57
58 ###¬†Cleanup previous runs
59
60 ! [ -z "$WORKSPACE" ] || die "No WORKSPACE"
61 [ -d "$WORKSPACE" ] || die "WORKSPACE ($WORKSPACE) does not exist"
62
63 do_cleanup
64
65 for d in "$WORKSPACE/build"
66 do
67   mkdir "$d" || die "Could not create $d"
68 done
69
70 NUMPROC="$(nproc)" || NUMPROC=1
71
72 cd $WORKSPACE/build
73
74 ctest -D ExperimentalStart || true
75
76 cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=OFF \
77       -Denable_compile_optimizations=ON -Denable_compile_warnings=ON \
78       -Denable_jedule=ON -Denable_mallocators=OFF \
79       -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_model-checking=OFF \
80       -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_smpi_ISP_testsuite=ON -Denable_coverage=OFF\
81       -Denable_fortran=OFF ${SANITIZER_OPTIONS} $WORKSPACE
82
83 make -j$NUMPROC
84 ctest -D ExperimentalTest || true
85
86 if [ -f Testing/TAG ] ; then
87    xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults_${SANITIZER}.xml
88    mv CTestResults_${SANITIZER}.xml $WORKSPACE
89 fi
90
91 make clean