Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dynar--
[simgrid.git] / tools / jenkins / Coverage.sh
index 6310ddb..1befd18 100755 (executable)
@@ -2,13 +2,15 @@
 
 set -e
 
+BUILDFOLDER=$WORKSPACE/build
+
 die() {
     echo "$@"
     exit 1
 }
 
 do_cleanup() {
-  for d in "$WORKSPACE/build"
+  for d in "$BUILDFOLDER"
   do
     if [ -d "$d" ]
     then
@@ -19,7 +21,7 @@ do_cleanup() {
 
 ### Check the node installation
 
-for pkg in xsltproc gcovr
+for pkg in xsltproc gcovr ant cover2cover.py
 do
    if command -v $pkg
    then 
@@ -36,14 +38,15 @@ done
 
 do_cleanup
 
-for d in "$WORKSPACE/build"
+for d in "$BUILDFOLDER"
 do
   mkdir "$d" || die "Could not create $d"
 done
 
 NUMPROC="$(nproc)" || NUMPROC=1
 
-cd $WORKSPACE/build
+
+cd $BUILDFOLDER
 
 ctest -D ExperimentalStart || true
 
@@ -54,10 +57,28 @@ cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=ON \
       -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_smpi_ISP_testsuite=ON -Denable_coverage=ON $WORKSPACE
 
 make -j$NUMPROC
+JACOCO_PATH="/usr/local/share/jacoco"
+export JAVA_TOOL_OPTIONS="-javaagent:${JACOCO_PATH}/lib/jacocoagent.jar"
+
 ctest -D ExperimentalTest -j$NUMPROC || true
 ctest -D ExperimentalCoverage || true
 
+unset JAVA_TOOL_OPTIONS
 if [ -f Testing/TAG ] ; then
+
+  files=`find . -name "jacoco.exec"`
+  i=0
+  for file in $files
+  do
+    sourcepath=`dirname $file`
+    #convert jacoco reports in xml ones
+    ant -f $WORKSPACE/tools/jenkins/jacoco.xml -Dexamplesrcdir=$WORKSPACE -Dbuilddir=$BUILDFOLDER/${sourcepath} -Djarfile=$BUILDFOLDER/simgrid.jar -Djacocodir=${JACOCO_PATH}/lib
+    #convert jacoco xml reports in cobertura xml reports
+    cover2cover.py $BUILDFOLDER/${sourcepath}/report.xml .. ../src/bindings/java src/bindings/java > $WORKSPACE/java_coverage_${i}.xml
+    i=$(($i + 1))
+  done
+
+   #convert all gcov reports to xml cobertura reports
    gcovr -r .. --xml-pretty -e teshsuite.* -u -o $WORKSPACE/xml_coverage.xml
    xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults_memcheck.xml
    mv CTestResults_memcheck.xml $WORKSPACE