diff --git a/centipede/seed_corpus_maker_lib.cc b/centipede/seed_corpus_maker_lib.cc index b43d7e94c..b94f5160b 100644 --- a/centipede/seed_corpus_maker_lib.cc +++ b/centipede/seed_corpus_maker_lib.cc @@ -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), // @@ -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( // @@ -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()); diff --git a/centipede/seed_corpus_maker_lib.h b/centipede/seed_corpus_maker_lib.h index d238bc30b..e5ae87b5a 100644 --- a/centipede/seed_corpus_maker_lib.h +++ b/centipede/seed_corpus_maker_lib.h @@ -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_