aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-05-07 15:44:16 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-05-07 15:44:19 +0200
commit9313c4e6aa4b707c06a86b33d5d2753cd8383340 (patch)
treeb7b86ac8aed0506dfba141d024168ec067eeae2a /src/test/fuzz
parenteb9a1fe03779bf05062b70f14190cb23ff42b46f (diff)
parentfa5cb6b268554fe0f272833794a98106872ac6a5 (diff)
downloadbitcoin-9313c4e6aa4b707c06a86b33d5d2753cd8383340.tar.xz
Merge bitcoin/bitcoin#21874: fuzz: Add WRITE_ALL_FUZZ_TARGETS_AND_ABORT
fa5cb6b268554fe0f272833794a98106872ac6a5 fuzz: Add WRITE_ALL_FUZZ_TARGETS_AND_ABORT (MarcoFalke) Pull request description: This is needed when stdout is polluted by the fuzz engine. stderr can't be used instead because it is polluted by aborting the program. Top commit has no ACKs. Tree-SHA512: bf0a2a6bcd964ff1f0f3ef6e7e297b4c780430c4d6312332ed99ace0e1c58243c1483fd387e39405837d39b36072dfeb9ae03d2a7aa728ad6955159754fd5766
Diffstat (limited to 'src/test/fuzz')
-rw-r--r--src/test/fuzz/fuzz.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp
index 1fab46ff13..0d8d960d56 100644
--- a/src/test/fuzz/fuzz.cpp
+++ b/src/test/fuzz/fuzz.cpp
@@ -29,13 +29,24 @@ static TypeTestOneInput* g_test_one_input{nullptr};
void initialize()
{
+ bool should_abort{false};
if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) {
for (const auto& t : FuzzTargets()) {
if (std::get<2>(t.second)) continue;
std::cout << t.first << std::endl;
}
- Assert(false);
+ should_abort = true;
}
+ if (const char* out_path = std::getenv("WRITE_ALL_FUZZ_TARGETS_AND_ABORT")) {
+ std::cout << "Writing all fuzz target names to '" << out_path << "'." << std::endl;
+ std::ofstream out_stream(out_path, std::ios::binary);
+ for (const auto& t : FuzzTargets()) {
+ if (std::get<2>(t.second)) continue;
+ out_stream << t.first << std::endl;
+ }
+ should_abort = true;
+ }
+ Assert(!should_abort);
std::string_view fuzz_target{Assert(std::getenv("FUZZ"))};
const auto it = FuzzTargets().find(fuzz_target);
Assert(it != FuzzTargets().end());