Add environment variable to extend the default 1s time limit of GoogleFuzzTest in unit-test mode. PiperOrigin-RevId: 519758571
diff --git a/fuzztest/internal/runtime.cc b/fuzztest/internal/runtime.cc index 2f7d3a1..8d1a049 100644 --- a/fuzztest/internal/runtime.cc +++ b/fuzztest/internal/runtime.cc
@@ -609,7 +609,14 @@ PopulateFromSeeds(); - const auto time_limit = stats_.start_time + absl::Seconds(1); + auto duration = absl::Seconds(1); + const auto fuzz_for = absl::NullSafeStringView(getenv("FUZZTEST_FUZZ_FOR")); + if (!fuzz_for.empty()) { + FUZZTEST_INTERNAL_CHECK( + absl::ParseDuration(fuzz_for, &duration), + "Could not parse duration in FUZZTEST_FUZZ_FOR=", fuzz_for); + } + const auto time_limit = stats_.start_time + duration; PRNG prng(seed_sequence_); Input mutation{params_domain_->UntypedInit(prng)}; constexpr size_t max_iterations = 10000;