Skip to content

Commit

Permalink
Tear down fixture in the controller mode as early as possible.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 734553075
  • Loading branch information
xinhaoyuan authored and copybara-github committed Mar 7, 2025
1 parent 972fbf8 commit 1830408
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fuzztest/internal/centipede_adaptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ bool CentipedeFuzzerAdaptor::Run(int* argc, char*** argv, RunMode mode,
runtime_.EnableReporter(&fuzzer_impl_.stats_, [] { return absl::Now(); });
}
fuzzer_impl_.fixture_driver_->SetUpFuzzTest();
bool to_tear_down_fuzz_test = true;
const int result = ([&]() {
if (runtime_.skipping_requested()) {
absl::FPrintF(GetStderr(),
Expand All @@ -629,6 +630,9 @@ bool CentipedeFuzzerAdaptor::Run(int* argc, char*** argv, RunMode mode,
if (fuzzer_impl_.ReplayInputsIfAvailable(configuration)) return 0;
// `ReplayInputsIfAvailable` overwrites the run mode - revert it back.
runtime_.SetRunMode(mode);
// Tear down fixture early to avoid interfering with the runners.
fuzzer_impl_.fixture_driver_->TearDownFuzzTest();
to_tear_down_fuzz_test = false;
// Run as the fuzzing engine.
std::unique_ptr<TempDir> workdir;
if (configuration.corpus_database.empty() || mode == RunMode::kUnitTest)
Expand Down Expand Up @@ -692,7 +696,9 @@ bool CentipedeFuzzerAdaptor::Run(int* argc, char*** argv, RunMode mode,
}
return centipede::CentipedeMain(env, factory);
})();
fuzzer_impl_.fixture_driver_->TearDownFuzzTest();
if (to_tear_down_fuzz_test) {
fuzzer_impl_.fixture_driver_->TearDownFuzzTest();
}
return result == 0;
}

Expand Down

0 comments on commit 1830408

Please sign in to comment.