Skip to content
Merged
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
34 changes: 19 additions & 15 deletions test/fuzz/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,25 @@ int main(int argc, char** argv) {
RELEASE_ASSERT(argc >= 2, "");
// Consider any file after the test path which doesn't have a - prefix to be a corpus entry.
uint32_t input_args = 0;
Envoy::Stats::IsolatedStoreImpl stats_store;
Envoy::Api::ApiPtr api = Envoy::Api::createApiForTest(stats_store);
for (int i = 1; i < argc; ++i) {
const std::string arg{argv[i]};
if (arg.empty() || arg[0] == '-') {
break;
}
++input_args;
// Outputs from envoy_directory_genrule might be directories or we might
// have artisanal files.
if (api->fileSystem().directoryExists(arg)) {
const auto paths = Envoy::TestUtility::listFiles(arg, true);
Envoy::test_corpus_.insert(Envoy::test_corpus_.begin(), paths.begin(), paths.end());
} else {
Envoy::test_corpus_.emplace_back(arg);
// Ensure we cleanup API resources before we jump into the tests, the test API creates a singleton
// time system that we don't want to leak into gtest.
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you sink stats_store too?

Envoy::Stats::IsolatedStoreImpl stats_store;
Envoy::Api::ApiPtr api = Envoy::Api::createApiForTest(stats_store);
for (int i = 1; i < argc; ++i) {
const std::string arg{argv[i]};
if (arg.empty() || arg[0] == '-') {
break;
}
++input_args;
// Outputs from envoy_directory_genrule might be directories or we might
// have artisanal files.
if (api->fileSystem().directoryExists(arg)) {
const auto paths = Envoy::TestUtility::listFiles(arg, true);
Envoy::test_corpus_.insert(Envoy::test_corpus_.begin(), paths.begin(), paths.end());
} else {
Envoy::test_corpus_.emplace_back(arg);
}
}
}
argc -= input_args;
Expand Down