aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2017-06-06 17:26:56 -0700
committerAndrew Chow <achow101-github@achow101.com>2017-06-09 12:24:48 -0700
commit405b86a92aee4f2ddb6710bfe07ff714f2afcfa2 (patch)
tree9c2550e3b69ab1c34a61240c70b6754ec5e1fdcf
parentc8914b9dbbf6106dac3c62769f7ce3bacd8fbf9b (diff)
downloadbitcoin-405b86a92aee4f2ddb6710bfe07ff714f2afcfa2.tar.xz
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
-rw-r--r--Makefile.am12
-rwxr-xr-xcontrib/filter-lcov.py24
2 files changed, 32 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am
index 27d9f5af81..88879b9e42 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -171,13 +171,15 @@ baseline.info:
$(LCOV) -c -i -d $(abs_builddir)/src -o $@
baseline_filtered.info: baseline.info
- $(LCOV) -r $< "/usr/include/*" $(LCOV_OPTS) -o $@
+ $(abs_builddir)/contrib/filter-lcov.py "/usr/include/" $< $@
+ $(LCOV) -a $@ $(LCOV_OPTS) -o $@
leveldb_baseline.info: baseline_filtered.info
$(LCOV) -c -i -d $(abs_builddir)/src/leveldb -b $(abs_builddir)/src/leveldb -o $@
leveldb_baseline_filtered.info: leveldb_baseline.info
- $(LCOV) -r $< "/usr/include/*" $(LCOV_OPTS) -o $@
+ $(abs_builddir)/contrib/filter-lcov.py "/usr/include/" $< $@
+ $(LCOV) -a $@ $(LCOV_OPTS) -o $@
baseline_filtered_combined.info: leveldb_baseline_filtered.info baseline_filtered.info
$(LCOV) -a $(LCOV_OPTS) leveldb_baseline_filtered.info -a baseline_filtered.info -o $@
@@ -189,7 +191,8 @@ test_bitcoin.info: baseline_filtered_combined.info
$(LCOV) -z $(LCOV_OPTS) -d $(abs_builddir)/src/leveldb
test_bitcoin_filtered.info: test_bitcoin.info
- $(LCOV) -r $< "/usr/include/*" $(LCOV_OPTS) -o $@
+ $(abs_builddir)/contrib/filter-lcov.py "/usr/include/" $< $@
+ $(LCOV) -a $@ $(LCOV_OPTS) -o $@
functional_test.info: test_bitcoin_filtered.info
-@TIMEOUT=15 test/functional/test_runner.py $(EXTENDED_FUNCTIONAL_TESTS)
@@ -198,7 +201,8 @@ functional_test.info: test_bitcoin_filtered.info
$(LCOV) -z $(LCOV_OPTS) -d $(abs_builddir)/src/leveldb
functional_test_filtered.info: functional_test.info
- $(LCOV) -r $< "/usr/include/*" $(LCOV_OPTS) -o $@
+ $(abs_builddir)/contrib/filter-lcov.py "/usr/include/" $< $@
+ $(LCOV) -a $@ $(LCOV_OPTS) -o $@
test_bitcoin_coverage.info: baseline_filtered_combined.info test_bitcoin_filtered.info
$(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a leveldb_baseline_filtered.info -a test_bitcoin_filtered.info -o $@
diff --git a/contrib/filter-lcov.py b/contrib/filter-lcov.py
new file mode 100755
index 0000000000..ce2966c43d
--- /dev/null
+++ b/contrib/filter-lcov.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+
+import argparse
+
+parser = argparse.ArgumentParser(description='Remove the coverage data from a tracefile for all files matching the pattern.')
+parser.add_argument('pattern', help='the pattern of files to remove')
+parser.add_argument('tracefile', help='the tracefile to remove the coverage data from')
+parser.add_argument('outfile', help='filename for the output to be written to')
+
+args = parser.parse_args()
+tracefile = args.tracefile
+pattern = args.pattern
+outfile = args.outfile
+
+in_remove = False
+with open(tracefile, 'r') as f:
+ with open(outfile, 'w') as wf:
+ for line in f:
+ if line.startswith("SF:") and pattern in line:
+ in_remove = True
+ if not in_remove:
+ wf.write(line)
+ if line == 'end_of_record\n':
+ in_remove = False