Skip to content

Commit

Permalink
Build: Update coverage build target(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuzzbawls authored and KolbyML committed Mar 14, 2020
1 parent 0c1a764 commit 9be21de
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 36 deletions.
58 changes: 25 additions & 33 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ OSX_PACKAGING = $(OSX_DEPLOY_SCRIPT) $(OSX_FANCY_PLIST) $(OSX_INSTALLER_ICONS) \
$(top_srcdir)/contrib/macdeploy/detached-sig-apply.sh \
$(top_srcdir)/contrib/macdeploy/detached-sig-create.sh

COVERAGE_INFO = baseline_filtered_combined.info baseline.info block_test.info \
leveldb_baseline.info test_phore_filtered.info total_coverage.info \
baseline_filtered.info block_test_filtered.info \
leveldb_baseline_filtered.info test_phore_coverage.info test_phore.info
COVERAGE_INFO = baseline.info \
test_phore_filtered.info total_coverage.info \
baseline_filtered.info functional_test.info functional_test_filtered.info \
test_phore_coverage.info test_phore.info

dist-hook:
-$(MAKE) -C $(top_distdir)/src/leveldb clean
Expand Down Expand Up @@ -167,53 +167,45 @@ $(BITCOIN_CLI_BIN): FORCE
$(MAKE) -C src $(@F)

if USE_LCOV
LCOV_FILTER_PATTERN=-p "/usr/include/" -p "src/leveldb/" -p "src/univalue" -p "src/secp256k1"

baseline.info:
$(LCOV) -c -i -d $(abs_builddir)/src -o $@

baseline_filtered.info: baseline.info
$(LCOV) -r $< "/usr/include/*" -o $@
$(abs_builddir)/contrib/filter-lcov.py $(LCOV_FILTER_PATTERN) $< $@
$(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/*" -o $@

baseline_filtered_combined.info: leveldb_baseline_filtered.info baseline_filtered.info
$(LCOV) -a leveldb_baseline_filtered.info -a baseline_filtered.info -o $@

test_phore.info: baseline_filtered_combined.info
test_phore.info: baseline_filtered.info
$(MAKE) -C src/ check
$(LCOV) -c -d $(abs_builddir)/src -t test_phore -o $@
$(LCOV) -z -d $(abs_builddir)/src
$(LCOV) -z -d $(abs_builddir)/src/leveldb
$(LCOV) -c $(LCOV_OPTS) -d $(abs_builddir)/src -t test_phore -o $@
$(LCOV) -z $(LCOV_OPTS) -d $(abs_builddir)/src

test_phore_filtered.info: test_phore.info
$(LCOV) -r $< "/usr/include/*" -o $@
$(abs_builddir)/contrib/filter-lcov.py $(LCOV_FILTER_PATTERN) $< $@
$(LCOV) -a $@ $(LCOV_OPTS) -o $@

block_test.info: test_phore_filtered.info
$(MKDIR_P) qa/tmp
-@TIMEOUT=15 qa/pull-tester/run-bitcoind-for-test.sh $(JAVA) -jar $(JAVA_COMPARISON_TOOL) qa/tmp/compTool 0
$(LCOV) -c -d $(abs_builddir)/src --t BitcoinJBlockTest -o $@
$(LCOV) -z -d $(abs_builddir)/src
$(LCOV) -z -d $(abs_builddir)/src/leveldb
functional_test.info: test_phore_filtered.info
-@TIMEOUT=15 test/functional/test_runner.py $(EXTENDED_FUNCTIONAL_TESTS)
$(LCOV) -c $(LCOV_OPTS) -d $(abs_builddir)/src --t functional-tests -o $@
$(LCOV) -z $(LCOV_OPTS) -d $(abs_builddir)/src

block_test_filtered.info: block_test.info
$(LCOV) -r $< "/usr/include/*" -o $@
functional_test_filtered.info: functional_test.info
$(abs_builddir)/contrib/filter-lcov.py $(LCOV_FILTER_PATTERN) $< $@
$(LCOV) -a $@ $(LCOV_OPTS) -o $@

test_phore_coverage.info: baseline_filtered_combined.info test_phore_filtered.info
$(LCOV) -a baseline_filtered.info -a leveldb_baseline_filtered.info -a test_phore_filtered.info -o $@
test_phore_coverage.info: baseline_filtered.info test_phore_filtered.info
$(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a test_phore_filtered.info -o $@

total_coverage.info: baseline_filtered_combined.info test_phore_filtered.info block_test_filtered.info
$(LCOV) -a baseline_filtered.info -a leveldb_baseline_filtered.info -a test_phore_filtered.info -a block_test_filtered.info -o $@ | $(GREP) "\%" | $(AWK) '{ print substr($$3,2,50) "/" $$5 }' > coverage_percent.txt
total_coverage.info: test_phore_filtered.info functional_test_filtered.info
$(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a test_phore_filtered.info -a functional_test_filtered.info -o $@ | $(GREP) "\%" | $(AWK) '{ print substr($$3,2,50) "/" $$5 }' > coverage_percent.txt

test_phore.coverage/.dirstamp: test_phore_coverage.info
$(GENHTML) -s $< -o $(@D)
$(GENHTML) -s $(LCOV_OPTS) $< -o $(@D)
@touch $@

total.coverage/.dirstamp: total_coverage.info
$(GENHTML) -s $< -o $(@D)
$(GENHTML) -s $(LCOV_OPTS) $< -o $(@D)
@touch $@

cov: test_phore.coverage/.dirstamp total.coverage/.dirstamp
Expand Down
17 changes: 14 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ AC_ARG_ENABLE([lcov],
[use_lcov=$enableval],
[use_lcov=no])

AC_ARG_ENABLE([lcov-branch-coverage],
[AS_HELP_STRING([--enable-lcov-branch-coverage],
[enable lcov testing branch coverage (default is no)])],
[use_lcov_branch=yes],
[use_lcov_branch=no])

AC_ARG_ENABLE([glibc-back-compat],
[AS_HELP_STRING([--enable-glibc-back-compat],
[enable backwards compatibility with glibc])],
Expand Down Expand Up @@ -435,8 +441,12 @@ if test x$use_lcov = xyes; then
CXXFLAGS="$CXXFLAGS -Og"
fi

dnl Require little endian
AC_C_BIGENDIAN([AC_MSG_ERROR("Big Endian not supported")])
if test x$use_lcov_branch != xno; then
AC_SUBST(LCOV_OPTS, "$LCOV_OPTS --rc lcov_branch_coverage=1")
fi

dnl Check for endianness
AC_C_BIGENDIAN

dnl Check for pthread compile/link requirements
AX_PTHREAD
Expand Down Expand Up @@ -1148,7 +1158,8 @@ AC_CONFIG_FILES([Makefile src/Makefile share/setup.nsi share/qt/Info.plist src/t
AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh])
AC_CONFIG_FILES([qa/pull-tester/tests-config.sh],[chmod +x qa/pull-tester/tests-config.sh])
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
AC_CONFIG_FILES([doc/Doxyfile])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])
AC_CONFIG_LINKS([contrib/filter-lcov.py:contrib/filter-lcov.py])

dnl boost's m4 checks do something really nasty: they export these vars. As a
dnl result, they leak into secp256k1's configure and crazy things happen.
Expand Down
25 changes: 25 additions & 0 deletions contrib/filter-lcov.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/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', '-p', action='append', help='the pattern of files to remove', required=True)
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', encoding="utf8") as f:
with open(outfile, 'w', encoding="utf8") as wf:
for line in f:
for p in pattern:
if line.startswith("SF:") and p in line:
in_remove = True
if not in_remove:
wf.write(line)
if line == 'end_of_record\n':
in_remove = False

0 comments on commit 9be21de

Please sign in to comment.