Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert designated initializer list usages so we are C++17 compliant. #1579

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
70 changes: 36 additions & 34 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,26 @@ 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 =
/*sources =*/
{
{
.dir_path = std::string(kRelDir2),
.shard_rel_glob = "corpus.*",
.shard_index_digits = kIdxDigits,
.num_shards = kNumShards,
source,
},
},
/*destination =*/
{
/*dir_path =*/std::string(kRelDir2),
/*shard_rel_glob =*/"corpus.*",
/*shard_index_digits =*/kIdxDigits,
/*num_shards =*/kNumShards,
},
};

{
Expand Down Expand Up @@ -205,10 +207,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 +231,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