-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunQC
executable file
·134 lines (109 loc) · 3.76 KB
/
runQC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# runQC
#
# runs some quality control tests for sonar
#
# written by: Oliver Cordes 2017-04-01
# changed by: Oliver Cordes 2017-06-23
DEBUG=1
# create the report directory
mkdir -p sonar
sonar_cxx_cppcheck_reportFile="sonar/sonar_cxx_cppcheck_report.xml"
sonar_cxx_vera_reportFile="sonar/sonar_cxx_vera_report.xml"
sonar_cxx_rats_reportFile="sonar/sonar_cxx_rats_report.xml"
sonar_cxx_coverage_reportFile="sonar/sonar_cxx_coverage_report.xml"
sonar_cxx_valgrind_reportFile="sonar/sonar_cxx_valgrind_report"
sonar_cxx_xunit_reportFile="sonar/sonar_cxx_xunit_report"
GCOVR_DIR=build.gcovr
# check for executables
CPPCHECK=`which cppcheck`
VERA=`which vera++`
RATS=`which rats`
GCOVR=`which gcovr`
VALGRIND=`which valgrind`
function runCppcheck
{
rm -f $sonar_cxx_cppcheck_reportFile
if [ ${CPPCHECK} ]; then
if [ "$DEBUG" == "0" ]; then
out="-q"
else
out=""
fi
#INCLUDES="-I /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 \
# -I /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include \
# -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/machine/ \
# -I /usr/include -I /usr/local/include -I /Users/ocordes/git/arctic/build"
INCLUDES="-I /usr/include -I /usr/include/c++/4.2.1 -I /usr/local/include -I /Users/ocordes/git/arctic/build"
INCLUDES="-I /usr/local/include -I /Users/ocordes/git/arctic/build"
cppcheck --force --xml --std=c++11 --enable=all --suppress=missingInclude src/ $out $INCLUDES 2> $sonar_cxx_cppcheck_reportFile
fi
} # runCppcheck
function runVera++
{
rm -f $sonar_cxx_vera_reportFile
if [ ${VERA} ]; then
export VERA_ROOT=/usr/local/lib/vera++
#find src -regex ".*\.cc\|.*\.h" | vera++ -s -c $sonar_cxx_vera_reportFile
find src -type f | vera++ -s -c $sonar_cxx_vera_reportFile
fi
} # runVera++
function runRats
{
rm -f $sonar_cxx_rats_reportFile
if [ ${RATS} ]; then
rats -w 3 --xml src > $sonar_cxx_rats_reportFile
fi
} # runrats
function runCppCoverage
{
rm -f ${sonar_cxx_coverage_reportFile}
rm -f ${sonar_cxx_xunit_reportFile}
if [ ${GCOVR} ]; then
mkdir -p ${GCOVR_DIR}
rm -rf ${GCOVR_DIR}/*
if [ -d ${GCOVR_DIR} ]; then
(cd ${GCOVR_DIR}; cmake -DCOVERAGE=1 ..; make )
(cd ${GCOVR_DIR}; find . -name "*.gcda" -delete )
#(cd ${GCOVR_DIR}; make test ) # old version
EXEs=`cd ${GCOVR_DIR}; find . -maxdepth 1 -type f -name "Boost*"`
for i in ${EXEs}; do
EXE=`basename ${i}`
if [ -x ${GCOVR_DIR}/${EXE} ]; then
${GCOVR_DIR}/${EXE} --log_format=XML --log_sink=${sonar_cxx_xunit_reportFile}_${EXE}.xml --log_level=all --report_level=no
fi
done
fi
gcovr -r . --exclude '.*/unittests/.*' --xml -o $sonar_cxx_coverage_reportFile
fi
}
function runValgrind
{
rm -f ${sonar_cxx_valgrind_reportFile}*.xml
if [ ${VALGRIND} ]; then
if [ -d ${GCOVR_DIR} ]; then
EXEs=`cd ${GCOVR_DIR}; find . -maxdepth 1 -type f -name "Boost*"`
for i in ${EXEs}; do
EXE=`basename ${i}`
if [ -x ${GCOVR_DIR}/${EXE} ]; then
${VALGRIND} --leak-check=full --track-origins=yes --xml=yes --xml-file=${sonar_cxx_valgrind_reportFile}_${EXE}.xml ${GCOVR_DIR}/${EXE}
#${VALGRIND} --leak-check=full --xml=yes --xml-file=${sonar_cxx_valgrind_reportFile}_${EXE}.xml ${GCOVR_DIR}/${EXE}
fi
done
else
echo "No executables for valgrind found."
fi
fi
}
# main
# doing some measurements
SECONDS=0
# run all commands
runCppcheck
runVera++
runRats
runCppCoverage
runValgrind
# finished!
duration=$SECONDS
echo "All tests don in $(($duration / 60)) minutes and $(($duration % 60)) seconds!"