Make G_FUZZING constexpr, require -DBUILD_FOR_FUZZING=ON to execute a fuzz target

This commit is contained in:
MarcoFalke
2024-10-31 13:53:48 +01:00
parent fae3cf0ffa
commit fafbf8acf4
5 changed files with 17 additions and 7 deletions

View File

@@ -102,8 +102,6 @@ void ResetCoverageCounters() {}
void initialize()
{
g_fuzzing = true;
// By default, make the RNG deterministic with a fixed seed. This will affect all
// randomness during the fuzz test, except:
// - GetStrongRandBytes(), which is used for the creation of private key material.
@@ -156,6 +154,10 @@ void initialize()
std::cerr << "No fuzz target compiled for " << g_fuzz_target << "." << std::endl;
std::exit(EXIT_FAILURE);
}
if constexpr (!G_FUZZING) {
std::cerr << "Must compile with -DBUILD_FOR_FUZZING=ON to execute a fuzz target." << std::endl;
std::exit(EXIT_FAILURE);
}
Assert(!g_test_one_input);
g_test_one_input = &it->second.test_one_input;
it->second.opts.init();