File tree Expand file tree Collapse file tree 5 files changed +37
-19
lines changed Expand file tree Collapse file tree 5 files changed +37
-19
lines changed Original file line number Diff line number Diff line change 77#include < netaddress.h>
88#include < netbase.h>
99#include < test/fuzz/util/check_globals.h>
10+ #include < test/util/coverage.h>
1011#include < test/util/random.h>
1112#include < test/util/setup_common.h>
1213#include < util/check.h>
@@ -89,25 +90,6 @@ const std::function<std::string()> G_TEST_GET_FULL_NAME{[]{
8990 return std::string{g_fuzz_target};
9091}};
9192
92- #if defined(__clang__) && defined(__linux__)
93- extern " C" void __llvm_profile_reset_counters (void ) __attribute__((weak));
94- extern " C" void __gcov_reset (void ) __attribute__((weak));
95-
96- void ResetCoverageCounters ()
97- {
98- if (__llvm_profile_reset_counters) {
99- __llvm_profile_reset_counters ();
100- }
101-
102- if (__gcov_reset) {
103- __gcov_reset ();
104- }
105- }
106- #else
107- void ResetCoverageCounters () {}
108- #endif
109-
110-
11193static void initialize ()
11294{
11395 // By default, make the RNG deterministic with a fixed seed. This will affect all
Original file line number Diff line number Diff line change 55add_library (test_util STATIC EXCLUDE_FROM_ALL
66 blockfilter.cpp
77 coins.cpp
8+ coverage.cpp
89 index.cpp
910 json.cpp
1011 logging.cpp
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2025-present The Bitcoin Core developers
2+ // Distributed under the MIT software license, see the accompanying
3+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+ #include < test/util/coverage.h>
6+
7+ #if defined(__clang__) && defined(__linux__)
8+ extern " C" void __llvm_profile_reset_counters (void ) __attribute__((weak));
9+ extern " C" void __gcov_reset (void ) __attribute__((weak));
10+
11+ void ResetCoverageCounters ()
12+ {
13+ if (__llvm_profile_reset_counters) {
14+ __llvm_profile_reset_counters ();
15+ }
16+
17+ if (__gcov_reset) {
18+ __gcov_reset ();
19+ }
20+ }
21+ #else
22+ void ResetCoverageCounters () {}
23+ #endif
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2025-present The Bitcoin Core developers
2+ // Distributed under the MIT software license, see the accompanying
3+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+ #ifndef BITCOIN_TEST_UTIL_COVERAGE_H
6+ #define BITCOIN_TEST_UTIL_COVERAGE_H
7+
8+ void ResetCoverageCounters ();
9+
10+ #endif // BITCOIN_TEST_UTIL_COVERAGE_H
Original file line number Diff line number Diff line change 3737#include < scheduler.h>
3838#include < script/sigcache.h>
3939#include < streams.h>
40+ #include < test/util/coverage.h>
4041#include < test/util/net.h>
4142#include < test/util/random.h>
4243#include < test/util/txmempool.h>
@@ -80,6 +81,7 @@ static const bool g_rng_temp_path_init{[] {
8081 Assert (!g_used_g_prng);
8182 (void )g_rng_temp_path.rand64 ();
8283 g_used_g_prng = false ;
84+ ResetCoverageCounters (); // The seed strengthen in SeedStartup is not deterministic, so exclude it from coverage counts
8385 return true ;
8486}()};
8587
You can’t perform that action at this time.
0 commit comments