mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 06:49:38 -04:00
When building with BUILD_FOR_FUZZING=OFF BUILD_FUZZ_BINARY=ON CMAKE_BUILD_TYPE=Debug allow the fuzz binary to execute given test cases (without actual fuzzing) to make it easier to reproduce fuzz test failures in a more normal debug build. In Debug builds, deterministic fuzz behaviour is controlled via a runtime variable, which is normally false, but set to true automatically in the fuzz binary, unless the FUZZ_NONDETERMINISM environment variable is set.
37 lines
1.3 KiB
C++
37 lines
1.3 KiB
C++
// Copyright (c) 2022 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <util/check.h>
|
|
|
|
#include <bitcoin-build-config.h> // IWYU pragma: keep
|
|
|
|
#include <clientversion.h>
|
|
#include <tinyformat.h>
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
std::string StrFormatInternalBug(std::string_view msg, std::string_view file, int line, std::string_view func)
|
|
{
|
|
return strprintf("Internal bug detected: %s\n%s:%d (%s)\n"
|
|
"%s %s\n"
|
|
"Please report this issue here: %s\n",
|
|
msg, file, line, func, CLIENT_NAME, FormatFullVersion(), CLIENT_BUGREPORT);
|
|
}
|
|
|
|
NonFatalCheckError::NonFatalCheckError(std::string_view msg, std::string_view file, int line, std::string_view func)
|
|
: std::runtime_error{StrFormatInternalBug(msg, file, line, func)}
|
|
{
|
|
}
|
|
|
|
void assertion_fail(std::string_view file, int line, std::string_view func, std::string_view assertion)
|
|
{
|
|
auto str = strprintf("%s:%s %s: Assertion `%s' failed.\n", file, line, func, assertion);
|
|
fwrite(str.data(), 1, str.size(), stderr);
|
|
std::abort();
|
|
}
|
|
|
|
std::atomic<bool> g_enable_dynamic_fuzz_determinism{false};
|