mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-29 18:20:58 +02:00
[fuzz] Avoid collecting initialization coverage
This commit is contained in:
@ -79,6 +79,26 @@ void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target,
|
|||||||
static std::string_view g_fuzz_target;
|
static std::string_view g_fuzz_target;
|
||||||
static const TypeTestOneInput* g_test_one_input{nullptr};
|
static const TypeTestOneInput* g_test_one_input{nullptr};
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__clang__) && defined(__linux__)
|
||||||
|
extern "C" void __llvm_profile_reset_counters(void) __attribute__((weak));
|
||||||
|
extern "C" void __gcov_reset(void) __attribute__((weak));
|
||||||
|
|
||||||
|
void ResetCoverageCounters()
|
||||||
|
{
|
||||||
|
if (__llvm_profile_reset_counters) {
|
||||||
|
__llvm_profile_reset_counters();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__gcov_reset) {
|
||||||
|
__gcov_reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void ResetCoverageCounters() {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void initialize()
|
void initialize()
|
||||||
{
|
{
|
||||||
// Terminate immediately if a fuzzing harness ever tries to create a TCP socket.
|
// Terminate immediately if a fuzzing harness ever tries to create a TCP socket.
|
||||||
@ -129,6 +149,8 @@ void initialize()
|
|||||||
Assert(!g_test_one_input);
|
Assert(!g_test_one_input);
|
||||||
g_test_one_input = &it->second.test_one_input;
|
g_test_one_input = &it->second.test_one_input;
|
||||||
it->second.opts.init();
|
it->second.opts.init();
|
||||||
|
|
||||||
|
ResetCoverageCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PROVIDE_FUZZ_MAIN_FUNCTION)
|
#if defined(PROVIDE_FUZZ_MAIN_FUNCTION)
|
||||||
|
Reference in New Issue
Block a user