Skip to content

Commit

Permalink
Revert designated initializer list usages so we are C++17 compliant.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 731809562
  • Loading branch information
saladq authored and copybara-github committed Feb 27, 2025
1 parent 3f4c7b4 commit 0c784bd
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 150 deletions.
69 changes: 33 additions & 36 deletions centipede/seed_corpus_maker_lib_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ TEST(SeedCorpusMakerLibTest, RoundTripWriteReadWrite) {
{
constexpr size_t kNumShards = 2;
const SeedCorpusDestination destination = {
.dir_path = std::string(kRelDir1),
.shard_rel_glob = absl::StrCat("distilled-", kCovBin, ".*"),
.shard_index_digits = kIdxDigits,
.num_shards = kNumShards,
/*dir_path=*/std::string(kRelDir1),
/*shard_rel_glob=*/absl::StrCat("distilled-", kCovBin, ".*"),
/*shard_index_digits=*/kIdxDigits,
/*num_shards=*/kNumShards,
};
ASSERT_OK(WriteSeedCorpusElementsToDestination( //
kElements, kCovBin, kCovHash, destination));
Expand All @@ -133,13 +133,12 @@ TEST(SeedCorpusMakerLibTest, RoundTripWriteReadWrite) {
// subsample of elements from the seed source created by the previous step.
{
for (const float fraction : {1.0, 0.5, 0.2}) {
const SeedCorpusSource source = {
.dir_glob = std::string(kRelDir1),
.num_recent_dirs =
2, // Intentionally specify more than we actually have
.shard_rel_glob = absl::StrCat("distilled-", kCovBin, ".*"),
.sampled_fraction_or_count = fraction,
};
SeedCorpusSource source;
source.dir_glob = std::string(kRelDir1);
source.num_recent_dirs = 2;
source.shard_rel_glob = absl::StrCat("distilled-", kCovBin, ".*");
source.sampled_fraction_or_count = fraction;

InputAndFeaturesVec elements;
ASSERT_OK(SampleSeedCorpusElementsFromSource( //
source, kCovBin, kCovHash, elements));
Expand All @@ -154,23 +153,21 @@ TEST(SeedCorpusMakerLibTest, RoundTripWriteReadWrite) {
// from the source and writes expected shards to the destination.
{
constexpr size_t kNumShards = 3;

SeedCorpusSource source;
source.dir_glob = std::string(kRelDir1);
source.num_recent_dirs = 1;
source.shard_rel_glob = absl::StrCat("distilled-", kCovBin, ".*");
source.sampled_fraction_or_count = 1.0f;
const SeedCorpusConfig config = {
.sources =
{
{
.dir_glob = std::string(kRelDir1),
.num_recent_dirs = 1,
.shard_rel_glob = absl::StrCat("distilled-", kCovBin, ".*"),
.sampled_fraction_or_count = 1.0f,
},
},
.destination =
{
.dir_path = std::string(kRelDir2),
.shard_rel_glob = "corpus.*",
.shard_index_digits = kIdxDigits,
.num_shards = kNumShards,
},
/*sources=*/{{source}},
/*destination=*/
{
/*dir_path=*/std::string(kRelDir2),
/*shard_rel_glob=*/"corpus.*",
/*shard_index_digits=*/kIdxDigits,
/*num_shards=*/kNumShards,
},
};

{
Expand Down Expand Up @@ -205,10 +202,10 @@ TEST(SeedCorpusMakerLibTest, LoadsBothIndividualInputsAndShardsFromSource) {
{
constexpr size_t kNumShards = 2;
const SeedCorpusDestination destination = {
.dir_path = std::string(kRelDir),
.shard_rel_glob = absl::StrCat("distilled-", kCovBin, ".*"),
.shard_index_digits = kIdxDigits,
.num_shards = kNumShards,
/*dir_path=*/std::string(kRelDir),
/*shard_rel_glob=*/absl::StrCat("distilled-", kCovBin, ".*"),
/*shard_index_digits=*/kIdxDigits,
/*num_shards=*/kNumShards,
};
CHECK_OK(WriteSeedCorpusElementsToDestination( //
kShardedInputs, kCovBin, kCovHash, destination));
Expand All @@ -229,13 +226,13 @@ TEST(SeedCorpusMakerLibTest, LoadsBothIndividualInputsAndShardsFromSource) {
InputAndFeaturesVec elements;
ASSERT_OK(SampleSeedCorpusElementsFromSource( //
SeedCorpusSource{
.dir_glob = std::string(kRelDir),
.num_recent_dirs = 1,
.shard_rel_glob = absl::StrCat("distilled-", kCovBin, ".*"),
/*dir_glob=*/std::string(kRelDir),
/*num_recent_dirs=*/1,
/*shard_rel_glob=*/absl::StrCat("distilled-", kCovBin, ".*"),
// Intentionally try to match the shard files and test if they will
// be read as individual inputs.
.individual_input_rel_glob = "*",
.sampled_fraction_or_count = 1.0f,
/*individual_input_rel_glob=*/"*",
/*sampled_fraction_or_count=*/1.0f,
},
kCovBin, kCovHash, elements));
EXPECT_EQ(elements.size(), 5); // Non-empty inputs
Expand Down
8 changes: 4 additions & 4 deletions centipede/seed_corpus_maker_proto_lib_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ TEST(SeedCorpusMakerProtoLibTest, MakesSeedUsingConfigProto) {
// Prepare a seed source for tests.
{
const SeedCorpusDestination destination = {
.dir_path = std::string(kRelDir1),
.shard_rel_glob = absl::StrCat("distilled-", kCovBin, ".*"),
.shard_index_digits = kIdxDigits,
.num_shards = 2,
/*dir_path=*/std::string(kRelDir1),
/*shard_rel_glob=*/absl::StrCat("distilled-", kCovBin, ".*"),
/*shard_index_digits=*/kIdxDigits,
/*num_shards=*/2,
};
ASSERT_OK(WriteSeedCorpusElementsToDestination( //
kElements, kCovBin, kCovHash, destination));
Expand Down
Loading

0 comments on commit 0c784bd

Please sign in to comment.