Browse Source

Merge #10565: [coverage] Remove subtrees and benchmarks from coverage report

d5711f4 Filter subtrees and and benchmarks from coverage report (Andrew Chow)
405b86a Replace lcov -r commands with faster way (Andrew Chow)
c8914b9 Have `make cov` optionally include branch coverage statistics (Andrew Chow)

Tree-SHA512: 9c349a7baeb7430ea586617c52f91177df58e3546d6dc573e26815ddb79e30ab1873542d85ac1daca5e1fb2c6d6c8965824b42d027b6b0496a744af57b095852
0.15
Wladimir J. van der Laan 8 years ago
parent
commit
8c2098ad12
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
  1. 51
      Makefile.am
  2. 12
      configure.ac
  3. 25
      contrib/filter-lcov.py
  4. 12
      src/util.h

51
Makefile.am

@ -59,10 +59,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-apply.sh \
$(top_srcdir)/contrib/macdeploy/detached-sig-create.sh $(top_srcdir)/contrib/macdeploy/detached-sig-create.sh
COVERAGE_INFO = baseline_filtered_combined.info baseline.info \ COVERAGE_INFO = baseline.info \
leveldb_baseline.info test_bitcoin_filtered.info total_coverage.info \ test_bitcoin_filtered.info total_coverage.info \
baseline_filtered.info functional_test.info functional_test_filtered.info \ baseline_filtered.info functional_test.info functional_test_filtered.info \
leveldb_baseline_filtered.info test_bitcoin_coverage.info test_bitcoin.info test_bitcoin_coverage.info test_bitcoin.info
dist-hook: dist-hook:
-$(GIT) archive --format=tar HEAD -- src/clientversion.cpp | $(AMTAR) -C $(top_distdir) -xf - -$(GIT) archive --format=tar HEAD -- src/clientversion.cpp | $(AMTAR) -C $(top_distdir) -xf -
@ -166,52 +166,45 @@ $(BITCOIN_CLI_BIN): FORCE
$(MAKE) -C src $(@F) $(MAKE) -C src $(@F)
if USE_LCOV if USE_LCOV
LCOV_FILTER_PATTERN=-p "/usr/include/" -p "src/leveldb/" -p "src/bench/" -p "src/univalue" -p "src/crypto/ctaes" -p "src/secp256k1"
baseline.info: baseline.info:
$(LCOV) -c -i -d $(abs_builddir)/src -o $@ $(LCOV) -c -i -d $(abs_builddir)/src -o $@
baseline_filtered.info: baseline.info 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 test_bitcoin.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_bitcoin.info: baseline_filtered_combined.info
$(MAKE) -C src/ check $(MAKE) -C src/ check
$(LCOV) -c -d $(abs_builddir)/src -t test_bitcoin -o $@ $(LCOV) -c $(LCOV_OPTS) -d $(abs_builddir)/src -t test_bitcoin -o $@
$(LCOV) -z -d $(abs_builddir)/src $(LCOV) -z $(LCOV_OPTS) -d $(abs_builddir)/src
$(LCOV) -z -d $(abs_builddir)/src/leveldb
test_bitcoin_filtered.info: test_bitcoin.info test_bitcoin_filtered.info: test_bitcoin.info
$(LCOV) -r $< "/usr/include/*" -o $@ $(abs_builddir)/contrib/filter-lcov.py $(LCOV_FILTER_PATTERN) $< $@
$(LCOV) -a $@ $(LCOV_OPTS) -o $@
functional_test.info: test_bitcoin_filtered.info functional_test.info: test_bitcoin_filtered.info
-@TIMEOUT=15 python test/functional/test_runner.py $(EXTENDED_FUNCTIONAL_TESTS) -@TIMEOUT=15 test/functional/test_runner.py $(EXTENDED_FUNCTIONAL_TESTS)
$(LCOV) -c -d $(abs_builddir)/src --t functional-tests -o $@ $(LCOV) -c $(LCOV_OPTS) -d $(abs_builddir)/src --t functional-tests -o $@
$(LCOV) -z -d $(abs_builddir)/src $(LCOV) -z $(LCOV_OPTS) -d $(abs_builddir)/src
$(LCOV) -z -d $(abs_builddir)/src/leveldb
functional_test_filtered.info: functional_test.info functional_test_filtered.info: functional_test.info
$(LCOV) -r $< "/usr/include/*" -o $@ $(abs_builddir)/contrib/filter-lcov.py $(LCOV_FILTER_PATTERN) $< $@
$(LCOV) -a $@ $(LCOV_OPTS) -o $@
test_bitcoin_coverage.info: baseline_filtered_combined.info test_bitcoin_filtered.info test_bitcoin_coverage.info: baseline_filtered.info test_bitcoin_filtered.info
$(LCOV) -a baseline_filtered.info -a leveldb_baseline_filtered.info -a test_bitcoin_filtered.info -o $@ $(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a test_bitcoin_filtered.info -o $@
total_coverage.info: baseline_filtered_combined.info test_bitcoin_filtered.info functional_test_filtered.info total_coverage.info: test_bitcoin_filtered.info functional_test_filtered.info
$(LCOV) -a baseline_filtered.info -a leveldb_baseline_filtered.info -a test_bitcoin_filtered.info -a functional_test_filtered.info -o $@ | $(GREP) "\%" | $(AWK) '{ print substr($$3,2,50) "/" $$5 }' > coverage_percent.txt $(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a test_bitcoin_filtered.info -a functional_test_filtered.info -o $@ | $(GREP) "\%" | $(AWK) '{ print substr($$3,2,50) "/" $$5 }' > coverage_percent.txt
test_bitcoin.coverage/.dirstamp: test_bitcoin_coverage.info test_bitcoin.coverage/.dirstamp: test_bitcoin_coverage.info
$(GENHTML) -s $< -o $(@D) $(GENHTML) -s $(LCOV_OPTS) $< -o $(@D)
@touch $@ @touch $@
total.coverage/.dirstamp: total_coverage.info total.coverage/.dirstamp: total_coverage.info
$(GENHTML) -s $< -o $(@D) $(GENHTML) -s $(LCOV_OPTS) $< -o $(@D)
@touch $@ @touch $@
cov: test_bitcoin.coverage/.dirstamp total.coverage/.dirstamp cov: test_bitcoin.coverage/.dirstamp total.coverage/.dirstamp

12
configure.ac

@ -158,6 +158,12 @@ AC_ARG_ENABLE([lcov],
[enable lcov testing (default is no)])], [enable lcov testing (default is no)])],
[use_lcov=yes], [use_lcov=yes],
[use_lcov=no]) [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], AC_ARG_ENABLE([glibc-back-compat],
[AS_HELP_STRING([--enable-glibc-back-compat], [AS_HELP_STRING([--enable-glibc-back-compat],
@ -442,6 +448,12 @@ if test x$use_lcov = xyes; then
[AC_MSG_ERROR("lcov testing requested but --coverage linker flag does not work")]) [AC_MSG_ERROR("lcov testing requested but --coverage linker flag does not work")])
AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"], AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"],
[AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")]) [AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")])
AC_DEFINE(USE_COVERAGE, 1, [Define this symbol if coverage is enabled])
CXXFLAGS="$CXXFLAGS -Og"
fi
if test x$use_lcov_branch != xno; then
AC_SUBST(LCOV_OPTS, "$LCOV_OPTS --rc lcov_branch_coverage=1")
fi fi
dnl Check for endianness dnl Check for endianness

