Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions centipede/centipede_flags.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
13 changes: 6 additions & 7 deletions centipede/centipede_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,17 +366,17 @@ 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
// path when only replaying to avoid replaying an unfinished fuzzing sessions.
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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down
8 changes: 2 additions & 6 deletions centipede/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
15 changes: 5 additions & 10 deletions centipede/environment_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -198,26 +198,21 @@ 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);

EXPECT_EQ(env.fuzztest_corpus_database, "db");
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
Loading