Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[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/simgrid-mc-*
14 rm -f /tmp/*.so
15 rm -f /tmp/*.so.*
16 ls /tmp
17 df -h
18 echo "XXXX Let's go"
19
20 set -e
21
22 BUILDFOLDER=$WORKSPACE/build
23
24 ### Check the node installation
25
26 pkg_check() {
27   for pkg
28   do
29     if command -v "$pkg"
30     then
31        echo "$pkg is installed. Good."
32     else
33        die "please install $pkg before proceeding"
34     fi
35   done
36 }
37
38 pkg_check xsltproc gcovr ant cover2cover.py
39
40 ### Cleanup previous runs
41
42 do_cleanup() {
43   for d
44   do
45     if [ -d "$d" ]
46     then
47       rm -rf "$d" || die "Could not remove $d"
48     fi
49     mkdir "$d" || die "Could not create $d"
50   done
51 }
52
53 do_cleanup "$BUILDFOLDER"
54
55 NUMPROC="$(nproc)" || NUMPROC=1
56
57
58 cd "$BUILDFOLDER"
59 rm -rf python_cov*
60 rm -rf xml_coverage.xml
61
62 ctest -D ExperimentalStart || true
63
64 cmake -Denable_documentation=OFF \
65       -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \
66       -Denable_mallocators=ON \
67       -Denable_ns3=ON \
68       -Denable_smpi=ON -Denable_testsuite_smpi_MPICH3=ON -Denable_model-checking=ON \
69       -Denable_smpi_papi=ON \
70       -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_testsuite_smpi_MBI=ON -Denable_testsuite_McMini=ON \
71       -Denable_coverage=ON -DLTO_EXTRA_FLAG="auto" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON "$WORKSPACE"
72
73 #build with sonarqube scanner wrapper
74 /home/ci/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-outputs make -j$NUMPROC tests
75
76 export PYTHON_TOOL_OPTIONS="/usr/bin/python3-coverage run --parallel-mode --branch"
77
78 ctest --no-compress-output -D ExperimentalTest -j$NUMPROC || true
79 ctest -D ExperimentalCoverage || true
80
81 if [ -f Testing/TAG ] ; then
82
83   #convert python coverage reports in xml ones
84   cd "$BUILDFOLDER"
85   find .. -size +1c -name ".coverage*" -exec mv {} . \;
86   /usr/bin/python3-coverage combine
87   /usr/bin/python3-coverage xml -i -o ./python_coverage.xml
88
89   #convert all gcov reports to xml cobertura reports
90   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 all --gcov-ignore-errors all
91
92   cd "$WORKSPACE"
93   xsltproc "$WORKSPACE"/tools/jenkins/ctest2junit.xsl build/Testing/"$( head -n 1 < build/Testing/TAG )"/Test.xml > CTestResults_memcheck.xml
94
95   #generate sloccount report
96   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
97
98   #generate PVS-studio report
99   EXCLUDEDPATH="-e $WORKSPACE/src/3rd-party/catch.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.cq"
100   pvs-studio-analyzer analyze -f "$BUILDFOLDER"/compile_commands.json -o "$WORKSPACE"/pvs.log $EXCLUDEDPATH -j$NUMPROC
101   # Disable:
102   # V521 Such expressions using the ',' operator are dangerous. (-> commas in catch.hpp),
103   # V576 Incorrect format. (-> gives false alarms, and already checked elsewhere)
104   # V1042 This file is marked with copyleft license, which requires you to open the derived source code.
105   # V1056 The predefined identifier '__func__' always contains the string 'operator()' inside function body of the overloaded 'operator()'.
106   plog-converter -t xml -o "$WORKSPACE"/pvs.plog -d V521,V576,V1042,V1056 "$WORKSPACE"/pvs.log
107
108 fi || exit 42