Skip to content

Commit

Permalink
Add coverage support scoped to only the zcash-gtest run; invoke with …
Browse files Browse the repository at this point in the history
…make zcash-cov; make cov is a superset.
  • Loading branch information
nejucomo committed Apr 18, 2016
1 parent 3ab0c1a commit d16d5ef
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ build

#lcov
*.gcno
*.gcda
/*.info
test_bitcoin.coverage/
zcash-gtest.coverage/
total.coverage/
coverage_percent.txt

Expand Down
26 changes: 22 additions & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,23 @@ baseline_filtered_combined.info: leveldb_baseline_filtered.info baseline_filtere
$(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/ bitcoin_test_check
$(LCOV) -c -d $(abs_builddir)/src -t test_bitcoin -o $@
$(LCOV) -z -d $(abs_builddir)/src
$(LCOV) -z -d $(abs_builddir)/src/leveldb

test_bitcoin_filtered.info: test_bitcoin.info
$(LCOV) -r $< "/usr/include/*" -o $@

zcash-gtest.info: baseline_filtered_combined.info
$(MAKE) -C src/ zcash-gtest_check
$(LCOV) -c -d $(abs_builddir)/src -t test_bitcoin -o $@
$(LCOV) -z -d $(abs_builddir)/src
$(LCOV) -z -d $(abs_builddir)/src/leveldb

zcash-gtest_filtered.info: zcash-gtest.info
$(LCOV) -r $< "/usr/include/*" -o $@

block_test.info: test_bitcoin_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
Expand All @@ -181,18 +190,27 @@ block_test_filtered.info: block_test.info
test_bitcoin_coverage.info: baseline_filtered_combined.info test_bitcoin_filtered.info
$(LCOV) -a baseline_filtered.info -a leveldb_baseline_filtered.info -a test_bitcoin_filtered.info -o $@

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

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

test_bitcoin.coverage/.dirstamp: test_bitcoin_coverage.info
$(GENHTML) -s $< -o $(@D)
@touch $@

zcash-gtest.coverage/.dirstamp: zcash-gtest_coverage.info
$(GENHTML) -s $< -o $(@D)
@touch $@

cov-zcash: zcash-gtest.coverage/.dirstamp

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

cov: test_bitcoin.coverage/.dirstamp total.coverage/.dirstamp
cov: test_bitcoin.coverage/.dirstamp cov-zcash total.coverage/.dirstamp

endif

Expand Down
33 changes: 30 additions & 3 deletions zcutil/build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
#!/bin/sh
set -ex
#!/bin/bash

set -eu -o pipefail

if [ "x$*" = 'x--help' ]
then
cat <<EOF
Usage:
$0 --help
Show this help message and exit.
$0 [ --enable-lcov ] [ MAKEARGS... ]
Build Zcash and most of its transitive dependencies from
source. MAKEARGS are applied to both dependencies and Zcash itself. If
--enable-lcov is passed, Zcash is configured to add coverage
instrumentation, thus enabling "make cov" to work.
EOF
exit 0
fi

set -x
cd "$(dirname "$(readlink -f "$0")")/.."

# If --enable-lcov is the first argument, enable lcov coverage support:
LCOV_ARG=''
if [ "x${1:-}" = 'x--enable-lcov' ]
then
LCOV_ARG='--enable-lcov'
shift
fi

# BUG: parameterize the platform/host directory:
PREFIX="$(pwd)/depends/x86_64-unknown-linux-gnu/"

make "$@" -C ./depends/ V=1 NO_QT=1
./autogen.sh
./configure --prefix="${PREFIX}" --with-gui=no CXXFLAGS='-O0 -g'
./configure --prefix="${PREFIX}" --with-gui=no "$LCOV_ARG" CXXFLAGS='-O0 -g'
make "$@" V=1

0 comments on commit d16d5ef

Please sign in to comment.