forked from rusefi/rusefi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci_gcov.sh
More file actions
executable file
·59 lines (51 loc) · 2.48 KB
/
Copy pathci_gcov.sh
File metadata and controls
executable file
·59 lines (51 loc) · 2.48 KB
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
#!/bin/bash
#
# ci_gcov.sh - Generate code coverage reports for rusEFI unit tests
#
# This script is invoked by GitHub Actions (see .github/workflows/build-unit-tests.yaml)
# after unit tests have been compiled and executed with gcov instrumentation enabled.
#
# It uses gcovr to process the coverage data produced by gcc/g++ and generates
# an HTML coverage report.
#
# Prerequisites:
# - Unit tests must have been built and run with --coverage flags prior to invoking this script.
# - gcovr must be installed (pip install gcovr).
#
# Output:
# - gcov_working_area/gcov/index.html — nested HTML coverage report.
#
# Usage:
# ./ci_gcov.sh
#
# Clean up any previous coverage working directory
rm -rf gcov_working_area
# Create a fresh working area and output directory
mkdir gcov_working_area
cd gcov_working_area
mkdir gcov
echo -e "\nGenerating rusEFI unit test coverage"
source ../coverage_common.sh
# Run gcovr to collect coverage data and produce an HTML report.
# --exclude-throw-branches : exclude branches caused by throw/catch from branch coverage
# --exclude-unreachable-branches : exclude compiler-generated unreachable branches
# --decisions : enable decision (MC/DC-like) coverage analysis
# --merge-mode-functions=separate : keep separate entries for same-named functions
# --exclude '/.*/googletest/': skip Google Test framework sources
# -j4 : use 4 parallel threads for processing
# -r <root> : repository root; defaults to two levels up from gcov_working_area
# override by setting GCOVR_ROOT before invoking this script
# --html-nested : generate a nested HTML report with per-directory pages
#
# For debug use --html-details --html-single-page --verbose to generate a single html
GCOVR_ROOT="${GCOVR_ROOT:-../..}"
GCOVR_COMMON_OPTS="--exclude-throw-branches --exclude-unreachable-branches --decisions --merge-mode-functions=separate \
$GCOVR_EXCLUDES \
-j4 -r $GCOVR_ROOT"
# Generate nested HTML report for browsing coverage details.
# The '..' search path explicitly tells gcovr to look for .gcda files in the parent
# directory (unit_tests/), where build/obj/*.gcda files reside. Without this, gcovr
# defaults to searching '.' (gcov_working_area/) which is empty.
gcovr $GCOVR_COMMON_OPTS --html-nested --output gcov/index.html ..
# Generate Cobertura XML for GitHub Action coverage summary processing.
gcovr $GCOVR_COMMON_OPTS --xml-pretty --output gcov/coverage.xml ..