diff --git a/centipede/centipede_flags.inc b/centipede/centipede_flags.inc index f6d6da2e9..78f644f45 100644 --- a/centipede/centipede_flags.inc +++ b/centipede/centipede_flags.inc @@ -505,9 +505,6 @@ CENTIPEDE_FLAG( CENTIPEDE_FLAG(std::string, fuzztest_workdir_root, "", "The root directory for Centipede workdirs for working on the " "corpus database.") -CENTIPEDE_FLAG(bool, fuzztest_only_replay, false, - "If set, further steps are skipped after replaying with the " - "corpus database.") CENTIPEDE_FLAG( std::string, fuzztest_execution_id, "", "If set, will be used when working on a corpus database to resume " diff --git a/centipede/centipede_interface.cc b/centipede/centipede_interface.cc index 330504502..edac2ebf4 100644 --- a/centipede/centipede_interface.cc +++ b/centipede/centipede_interface.cc @@ -366,6 +366,7 @@ void UpdateCorpusDatabase(Environment env, return stamp; }(); + const bool only_replay = env.load_shards_only; const bool is_workdir_specified = !env.workdir.empty(); // When env.workdir is empty, the full workdir paths will be formed by // appending the fuzz test names to the base workdir path. We use different @@ -373,10 +374,9 @@ void UpdateCorpusDatabase(Environment env, const auto base_workdir_path = is_workdir_specified ? std::filesystem::path{} // Will not be used. - : workdir_root_path / - absl::StrFormat("workdir%s.%03d", - env.fuzztest_only_replay ? "-replay" : "", - test_shard_index); + : workdir_root_path / absl::StrFormat("workdir%s.%03d", + only_replay ? "-replay" : "", + test_shard_index); // There's no point in saving the binary info to the workdir, since the // workdir is deleted at the end. env.save_binary_info = false; @@ -495,7 +495,7 @@ void UpdateCorpusDatabase(Environment env, return; } - FUZZTEST_LOG(INFO) << (env.fuzztest_only_replay ? "Replaying " : "Fuzzing ") + FUZZTEST_LOG(INFO) << (only_replay ? "Replaying " : "Fuzzing ") << env.test_name << " for " << time_limit << "\n\tTest binary: " << env.binary; @@ -531,8 +531,7 @@ void UpdateCorpusDatabase(Environment env, // TODO(xinhaoyuan): Have a separate flag to skip corpus updating instead // of checking whether workdir is specified or not. - const bool skip_corpus_db_update = - env.fuzztest_only_replay || is_workdir_specified; + const bool skip_corpus_db_update = only_replay || is_workdir_specified; if (skip_corpus_db_update && !env.report_crash_summary) return; // Deduplicate and optionally update the crashing inputs. diff --git a/centipede/environment.cc b/centipede/environment.cc index 37d218943..42abe31b7 100644 --- a/centipede/environment.cc +++ b/centipede/environment.cc @@ -245,7 +245,6 @@ void Environment::UpdateWithTargetConfig( fuzztest_binary_identifier = config.binary_identifier; fuzztest_stats_root = config.stats_root; fuzztest_workdir_root = config.workdir_root; - fuzztest_only_replay = config.only_replay; fuzztest_execution_id = config.execution_id.value_or(""); fuzztest_replay_coverage_inputs = config.replay_coverage_inputs; fuzztest_time_limit_per_test = config.GetTimeLimitPerTest(); @@ -316,14 +315,11 @@ void Environment::UpdateWithTargetConfig( << VV(stack_limit_kb) << VV(config.stack_limit); stack_limit_kb = bytes_to_kb(config.stack_limit); - if (fuzztest_only_replay) { - load_shards_only = true; - populate_binary_info = false; - } - if (test_name.empty() && config.fuzz_tests_in_current_shard.size() == 1) { test_name = config.fuzz_tests_in_current_shard[0]; } + + load_shards_only = config.only_replay; } void Environment::UpdateTimeoutPerBatchIfEqualTo(size_t val) { diff --git a/centipede/environment_test.cc b/centipede/environment_test.cc index 259a8482e..50f48e8a4 100644 --- a/centipede/environment_test.cc +++ b/centipede/environment_test.cc @@ -186,7 +186,7 @@ TEST(Environment, DiesOnInconsistentStackLimitKbAndTargetConfigStackLimit) { "stack_limit in the target binary"); } -TEST(Environment, UpdatesFuzzTestFieldsFromTargetConfig) { +TEST(Environment, UpdatesFieldsFromTargetConfig) { Environment env; fuzztest::internal::Configuration config; config.corpus_database = "db"; @@ -198,6 +198,8 @@ TEST(Environment, UpdatesFuzzTestFieldsFromTargetConfig) { config.replay_coverage_inputs = true; config.time_limit = absl::Seconds(10); config.time_budget_type = TimeBudgetType::kPerTest; + config.fuzz_tests_in_current_shard = {"some_test"}; + config.jobs = 6; env.UpdateWithTargetConfig(config); @@ -205,19 +207,12 @@ TEST(Environment, UpdatesFuzzTestFieldsFromTargetConfig) { EXPECT_EQ(env.fuzztest_binary_identifier, "bin"); EXPECT_EQ(env.fuzztest_stats_root, "stats"); EXPECT_EQ(env.fuzztest_workdir_root, "workdir"); - EXPECT_TRUE(env.fuzztest_only_replay); EXPECT_EQ(env.fuzztest_execution_id, "exec"); EXPECT_TRUE(env.fuzztest_replay_coverage_inputs); EXPECT_EQ(env.fuzztest_time_limit_per_test, absl::Seconds(10)); -} - -TEST(Environment, UpdatesReplayOnlyConfiguration) { - Environment env; - fuzztest::internal::Configuration config; - config.only_replay = true; - env.UpdateWithTargetConfig(config); EXPECT_TRUE(env.load_shards_only); - EXPECT_FALSE(env.populate_binary_info); + EXPECT_EQ(env.test_name, "some_test"); + EXPECT_EQ(env.j, 6); } } // namespace fuzztest::internal