test/coverage: demangle C++ function names before merging coverage files

This commit is contained in:
Matthias Ringwald 2020-09-21 12:04:18 +02:00
parent 410e1b0659
commit cf7023dfc2
2 changed files with 36 additions and 5 deletions

View File

@ -89,6 +89,8 @@ test-coverage-ble: subdirs
$(MAKE) test-ble
# collect traces
lcov --capture --rc lcov_branch_coverage=1 --directory . --exclude "/Applications/*" --exclude "/Library/*" --exclude "/usr/*" --exclude "*/test/*" --output-file coverage-unit-ble.info
# demangle
python3 coverage_demangle.py coverage-unit-ble.info
test-coverage: subdirs
# delete trace data
@ -97,10 +99,13 @@ test-coverage: subdirs
$(MAKE) test
# collect traces
lcov --capture --rc lcov_branch_coverage=1 --directory . --exclude "/Applications/*" --exclude "/Library/*" --exclude "/usr/*" --exclude "*/test/*" --output-file coverage-unit.info
# demangle
python3 coverage_demangle.py coverage-unit.info
coverage: test-coverage test-coverage-ble
# download pts coverage and fix paths
curl https://bluekitchen-gmbh.com/btstack/develop/coverage-pts.info | sed 's|buildbot-worker/auto-pts/btstack|buildbot-worker/test-develop/build|' > coverage-pts.info
# curl https://bluekitchen-gmbh.com/btstack/develop/coverage-pts.info | sed 's|buildbot-worker/auto-pts/btstack|buildbot-worker/test-develop/build|' > coverage-pts.info
curl https://bluekitchen-gmbh.com/btstack/develop/coverage-pts.info | sed 's|buildbot-worker/auto-pts/btstack|Projects/btstack|' > coverage-pts.info
# combine unit[-ble] and pts
lcov --rc lcov_branch_coverage=1 -a coverage-pts.info -a coverage-unit.info --output-file coverage.info
@ -110,8 +115,11 @@ coverage: test-coverage test-coverage-ble
./coverage_subset_bat.py coverage-ble.info coverage-bat.info
./coverage_subset_bat.py coverage-unit-ble.info coverage-unit-bat.info
./coverage_subset_bat.py coverage-pts.info coverage-pts-bat.info
# generate html output
genhtml coverage-unit.info --branch-coverage --output-directory coverage-unit
genhtml coverage-unit-bat.info --branch-coverage --output-directory coverage-unit-bat
genhtml coverage-bat.info --branch-coverage --output-directory coverage-bat
genhtml coverage.info --branch-coverage --output-directory coverage
genhtml coverage-unit.info --branch-coverage --demangle-cpp --output-directory coverage-unit
genhtml coverage-unit-bat.info --branch-coverage --demangle-cpp --output-directory coverage-unit-bat
genhtml coverage-bat.info --branch-coverage --demangle-cpp --output-directory coverage-bat
genhtml coverage.info --branch-coverage --demangle-cpp --output-directory coverage
genhtml coverage-pts-bat.info --branch-coverage --demangle-cpp --output-directory coverage-pts-bat

23
test/coverage_demangle.py Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python3
#
# Demangle C++ function names in lcov .info reports
#
# Copyright 2020 BlueKitchen GmbH
#
import cxxfilt
import fileinput
import sys
import re
for line in fileinput.input(inplace=1):
match = re.match('(FN|FNDA):(\d.*),(\w*)', line)
if match:
(key, line_no, mangled) = match.groups()
demangled = cxxfilt.demangle(mangled)
match = re.match('(\w+)\(.*\)', demangled)
if (match):
fn = match.groups()[0]
sys.stdout.write('%s:%s,%s\n' % (key, line_no, fn))
continue
sys.stdout.write(line)