Do not report/abort when the reporter is disabled. This is mainly to avoid reporting/aborting on `EXPECT_TRUE(test->RunIn...)`, which is unnecessary and time consuming (due to full stack trace printing). PiperOrigin-RevId: 882585202
diff --git a/fuzztest/internal/centipede_adaptor.cc b/fuzztest/internal/centipede_adaptor.cc index ef874eb..71df38d 100644 --- a/fuzztest/internal/centipede_adaptor.cc +++ b/fuzztest/internal/centipede_adaptor.cc
@@ -863,6 +863,11 @@ runtime_.SetRunMode(mode); runtime_.SetSkippingRequested(false); runtime_.SetCurrentTest(&test_, &configuration); + // We don't always enable reporter, but always disable it at the end for + // simplicity. + absl::Cleanup always_disable_reporter = [this]() { + runtime_.DisableReporter(); + }; if (is_running_property_function_in_this_process) { if (IsSilenceTargetEnabled()) SilenceTargetStdoutAndStderr(); // TODO(b/393582695): Consider whether we need some kind of reporting
diff --git a/fuzztest/internal/googletest_adaptor.h b/fuzztest/internal/googletest_adaptor.h index 98e8a8a..190da2c 100644 --- a/fuzztest/internal/googletest_adaptor.h +++ b/fuzztest/internal/googletest_adaptor.h
@@ -122,6 +122,7 @@ void OnTestPartResult(const TestPartResult& test_part_result) override { if (!test_part_result.failed()) return; Runtime& runtime = Runtime::instance(); + if (!runtime.reporter_enabled()) return; runtime.SetCrashTypeIfUnset("GoogleTest assertion failure"); if (runtime.run_mode() == RunMode::kFuzz) { if (runtime.should_terminate_on_non_fatal_failure()) {
diff --git a/fuzztest/internal/runtime.h b/fuzztest/internal/runtime.h index bdefab5..ea867c3 100644 --- a/fuzztest/internal/runtime.h +++ b/fuzztest/internal/runtime.h
@@ -175,6 +175,7 @@ ResetCrashType(); } void DisableReporter() { reporter_enabled_ = false; } + bool reporter_enabled() const { return reporter_enabled_; } struct Args { const GenericDomainCorpusType& corpus_value;