This repository was archived by the owner on Jul 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathtest_coverage.sh
executable file
·96 lines (84 loc) · 2.81 KB
/
test_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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Copyright 2018-2020 Google LLC
#
# This is part of the Google Cloud IoT Device SDK for Embedded C.
# It is licensed under the BSD 3-Clause license; you may not use this file
# except in compliance with the License.
#
# You may obtain a copy of the License at:
# https://opensource.org/licenses/BSD-3-Clause
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/bin/bash
echo
echo
echo =======================================
echo = Building Test Coverage HTML reports =
echo =======================================
echo
echo Checking for installed dependencies...
echo
if hash gcov 2>/dev/null; then
echo gcov detected in environment.
else
echo " **ERROR**"
echo " gcov is required to create test coverage report."
echo " gcov is provided as part of the gnu gcc toolchain on ubuntu."
echo
exit -1
fi
echo
if hash lcov 2>/dev/null; then
echo locv detected in environment.
else
echo " **ERROR**"
echo " lcov is required to create test coverage report."
echo " try: sudo apt-get install lcov"
echo
exit -1
fi
echo
echo cleaning...
make clean
rm -rf test_coverage
mkdir test_coverage
echo
echo building and running unit tests...
make IOTC_COMMON_COMPILER_FLAGS="-fprofile-arcs -ftest-coverage" utests -j
echo
echo generating unit tests report...
lcov --capture --directory . --output-file test_coverage/utest_coverage.info
lcov --remove test_coverage/utest_coverage.info '*/src/import/*' '*/src/tests/*' '*/src/bsp/*' -o test_coverage/utest_coverage.info
genhtml test_coverage/utest_coverage.info --output-directory test_coverage/utests
rm -f test_coverage/utest_coverage.info
echo
echo cleaning intermediate files...
rm -f iotc_utests.gcda
rm -f iotc_utests.gcno
rm -f iotc_libiotc_driver.gcno
echo
echo cleaning build...
make clean
echo
echo building and running integration testsxi
make IOTC_COMMON_COMPILER_FLAGS="-fprofile-arcs -ftest-coverage" itests -j
echo
echo generating integration test report...
lcov --capture --directory . --output-file test_coverage/itest_coverage.info
lcov --remove test_coverage/itest_coverage.info '*/src/import/*' '*/tests/*' '*/src/bsp/*' -o test_coverage/itest_coverage.info
genhtml test_coverage/itest_coverage.info --output-directory test_coverage/itests
rm -f test_coverage/itest_coverage.info
echo
echo cleaning intermediate files...
rm -f iotc_utests.gcda
rm -f iotc_utests.gcno
rm -f iotc_libiotc_driver.gcno
# linking .o files built with profile-arcs and test-coverage in a subsequent
# standard build will create link errors, so clean them up for convenience.
echo
echo cleaning build...
make clean
echo Done!