-
Notifications
You must be signed in to change notification settings - Fork 138
/
collect_coverage.sh
executable file
·79 lines (71 loc) · 2.27 KB
/
collect_coverage.sh
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
#!/bin/bash
# Run this at the root of a Duo Unix directory that has been compiled with coverage
# reporting turned on
if ! [ -x "$(command -v gcovr)" ]; then
echo "Missing gcovr. Please pip install"
exit 1
fi
mkdir -p coverage
# This section is necessary because otherwise coverage files are created with a
# file mode of 0100 (due to an issue with linking to compat) which causes
# errors. To "get ahead of this" we are creating the coverage files and setting
# their file mode to 700 this allows us to have full coverage and avoid errors.
mkdir -p tests/.libs
GCDA_FILES=(
"/vagrant/pam_duo/.libs/pam_duo_private.gcda"
"/vagrant/pam_duo/.libs/pam_duo.gcda"
"/vagrant/tests/testpam.gcda"
"/vagrant/tests/.libs/testpam_preload.gcda"
"/vagrant/pam_duo/.libs/pam_duo_private.gcda"
"/vagrant/pam_duo/.libs/pam_duo.gcda"
"/vagrant/tests/testpam.gcda"
"/vagrant/tests/.libs/testpam_preload.gcda"
"/vagrant/lib/.libs/http_parser.gcda"
"/vagrant/lib/.libs/urlenc.gcda"
"/vagrant/lib/.libs/ini.gcda"
"/vagrant/lib/.libs/https.gcda"
"/vagrant/lib/.libs/duo.gcda"
)
for i in "${GCDA_FILES[@]}"; do
rm -f "$i"; touch "$i"; chmod 700 "$i"
done
# end weird permission hacking
make check
gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o coverage/coverage.xml --root .
if [ -f pam_duo/pam_duo.gcno ]; then
(
cd pam_duo || return
gcov pam_duo.c -o .libs
gcovr --txt
gcovr --html-details pam_duo.html
rm -f .libs/*.gcda
)
mv pam_duo/*.{css,html} coverage
else
echo "No coverage information found for pam_duo.c"
fi
if [ -f login_duo/login_duo.gcno ]; then
(
cd login_duo || return
gcov login_duo.c
gcovr --txt
gcovr --html-details login_duo.html
gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o login_duo.xml --root ${CI_PROJECT_DIR}
rm -f *.gcda
)
mv login_duo/*.{css,html} coverage
else
echo "No coverage information found for login_duo.c"
fi
if [ -f lib/duo.gcno ]; then
(
cd lib || return
gcov duo.c -o .libs
gcovr --txt
gcovr --html-details duo.html
rm -f .libs/*.gcda
)
mv lib/*.{css,html} coverage
else
echo "No coverage information found for duo.c"
fi