From: Augustin Degomme Date: Wed, 9 Jan 2019 10:48:30 +0000 (+0100) Subject: add python coverage X-Git-Tag: v3_22~624 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4a0bf1b8a5858a914ebf40fd189a83d4fbc5f9de add python coverage May crash with some examples, such as actor-create.. --- diff --git a/examples/python/actor-create/actor-create.tesh b/examples/python/actor-create/actor-create.tesh index c93449dd46..17f7c8b4c9 100644 --- a/examples/python/actor-create/actor-create.tesh +++ b/examples/python/actor-create/actor-create.tesh @@ -1,6 +1,6 @@ #!/usr/bin/env tesh -$ python3 ${srcdir:=.}/actor-create.py +$ python3 ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/actor-create.py > [Tremblay:sender1:(2) 0.000000] [python/INFO] Hello s4u, I have something to send > [Jupiter:sender2:(3) 0.000000] [python/INFO] Hello s4u, I have something to send > [Fafard:sender:(4) 0.000000] [python/INFO] Hello s4u, I have something to send diff --git a/examples/python/actor-daemon/actor-daemon.tesh b/examples/python/actor-daemon/actor-daemon.tesh index 71c19ce5bd..1513f146f4 100644 --- a/examples/python/actor-daemon/actor-daemon.tesh +++ b/examples/python/actor-daemon/actor-daemon.tesh @@ -2,7 +2,7 @@ p Testing the process daemonization feature -$ python3 ${bindir:=.}/actor-daemon.py ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n" +$ python3 ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/actor-daemon.py ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n" > [ 0.000000] (worker@Boivin) Let's do some work (for 10 sec on Boivin). > [ 0.000000] (daemon@Tremblay) Hello from the infinite loop > [ 3.000000] (daemon@Tremblay) Hello from the infinite loop diff --git a/examples/python/actor-join/actor-join.tesh b/examples/python/actor-join/actor-join.tesh index 4fc199e1db..f9c8ffc5c9 100644 --- a/examples/python/actor-join/actor-join.tesh +++ b/examples/python/actor-join/actor-join.tesh @@ -1,4 +1,4 @@ -$ python3 ${bindir:=.}/actor-join.py ${platfdir}/small_platform.xml +$ python3 ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/actor-join.py ${platfdir}/small_platform.xml > [Tremblay:master:(1) 0.000000] [python/INFO] Start sleeper > [Tremblay:sleeper from master:(2) 0.000000] [python/INFO] Sleeper started > [Tremblay:master:(1) 0.000000] [python/INFO] Join the sleeper (timeout 2) diff --git a/examples/python/actor-kill/actor-kill.tesh b/examples/python/actor-kill/actor-kill.tesh index 422e40a6fa..40a39a7248 100644 --- a/examples/python/actor-kill/actor-kill.tesh +++ b/examples/python/actor-kill/actor-kill.tesh @@ -1,6 +1,6 @@ #!/usr/bin/env tesh -$ python3 ${bindir:=.}/actor-kill.py ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n" +$ python3 ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/actor-kill.py ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n" > [ 0.000000] (killer@Tremblay) Hello! > [ 0.000000] (victim A@Fafard) Hello! > [ 0.000000] (victim A@Fafard) Suspending myself diff --git a/examples/python/actor-lifetime/actor-lifetime.tesh b/examples/python/actor-lifetime/actor-lifetime.tesh index 4e52a38d6f..c5b8121e77 100644 --- a/examples/python/actor-lifetime/actor-lifetime.tesh +++ b/examples/python/actor-lifetime/actor-lifetime.tesh @@ -1,6 +1,6 @@ #!/usr/bin/env tesh -$ python3 ${bindir:=.}/actor-lifetime.py ${platfdir}/cluster_backbone.xml actor-lifetime_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ python3 ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/actor-lifetime.py ${platfdir}/cluster_backbone.xml actor-lifetime_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:sleeper@node-0.simgrid.org) Hello! I go to sleep. > [ 0.000000] (2:sleeper@node-1.simgrid.org) Hello! I go to sleep. > [ 2.000000] (3:sleeper@node-0.simgrid.org) Hello! I go to sleep. diff --git a/examples/python/actor-migrate/actor-migrate.tesh b/examples/python/actor-migrate/actor-migrate.tesh index 4ec3fcabdc..5c3ac059dd 100644 --- a/examples/python/actor-migrate/actor-migrate.tesh +++ b/examples/python/actor-migrate/actor-migrate.tesh @@ -2,7 +2,7 @@ p Testing the actor migration feature -$ python3 ${bindir:=.}/actor-migrate.py ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n" +$ python3 ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/actor-migrate.py ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n" > [ 0.000000] (worker@Fafard) Let's move to Boivin to execute 1177.14 Mflops (5sec on Boivin and 5sec on Jacquelin) > [ 5.000000] (monitor@Boivin) After 5 seconds, move the process to Jacquelin > [ 10.000000] (worker@Jacquelin) I wake up on Jacquelin. Let's suspend a bit diff --git a/examples/python/actor-suspend/actor-suspend.tesh b/examples/python/actor-suspend/actor-suspend.tesh index e64839820e..226b54b68e 100644 --- a/examples/python/actor-suspend/actor-suspend.tesh +++ b/examples/python/actor-suspend/actor-suspend.tesh @@ -3,7 +3,7 @@ p Testing the suspend/resume feature of SimGrid ! output sort 19 -$ python3 ${bindir:=.}/actor-suspend.py ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n" +$ python3 ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/actor-suspend.py ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n" > [ 0.000000] (dream_master@Boivin) Let's create a lazy guy. > [ 0.000000] (Lazy@Boivin) Nobody's watching me ? Let's go to sleep. > [ 0.000000] (dream_master@Boivin) Let's wait a little bit... diff --git a/examples/python/actor-yield/actor-yield.tesh b/examples/python/actor-yield/actor-yield.tesh index 6cbf8baaa1..33b6c3fcb9 100644 --- a/examples/python/actor-yield/actor-yield.tesh +++ b/examples/python/actor-yield/actor-yield.tesh @@ -1,5 +1,5 @@ #!/usr/bin/env tesh -$ python3 ${srcdir:=.}/actor-yield.py ${platfdir}/small_platform_fatpipe.xml ${srcdir:=.}/../../s4u/actor-yield/s4u-actor-yield_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ python3 ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/actor-yield.py ${platfdir}/small_platform_fatpipe.xml ${srcdir:=.}/../../s4u/actor-yield/s4u-actor-yield_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:yielder@Tremblay) I yielded 10 times. Goodbye now! > [ 0.000000] (2:yielder@Ruby) I yielded 15 times. Goodbye now! diff --git a/examples/python/exec-basic/exec-basic.tesh b/examples/python/exec-basic/exec-basic.tesh index ce25f09b9d..fffc31b6d7 100644 --- a/examples/python/exec-basic/exec-basic.tesh +++ b/examples/python/exec-basic/exec-basic.tesh @@ -1,6 +1,6 @@ #!/usr/bin/env tesh p Start remote processes -$ python3 ${srcdir}/exec-basic.py ${platfdir}/small_platform.xml +$ python3 ${PYTHON_TOOL_OPTIONS:=} ${srcdir}/exec-basic.py ${platfdir}/small_platform.xml > [Tremblay:privileged:(2) 0.001500] [python/INFO] Done. > [Tremblay:executor:(1) 0.002000] [python/INFO] Done. diff --git a/tools/jenkins/Coverage.sh b/tools/jenkins/Coverage.sh index b268cdb8e4..fca49e660b 100755 --- a/tools/jenkins/Coverage.sh +++ b/tools/jenkins/Coverage.sh @@ -48,6 +48,8 @@ NUMPROC="$(nproc)" || NUMPROC=1 cd $BUILDFOLDER rm -rf java_cov* +rm -rf jacoco_cov* +rm -rf python_cov* rm -rf xml_coverage.xml ctest -D ExperimentalStart || true @@ -64,6 +66,8 @@ cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=ON \ JACOCO_PATH="/usr/local/share/jacoco" export JAVA_TOOL_OPTIONS="-javaagent:${JACOCO_PATH}/lib/jacocoagent.jar" +export PYTHON_TOOL_OPTIONS="/usr/bin/python3-coverage run --branch" + ctest --no-compress-output -D ExperimentalTest -j$NUMPROC || true ctest -D ExperimentalCoverage || true @@ -78,13 +82,28 @@ if [ -f Testing/TAG ] ; then #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 + cover2cover.py $BUILDFOLDER/${sourcepath}/report.xml .. ../src/bindings/java src/bindings/java > $BUILDFOLDER/java_coverage_${i}.xml + #save jacoco xml report as sonar only allows it + mv $BUILDFOLDER/${sourcepath}/report.xml $BUILDFOLDER/jacoco_coverage_${i}.xml + i=$((i + 1)) + done + + cd $WORKSPACE + + files=$( find . -size +1c -name ".coverage" ) + i=0 + for file in $files + do + sourcepath=$( dirname $file ) + #convert python coverage reports in xml ones + cd $sourcepath + /usr/bin/python3-coverage xml -i -o $BUILDFOLDER/python_coverage_${i}.xml + cd $WORKSPACE i=$((i + 1)) done - cd $WORKSPACE #convert all gcov reports to xml cobertura reports - gcovr -r . --xml-pretty -e teshsuite -u -o $WORKSPACE/xml_coverage.xml + gcovr -r . --xml-pretty -e teshsuite -u -o $BUILDFOLDER/xml_coverage.xml xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl build/Testing/$( head -n 1 < build/Testing/TAG )/Test.xml > CTestResults_memcheck.xml #generate sloccount report @@ -93,13 +112,19 @@ if [ -f Testing/TAG ] ; then #upload files to codacy. CODACY_PROJECT_TOKEN must be setup ! if ! [ -z $CODACY_PROJECT_TOKEN ] then - for report in $WORKSPACE/java_cov* + for report in $BUILDFOLDER/java_cov* do if [ ! -e "$report" ]; then continue; fi java -jar /home/ci/codacy-coverage-reporter-*-assembly.jar report -l Java -r $report --partial done java -jar /home/ci/codacy-coverage-reporter-*-assembly.jar final - java -jar /home/ci/codacy-coverage-reporter-*-assembly.jar report -l C -f -r $WORKSPACE/xml_coverage.xml - java -jar /home/ci/codacy-coverage-reporter-*-assembly.jar report -l CPP -f -r $WORKSPACE/xml_coverage.xml + for report in $BUILDFOLDER/python_cov* + do + if [ ! -e "$report" ]; then continue; fi + java -jar /home/ci/codacy-coverage-reporter-*-assembly.jar report -l Python -r $report --partial + done + java -jar /home/ci/codacy-coverage-reporter-*-assembly.jar final + java -jar /home/ci/codacy-coverage-reporter-*-assembly.jar report -l C -f -r $BUILDFOLDER/xml_coverage.xml + java -jar /home/ci/codacy-coverage-reporter-*-assembly.jar report -l CPP -f -r $BUILDFOLDER/xml_coverage.xml fi fi