25
contrib/filter-lcov.py

@ -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') as f:
with open(outfile, 'w') 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

12
src/util.h

@ -122,6 +122,17 @@ int LogPrintStr(const std::string &str);
/** Get format string from VA_ARGS for error reporting */ /** Get format string from VA_ARGS for error reporting */
template<typename... Args> std::string FormatStringFromLogArgs(const char *fmt, const Args&... args) { return fmt; } template<typename... Args> std::string FormatStringFromLogArgs(const char *fmt, const Args&... args) { return fmt; }
static inline void MarkUsed() {}
template<typename T, typename... Args> static inline void MarkUsed(const T& t, const Args&... args)
{
(void)t;
MarkUsed(args...);
}
#ifdef USE_COVERAGE
#define LogPrintf(...) do { MarkUsed(__VA_ARGS__); } while(0)
#define LogPrint(category, ...) do { MarkUsed(__VA_ARGS__); } while(0)
#else
#define LogPrintf(...) do { \ #define LogPrintf(...) do { \
std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \ std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
try { \ try { \
@ -138,6 +149,7 @@ template<typename... Args> std::string FormatStringFromLogArgs(const char *fmt,
LogPrintf(__VA_ARGS__); \ LogPrintf(__VA_ARGS__); \
} \ } \
} while(0) } while(0)
#endif
template<typename... Args> template<typename... Args>
bool error(const char* fmt, const Args&... args) bool error(const char* fmt, const Args&... args)

Loading…
Cancel
Save