Skip to content

Commit 405b86a

Browse files
committed
Replace lcov -r commands with faster way
Instead of using lcov -r (which is extremely slow), first use a python script to perform bulk cleanup of the /usr/include/* coverage. Then use lcov -a to remove the duplicate entries. This has the same effect of lcov -r but runs significantly faster
1 parent c8914b9 commit 405b86a

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

Makefile.am

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,15 @@ baseline.info:
171171
$(LCOV) -c -i -d $(abs_builddir)/src -o $@
172172

173173
baseline_filtered.info: baseline.info
174-
$(LCOV) -r $< "/usr/include/*" $(LCOV_OPTS) -o $@
174+
$(abs_builddir)/contrib/filter-lcov.py "/usr/include/" $< $@
175+
$(LCOV) -a $@ $(LCOV_OPTS) -o $@
175176

176177
leveldb_baseline.info: baseline_filtered.info
177178
$(LCOV) -c -i -d $(abs_builddir)/src/leveldb -b $(abs_builddir)/src/leveldb -o $@
178179

179180
leveldb_baseline_filtered.info: leveldb_baseline.info
180-
$(LCOV) -r $< "/usr/include/*" $(LCOV_OPTS) -o $@
181+
$(abs_builddir)/contrib/filter-lcov.py "/usr/include/" $< $@
182+
$(LCOV) -a $@ $(LCOV_OPTS) -o $@
181183

182184
baseline_filtered_combined.info: leveldb_baseline_filtered.info baseline_filtered.info
183185
$(LCOV) -a $(LCOV_OPTS) leveldb_baseline_filtered.info -a baseline_filtered.info -o $@
@@ -189,7 +191,8 @@ test_bitcoin.info: baseline_filtered_combined.info
189191
$(LCOV) -z $(LCOV_OPTS) -d $(abs_builddir)/src/leveldb
190192

191193
test_bitcoin_filtered.info: test_bitcoin.info
192-
$(LCOV) -r $< "/usr/include/*" $(LCOV_OPTS) -o $@
194+
$(abs_builddir)/contrib/filter-lcov.py "/usr/include/" $< $@
195+
$(LCOV) -a $@ $(LCOV_OPTS) -o $@
193196

194197
functional_test.info: test_bitcoin_filtered.info
195198
-@TIMEOUT=15 test/functional/test_runner.py $(EXTENDED_FUNCTIONAL_TESTS)
@@ -198,7 +201,8 @@ functional_test.info: test_bitcoin_filtered.info
198201
$(LCOV) -z $(LCOV_OPTS) -d $(abs_builddir)/src/leveldb
199202

200203
functional_test_filtered.info: functional_test.info
201-
$(LCOV) -r $< "/usr/include/*" $(LCOV_OPTS) -o $@
204+
$(abs_builddir)/contrib/filter-lcov.py "/usr/include/" $< $@
205+
$(LCOV) -a $@ $(LCOV_OPTS) -o $@
202206

203207
test_bitcoin_coverage.info: baseline_filtered_combined.info test_bitcoin_filtered.info
204208
$(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a leveldb_baseline_filtered.info -a test_bitcoin_filtered.info -o $@

contrib/filter-lcov.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
5+
parser = argparse.ArgumentParser(description='Remove the coverage data from a tracefile for all files matching the pattern.')
6+
parser.add_argument('pattern', help='the pattern of files to remove')
7+
parser.add_argument('tracefile', help='the tracefile to remove the coverage data from')
8+
parser.add_argument('outfile', help='filename for the output to be written to')
9+
10+
args = parser.parse_args()
11+
tracefile = args.tracefile
12+
pattern = args.pattern
13+
outfile = args.outfile
14+
15+
in_remove = False
16+
with open(tracefile, 'r') as f:
17+
with open(outfile, 'w') as wf:
18+
for line in f:
19+
if line.startswith("SF:") and pattern in line:
20+
in_remove = True
21+
if not in_remove:
22+
wf.write(line)
23+
if line == 'end_of_record\n':
24+
in_remove = False

0 commit comments

Comments
 (0)