Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Try to have java coverage with jacoco.
authordegomme <augustin.degomme@unibas.ch>
Wed, 1 Mar 2017 01:03:33 +0000 (02:03 +0100)
committerdegomme <augustin.degomme@unibas.ch>
Wed, 1 Mar 2017 01:03:52 +0000 (02:03 +0100)
Should instead break everything.

examples/java/CMakeLists.txt
tools/jenkins/Coverage.sh
tools/jenkins/jacoco.xml [new file with mode: 0644]

index 999a5b9..0c8162e 100644 (file)
@@ -68,6 +68,6 @@ if(enable_java)
            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)
     string (REPLACE "_" "/" example_dir ${example})
-    ADD_TESH(java-${example}  --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/${example_dir}/${example}.tesh)
+    ADD_TESH(java-${example}  --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java/${example_dir} ${CMAKE_HOME_DIRECTORY}/examples/java/${example_dir}/${example}.tesh)
   endforeach()
 endif()
index 6310ddb..566cf9a 100755 (executable)
@@ -19,7 +19,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 
@@ -43,21 +43,36 @@ done
 
 NUMPROC="$(nproc)" || NUMPROC=1
 
+
 cd $WORKSPACE/build
 
 ctest -D ExperimentalStart || true
 
-cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=ON \
+cmake -Denable_documentation=OFF -Denable_lua=OFF -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=ON $WORKSPACE
+      -Denable_jedule=OFF -Denable_mallocators=ON \
+      -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_model-checking=ON \
+      -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_smpi_ISP_testsuite=OFF -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
+i=0
 if [ -f Testing/TAG ] ; then
+  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
+  do
+    #convert jacoco reports in xml ones
+    ant -f $WORKSPACE/tools/jenkins/jacoco.xml -Dsrcdir=$WORKSPACE/examples/java/${example} -Dbuilddir=$WORKSPACE/build/examples/java/${example} -Djacocodir=${JACOCO_PATH}/lib
+    #convert jacoco xml reports in cobertura xml reports
+    cover2cover.py $WORKSPACE/build/examples/java/${example}/report.xml $WORKSPACE/examples/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
diff --git a/tools/jenkins/jacoco.xml b/tools/jenkins/jacoco.xml
new file mode 100644 (file)
index 0000000..3106a1c
--- /dev/null
@@ -0,0 +1,26 @@
+<project name="Example" xmlns:jacoco="antlib:org.jacoco.ant">
+
+    <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
+        <classpath path="${jacocodir}/jacocoant.jar"/>
+    </taskdef>
+
+<jacoco:report>
+                        
+    <executiondata>
+        <file file="${builddir}/jacoco.exec"/>
+    </executiondata>
+                        
+    <structure name="Example Project">
+        <classfiles>
+            <fileset dir="${builddir}"/>
+        </classfiles>
+        <sourcefiles encoding="UTF-8">
+            <fileset dir="${srcdir}"/>
+        </sourcefiles>
+    </structure>
+                        
+    <xml destfile="${builddir}/report.xml"/>
+                        
+</jacoco:report>
+
+</project>