Skip to content

Commit fa5cb6b

Browse files
author
MarcoFalke
committed
fuzz: Add WRITE_ALL_FUZZ_TARGETS_AND_ABORT
1 parent eb9a1fe commit fa5cb6b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/test/fuzz/fuzz.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,24 @@ static TypeTestOneInput* g_test_one_input{nullptr};
2929

3030
void initialize()
3131
{
32+
bool should_abort{false};
3233
if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) {
3334
for (const auto& t : FuzzTargets()) {
3435
if (std::get<2>(t.second)) continue;
3536
std::cout << t.first << std::endl;
3637
}
37-
Assert(false);
38+
should_abort = true;
3839
}
40+
if (const char* out_path = std::getenv("WRITE_ALL_FUZZ_TARGETS_AND_ABORT")) {
41+
std::cout << "Writing all fuzz target names to '" << out_path << "'." << std::endl;
42+
std::ofstream out_stream(out_path, std::ios::binary);
43+
for (const auto& t : FuzzTargets()) {
44+
if (std::get<2>(t.second)) continue;
45+
out_stream << t.first << std::endl;
46+
}
47+
should_abort = true;
48+
}
49+
Assert(!should_abort);
3950
std::string_view fuzz_target{Assert(std::getenv("FUZZ"))};
4051
const auto it = FuzzTargets().find(fuzz_target);
4152
Assert(it != FuzzTargets().end());

0 commit comments

Comments
 (0)