Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Try to have java coverage with jacoco.
[simgrid.git] / tools / jenkins / Coverage.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 ### Check the node installation
21
22 for pkg in xsltproc gcovr ant cover2cover.py
23 do
24    if command -v $pkg
25    then 
26       echo "$pkg is installed. Good."
27    else 
28       die "please install $pkg before proceeding" 
29    fi
30 done
31
32 ###¬†Cleanup previous runs
33
34 ! [ -z "$WORKSPACE" ] || die "No WORKSPACE"
35 [ -d "$WORKSPACE" ] || die "WORKSPACE ($WORKSPACE) does not exist"
36
37 do_cleanup
38
39 for d in "$WORKSPACE/build"
40 do
41   mkdir "$d" || die "Could not create $d"
42 done
43
44 NUMPROC="$(nproc)" || NUMPROC=1
45
46
47 cd $WORKSPACE/build
48
49 ctest -D ExperimentalStart || true
50
51 cmake -Denable_documentation=OFF -Denable_lua=OFF -Denable_java=ON \
52       -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \
53       -Denable_jedule=OFF -Denable_mallocators=ON \
54       -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_model-checking=ON \
55       -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_smpi_ISP_testsuite=OFF -Denable_coverage=ON $WORKSPACE
56
57 make -j$NUMPROC
58 JACOCO_PATH="/usr/local/share/jacoco"
59 export JAVA_TOOL_OPTIONS="-javaagent:${JACOCO_PATH}/lib/jacocoagent.jar"
60
61 ctest -D ExperimentalTest -j$NUMPROC || true
62 ctest -D ExperimentalCoverage || true
63
64 unset JAVA_TOOL_OPTIONS
65 i=0
66 if [ -f Testing/TAG ] ; then
67   for example in app/bittorrent app/centralizedmutex app/masterworker app/pingpong app/tokenring async/yield async/waitall async/dsend cloud/migration cloud/masterworker dht/chord dht/kademlia energy/consumption energy/pstate energy/vm io/file io/storage process/kill process/migration process/startkilltime process/suspend task/priority trace/pingpong
68   do
69     #convert jacoco reports in xml ones
70     ant -f $WORKSPACE/tools/jenkins/jacoco.xml -Dsrcdir=$WORKSPACE/examples/java/${example} -Dbuilddir=$WORKSPACE/build/examples/java/${example} -Djacocodir=${JACOCO_PATH}/lib
71     #convert jacoco xml reports in cobertura xml reports
72     cover2cover.py $WORKSPACE/build/examples/java/${example}/report.xml $WORKSPACE/examples/java/ > $WORKSPACE/java_coverage_${i}.xml
73   i=$(($i + 1))
74   done
75    #convert all gcov reports to xml cobertura reports
76    gcovr -r .. --xml-pretty -e teshsuite.* -u -o $WORKSPACE/xml_coverage.xml
77    xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults_memcheck.xml
78    mv CTestResults_memcheck.xml $WORKSPACE
79 fi