Skip to content

Commit

Permalink
Remove CHECKs for non-empty coverage binary name and hash.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 648698186
  • Loading branch information
Markus Kusano authored and copybara-github committed Jul 9, 2024
1 parent 28a213f commit dc495af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
16 changes: 14 additions & 2 deletions centipede/seed_corpus_maker_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ void SampleSeedCorpusElementsFromSource( //
std::string_view coverage_binary_name, //
std::string_view coverage_binary_hash, //
InputAndFeaturesVec& elements) {
CHECK_EQ(coverage_binary_name.empty(), coverage_binary_hash.empty())
<< "Binary name and hash should both be either provided or empty";

RPROF_THIS_FUNCTION_WITH_TIMELAPSE( //
/*enable=*/ABSL_VLOG_IS_ON(1), //
/*timelapse_interval=*/absl::Seconds(ABSL_VLOG_IS_ON(2) ? 10 : 60), //
Expand Down Expand Up @@ -326,9 +329,10 @@ void WriteSeedCorpusElementsToDestination( //
std::string_view coverage_binary_name, //
std::string_view coverage_binary_hash, //
const SeedCorpusDestination& destination) {
CHECK_EQ(coverage_binary_name.empty(), coverage_binary_hash.empty())
<< "Binary name and hash should both be either provided or empty";

CHECK(!elements.empty());
CHECK(!coverage_binary_name.empty());
CHECK(!coverage_binary_hash.empty());
CHECK(!destination.dir_path().empty());

RPROF_THIS_FUNCTION_WITH_TIMELAPSE( //
Expand Down Expand Up @@ -487,7 +491,15 @@ void GenerateSeedCorpusFromConfig( //
LOG(WARNING) << "Config is empty: skipping seed corpus generation";
return;
}
GenerateSeedCorpusFromConfig( //
config, coverage_binary_name, coverage_binary_hash, override_out_dir);
}

void GenerateSeedCorpusFromConfig( //
const SeedCorpusConfig& config, //
std::string_view coverage_binary_name, //
std::string_view coverage_binary_hash, //
std::string_view override_out_dir) {
// Pre-create the destination dir early to catch possible misspellings etc.
if (!RemotePathExists(config.destination().dir_path())) {
RemoteMkdir(config.destination().dir_path());
Expand Down
7 changes: 7 additions & 0 deletions centipede/seed_corpus_maker_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ void GenerateSeedCorpusFromConfig( //
std::string_view coverage_binary_hash, //
std::string_view override_out_dir = "");

// Same as above but accepts a `SeedCorpusConfig` directly.
void GenerateSeedCorpusFromConfig( //
const SeedCorpusConfig& config, //
std::string_view coverage_binary_name, //
std::string_view coverage_binary_hash, //
std::string_view override_out_dir = "");

} // namespace centipede

#endif // THIRD_PARTY_CENTIPEDE_SEED_CORPUS_MAKER_LIB_H_

0 comments on commit dc495af

Please sign in to comment.