mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Merge bitcoin/bitcoin#32059: test: Update coverage.cpp to drop linux restriction
54e6eacc1f
test: Enable ResetCoverageCounters beyond Linux (janb84) Pull request description: In PR [#31901](https://github.com/bitcoin/bitcoin/pull/31901), Coverage.cpp was introduced as a separate utility file, based on existing code. However, the macro defined in Coverage.cpp was limited to Clang and Linux, which caused issues for users on macOS when using the newly introduced deterministic test tooling. This change adds fallback functions which are used when building without code coverage on non linux env. This adds support for macOS to ResetCoverageCounters. ResetCoverageCounters is used by the unit tests in `g_rng_temp_path_init` to support the deterministic unit test tooling. It is also used in fuzz tests to completely suppress coverage from anything init-related. See [Readme](https://github.com/bitcoin/bitcoin/blob/master/contrib/devtools/README.md) on how to test this for deterministic unit & fuzz test. Suggestion for test files: - for unit test: `util_string_tests` - for fuzz test: `addition_overflow ` These files should give deterministic results ACKs for top commit: maflcko: review-only ACK54e6eacc1f
hodlinator: re-ACK54e6eacc1f
Tree-SHA512: dd71da6f76d4fc9e64bf521bbfe5e7483d77c2ca0380f9e692502e64b529068ea33f21b19399481feb7c6780a23d893d8b7f733cef641a2db18a13397c98deea
This commit is contained in:
commit
14fec6380d
1 changed files with 10 additions and 11 deletions
|
@ -4,19 +4,18 @@
|
||||||
|
|
||||||
#include <test/util/coverage.h>
|
#include <test/util/coverage.h>
|
||||||
|
|
||||||
#if defined(__clang__) && defined(__linux__)
|
#if defined(__clang__)
|
||||||
extern "C" void __llvm_profile_reset_counters(void) __attribute__((weak));
|
extern "C" __attribute__((weak)) void __llvm_profile_reset_counters(void);
|
||||||
extern "C" void __gcov_reset(void) __attribute__((weak));
|
extern "C" __attribute__((weak)) void __gcov_reset(void);
|
||||||
|
|
||||||
void ResetCoverageCounters()
|
// Fallback implementations
|
||||||
{
|
extern "C" __attribute__((weak)) void __llvm_profile_reset_counters(void) {}
|
||||||
if (__llvm_profile_reset_counters) {
|
extern "C" __attribute__((weak)) void __gcov_reset(void) {}
|
||||||
|
|
||||||
|
void ResetCoverageCounters() {
|
||||||
|
// These will call the real ones if available, or our dummies if not
|
||||||
__llvm_profile_reset_counters();
|
__llvm_profile_reset_counters();
|
||||||
}
|
|
||||||
|
|
||||||
if (__gcov_reset) {
|
|
||||||
__gcov_reset();
|
__gcov_reset();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void ResetCoverageCounters() {}
|
void ResetCoverageCounters() {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue