Add script checking for deterministic line coverage in unit tests.
Context: #14343 (“coverage reports non-deterministic”)
When the coverage is deterministic this script can be invoked from Travis to guard against regressions, but left inactive for now.
Output in case of determinism:
0$ contrib/test_deterministic_coverage.sh 2
1[2019-01-30 20:08:46] Measuring coverage, run [#1](/bitcoin-bitcoin/1/) of 2
2[2019-01-30 20:10:45] Measuring coverage, run [#2](/bitcoin-bitcoin/2/) of 2
3
4Coverage test passed: Deterministic coverage across 2 runs.
Output in case of non-determinism:
0$ contrib/test_deterministic_coverage.sh 2
1[2019-01-30 20:08:46] Measuring coverage, run [#1](/bitcoin-bitcoin/1/) of 2
2[2019-01-30 20:10:45] Measuring coverage, run [#2](/bitcoin-bitcoin/2/) of 2
3
4The line coverage is non-deterministic between runs.
5
6The test suite must be deterministic in the sense that the set of lines executed at least
7once must be identical between runs. This is a neccessary condition for meaningful coverage
8measuring.
9
10--- gcovr.run-1.txt 2019-01-30 23:14:07.419418694 +0100
11+++ gcovr.run-2.txt 2019-01-30 23:15:57.998811282 +0100
12@@ -471,7 +471,7 @@
13 test/crypto_tests.cpp 270 270 100%
14 test/cuckoocache_tests.cpp 142 142 100%
15 test/dbwrapper_tests.cpp 148 148 100%
16-test/denialofservice_tests.cpp 225 225 100%
17+test/denialofservice_tests.cpp 225 224 99% 363
18 test/descriptor_tests.cpp 116 116 100%
19 test/fs_tests.cpp 24 3 12% 14,16-17,19-20,23,25-26,29,31-32,35-36,39,41-42,45-46,49,51-52
20 test/getarg_tests.cpp 111 111 100%
21@@ -585,5 +585,5 @@
22 zmq/zmqpublishnotifier.h 5 0 0% 12,31,37,43,49
23 zmq/zmqrpc.cpp 21 0 0% 16,18,20,22,33-35,38-45,49,52,56,60,62-63
24 ------------------------------------------------------------------------------
25-TOTAL 61561 27606 44%
26+TOTAL 61561 27605 44%
27 ------------------------------------------------------------------------------
In this case line 363 of test/denialofservice_tests.cpp
was executed only in the second run. Non-determinism detected!