No public description PiperOrigin-RevId: 1003288911
diff --git a/rust/cargo_fuzztest/src/lib.rs b/rust/cargo_fuzztest/src/lib.rs index fe9afcd..a0d55e7 100644 --- a/rust/cargo_fuzztest/src/lib.rs +++ b/rust/cargo_fuzztest/src/lib.rs
@@ -323,6 +323,10 @@ cmd.arg("--nocapture"); } + if self.options.fuzztest_options.unguided { + cmd.env("FUZZTEST_UNGUIDED", "true"); + } + Ok(cmd) }
diff --git a/rust/options/src/lib.rs b/rust/options/src/lib.rs index d84bb4a..94cb383 100644 --- a/rust/options/src/lib.rs +++ b/rust/options/src/lib.rs
@@ -142,6 +142,10 @@ /// sessions, or skipping tests that already finished with the same execution ID. #[arg(env = "FUZZTEST_EXECUTION_ID", long, requires = "corpus_db")] pub execution_id: Option<String>, + + /// If true, carries out fuzzing without coverage guidance. + #[arg(env = "FUZZTEST_UNGUIDED", long)] + pub unguided: bool, } /// Strongly-typed domain execution mode for test runs. @@ -819,4 +823,17 @@ })) ); } + + #[gtest] + fn test_unguided_parsing_env() { + assert_single_threaded_test_environment(); + // SAFETY: Single-threaded test environment and no background threads. + let options = unsafe { + with_env_var("FUZZTEST_UNGUIDED", "true", || { + FuzzTestOptions::parse_from(std::iter::empty::<OsString>()) + }) + }; + + expect_true!(options.unguided); + } }
diff --git a/rust/src/worker.rs b/rust/src/worker.rs index cd9ed80..fcfbd6a 100644 --- a/rust/src/worker.rs +++ b/rust/src/worker.rs
@@ -196,6 +196,8 @@ pub fn execute(&self, input: &GenericCorpusValue, sink: &mut FeedbackSink) { // TODO(the-shank): modify this in order to support persistent mode and batch execution. static CLEAR_STARTUP_COVERAGE: AtomicBool = AtomicBool::new(true); + // Called even in unguided mode: besides clearing coverage, this frees the SanCov state of + // threads that exited during the previous execution, which would otherwise accumulate. coverage::prepare_coverage(CLEAR_STARTUP_COVERAGE.swap(false, Ordering::AcqRel)); // SAFETY: We are currently in the `execute` callback of `RustFuzzTestAdapter`. @@ -203,9 +205,10 @@ let result = self.fuzz_test.execute(input); - coverage::post_process_coverage(false); - - sink.emit_sancov_features(); + if !options::get_fuzztest_options().unguided { + coverage::post_process_coverage(false); + sink.emit_sancov_features(); + } if !result { // TODO(the-shank): the signature should be different for different panics. Currently,