Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove Java bindings. They are not updated since maybe 10 years
[simgrid.git] / tools / jenkins / Coverage.sh
1 #!/usr/bin/env sh
2
3 die() {
4     echo "$@"
5     exit 1
6 }
7
8 [ -n "$WORKSPACE" ] || die "No WORKSPACE"
9 [ -d "$WORKSPACE" ] || die "WORKSPACE ($WORKSPACE) does not exist"
10
11 echo "XXXX Cleanup previous attempts. Remaining content of /tmp:"
12 rm -f /tmp/cc*
13 rm -f /tmp/*.so
14 rm -f /tmp/*.so.*
15 rm -rf /tmp/jvm-*
16 find "$WORKSPACE" -name "hs_err_pid*.log" -exec rm -f {} +
17 ls /tmp
18 df -h
19 echo "XXXX Let's go"
20
21 set -e
22
23 BUILDFOLDER=$WORKSPACE/build
24
25 ### Check the node installation
26
27 pkg_check() {
28   for pkg
29   do
30     if command -v "$pkg"
31     then
32        echo "$pkg is installed. Good."
33     else
34        die "please install $pkg before proceeding"
35     fi
36   done
37 }
38
39 pkg_check xsltproc gcovr ant cover2cover.py
40
41 ### Cleanup previous runs
42
43 do_cleanup() {
44   for d
45   do
46     if [ -d "$d" ]
47     then
48       rm -rf "$d" || die "Could not remove $d"
49     fi
50     mkdir "$d" || die "Could not create $d"
51   done
52 }
53
54 do_cleanup "$BUILDFOLDER"
55
56 NUMPROC="$(nproc)" || NUMPROC=1
57
58
59 cd "$BUILDFOLDER"
60 rm -rf jacoco_cov*
61 rm -rf python_cov*
62 rm -rf xml_coverage.xml
63
64 ctest -D ExperimentalStart || true
65
66 cmake -Denable_documentation=OFF \
67       -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \
68       -Denable_mallocators=ON \
69       -Denable_ns3=ON \
70       -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_model-checking=ON \
71       -Denable_smpi_papi=ON \
72       -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_smpi_MBI_testsuite=ON \
73       -Denable_coverage=ON -DLTO_EXTRA_FLAG="auto" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON "$WORKSPACE"
74
75 #build with sonarqube scanner wrapper
76 /home/ci/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-outputs make -j$NUMPROC tests
77 JACOCO_PATH="/usr/local/share/jacoco"
78 export JAVA_TOOL_OPTIONS="-javaagent:${JACOCO_PATH}/lib/jacocoagent.jar"
79
80 export PYTHON_TOOL_OPTIONS="/usr/bin/python3-coverage run --parallel-mode --branch"
81
82 ctest --no-compress-output -D ExperimentalTest -j$NUMPROC || true
83 ctest -D ExperimentalCoverage || true
84
85 unset JAVA_TOOL_OPTIONS
86 if [ -f Testing/TAG ] ; then
87
88   files=$( find . -size +1c -name "jacoco.exec" )
89   i=0
90   for file in $files
91   do
92     sourcepath=$( dirname "$file" )
93     #convert jacoco reports in xml ones
94     ant -f "$WORKSPACE"/tools/jenkins/jacoco.xml -Dexamplesrcdir="$WORKSPACE" -Dbuilddir="$BUILDFOLDER"/"${sourcepath}" -Djarfile="$BUILDFOLDER"/simgrid.jar -Djacocodir=${JACOCO_PATH}/lib
95     #convert jacoco xml reports in cobertura xml reports
96     cover2cover.py "$BUILDFOLDER"/"${sourcepath}"/report.xml .. ../src/bindings/java src/bindings/java > "$BUILDFOLDER"/java_coverage_${i}.xml
97     #save jacoco xml report as sonar only allows it
98     mv "$BUILDFOLDER"/"${sourcepath}"/report.xml "$BUILDFOLDER"/jacoco_cov_${i}.xml
99     i=$((i + 1))
100   done
101
102   #convert python coverage reports in xml ones
103   cd "$BUILDFOLDER"
104   find .. -size +1c -name ".coverage*" -exec mv {} . \;
105   /usr/bin/python3-coverage combine
106   /usr/bin/python3-coverage xml -i -o ./python_coverage.xml
107
108   #convert all gcov reports to xml cobertura reports
109   gcovr -r "$WORKSPACE" --xml-pretty -e "$WORKSPACE"/teshsuite -e MBI -e "$WORKSPACE"/examples/smpi/NAS -e "$WORKSPACE"/examples/smpi/mc -u -o xml_coverage.xml --gcov-ignore-parse-errors
110
111   cd "$WORKSPACE"
112   xsltproc "$WORKSPACE"/tools/jenkins/ctest2junit.xsl build/Testing/"$( head -n 1 < build/Testing/TAG )"/Test.xml > CTestResults_memcheck.xml
113
114   #generate sloccount report
115   sloccount --duplicates --wide --details "$WORKSPACE" | grep -v -e '.git' -e 'mpich3-test' -e 'sloccount.sc' -e 'build/' -e 'xml_coverage.xml' -e 'CTestResults_memcheck.xml' -e 'DynamicAnalysis.xml' > "$WORKSPACE"/sloccount.sc
116
117   #generate PVS-studio report
118   EXCLUDEDPATH="-e $WORKSPACE/src/include/catch.hpp -e $WORKSPACE/src/include/xxhash.hpp -e $WORKSPACE/teshsuite/smpi/mpich3-test/ -e *_dtd.c -e *_dtd.h -e *.yy.c -e *.tab.cacc -e *.tab.hacc -e $WORKSPACE/src/smpi/colls/ -e $WORKSPACE/examples/smpi/NAS/ -e $WORKSPACE/examples/smpi/gemm/gemm.c -e $WORKSPACE/src/msg/ -e $WORKSPACE/include/msg/ -e $WORKSPACE/examples/deprecated/ -e $WORKSPACE/teshsuite/msg/"
119   pvs-studio-analyzer analyze -f "$BUILDFOLDER"/compile_commands.json -o "$WORKSPACE"/pvs.log $EXCLUDEDPATH -j$NUMPROC
120   # Disable:
121   # V521 Such expressions using the ',' operator are dangerous. (-> commas in catch.hpp),
122   # V576 Incorrect format. (-> gives false alarms, and already checked elsewhere)
123   # V1042 This file is marked with copyleft license, which requires you to open the derived source code.
124   # V1056 The predefined identifier '__func__' always contains the string 'operator()' inside function body of the overloaded 'operator()'.
125   plog-converter -t xml -o "$WORKSPACE"/pvs.plog -d V521,V576,V1042,V1056 "$WORKSPACE"/pvs.log
126
127 fi || exit 42