Logo AND Algorithmique Numérique Distribuée

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