Skip to content

Commit 517d30b

Browse files
committed
contrib: fix test_deterministic_coverage.sh script for out-of-tree builds
This change also enables to run the script for anywhere within the repository.
1 parent f93d6cb commit 517d30b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

contrib/devtools/test_deterministic_coverage.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ NON_DETERMINISTIC_TESTS=(
3434
"wallet_tests/wallet_disableprivkeys" # validation.cpp: if (signals.CallbacksPending() > 10)
3535
)
3636

37-
TEST_BITCOIN_BINARY="src/test/test_bitcoin"
37+
TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)}
38+
BUILDDIR=${BUILDDIR:-$TOPDIR/build}
39+
TEST_BITCOIN_BINARY="$BUILDDIR/src/test/test_bitcoin"
3840

3941
print_usage() {
4042
echo "Usage: $0 [custom test filter (default: all but known non-deterministic tests)] [number of test runs (default: 2)]"
@@ -86,7 +88,7 @@ if [[ ! -e ${TEST_BITCOIN_BINARY} ]]; then
8688
fi
8789

8890
get_file_suffix_count() {
89-
find src/ -type f -name "*.$1" | wc -l
91+
find "$BUILDDIR/src/" -type f -name "*.$1" | wc -l
9092
}
9193

9294
if [[ $(get_file_suffix_count gcno) == 0 ]]; then
@@ -102,7 +104,7 @@ TEST_RUN_ID=0
102104
while [[ ${TEST_RUN_ID} -lt ${N_TEST_RUNS} ]]; do
103105
TEST_RUN_ID=$((TEST_RUN_ID + 1))
104106
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Measuring coverage, run #${TEST_RUN_ID} of ${N_TEST_RUNS}"
105-
find src/ -type f -name "*.gcda" -exec rm {} \;
107+
find "$BUILDDIR/src/" -type f -name "*.gcda" -exec rm {} \;
106108
if [[ $(get_file_suffix_count gcda) != 0 ]]; then
107109
echo "Error: Stale *.gcda files found. Exiting."
108110
exit 1
@@ -119,7 +121,7 @@ while [[ ${TEST_RUN_ID} -lt ${N_TEST_RUNS} ]]; do
119121
exit 1
120122
fi
121123
GCOVR_TEMPFILE=$(mktemp)
122-
if ! gcovr --gcov-executable "${GCOV_EXECUTABLE}" -r src/ > "${GCOVR_TEMPFILE}"; then
124+
if ! gcovr --gcov-executable "${GCOV_EXECUTABLE}" -r "$TOPDIR/src/" "$BUILDDIR/src/" > "${GCOVR_TEMPFILE}"; then
123125
echo "Error: gcovr failed. Output written to ${GCOVR_TEMPFILE}. Exiting."
124126
exit 1
125127
fi

0 commit comments

Comments
 (0)