Logo AND Algorithmique Numérique Distribuée

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