Abort on external failures in runner mode instead of keep running. This mainly affects the unit-test mode behavior when dealing with gtest assertion failures. This is to prepare for persistent mode, where multiple batches run in a single runner process (inside RunnerMain()). Aborting after failure input ensures Centipede know which batch contains the failure and triage accordingly. As a side-effect, change a unit-mode e2e test to switch to a non-failing test because the previous test generates an external failure (gTest EXPECT failure) which would cause the runner to abort without destructing the global environment. PiperOrigin-RevId: 790977540
diff --git a/e2e_tests/functional_test.cc b/e2e_tests/functional_test.cc index 80fa06d..2cf56d8 100644 --- a/e2e_tests/functional_test.cc +++ b/e2e_tests/functional_test.cc
@@ -229,7 +229,7 @@ } TEST_F(UnitTestModeTest, GlobalEnvironmentGoesThroughCompleteLifecycle) { - auto [status, std_out, std_err] = Run("MySuite.GoogleTestExpect"); + auto [status, std_out, std_err] = Run("MySuite.GoogleTestNeverFails"); EXPECT_GT(CountSubstrs(std_err, "<<GlobalEnvironment::GlobalEnvironment()>>"), 0); EXPECT_EQ(
diff --git a/fuzztest/internal/centipede_adaptor.cc b/fuzztest/internal/centipede_adaptor.cc index 13833ca..3497f2c 100644 --- a/fuzztest/internal/centipede_adaptor.cc +++ b/fuzztest/internal/centipede_adaptor.cc
@@ -419,14 +419,14 @@ if (centipede_ret != EXIT_SUCCESS) { absl::FPrintF(GetStderr(), "[!] Cannot list crash IDs using Centipede - returning " - "empty results."); + "empty results.\n"); return {}; } const auto contents = ReadFile(env.list_crash_ids_file); if (!contents.has_value()) { absl::FPrintF(GetStderr(), "[!] Cannot read the result file from listing crash IDs " - "with Centipede - returning empty results."); + "with Centipede - returning empty results.\n"); return {}; } if (contents->empty()) { @@ -466,6 +466,11 @@ fuzzer_impl_.TryParse({(char*)input.data(), input.size()}); if (parsed_input.ok()) { fuzzer_impl_.RunOneInput({*std::move(parsed_input)}); + if (runtime_.external_failure_detected()) { + absl::FPrintF(GetStderr(), + "[!] External failure detected - aborting.\n"); + std::abort(); + } return true; } return false; @@ -705,7 +710,7 @@ absl::FPrintF( GetStderr(), "[!] Encountered error when using Centipede to export the crash " - "input."); + "input.\n"); return false; } CentipedeAdaptorRunnerCallbacks runner_callbacks(&runtime_, &fuzzer_impl_,