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

GetSeedDataDirs: allow TEST_DATA_DIRS to be -D defined #2162

Merged
merged 2 commits into from
May 21, 2024
Merged
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions tests/gtest/avif_fuzztest_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,20 @@ ::testing::Environment* SetEnv(const char* name, const char* value) {

//------------------------------------------------------------------------------

// Helper macros to ensure TEST_DATA_DIRS is a quoted string.
// NOTE: TEST_DATA_DIRS MUST NOT be a quoted string before stringification
jzern marked this conversation as resolved.
Show resolved Hide resolved
// otherwise it will be quoted twice, resulting in the use of an incorrect path.
#define AVIF_TO_STRING(S) #S
#define AVIF_STRINGIFY(S) AVIF_TO_STRING(S)
jzern marked this conversation as resolved.
Show resolved Hide resolved

std::vector<std::string> GetSeedDataDirs() {
const char* var = std::getenv("TEST_DATA_DIRS");
std::vector<std::string> res;
#ifdef TEST_DATA_DIRS
if (var == nullptr) {
var = AVIF_STRINGIFY(TEST_DATA_DIRS);
}
#endif
if (var == nullptr || *var == 0) return res;
const char* var_start = var;
while (true) {
Expand All @@ -203,6 +214,9 @@ std::vector<std::string> GetSeedDataDirs() {
return res;
}

#undef AVIF_STRINGIFY
#undef AVIF_TO_STRING

std::vector<std::string> GetTestImagesContents(
size_t max_file_size, const std::vector<avifAppFileFormat>& image_formats) {
// Use an environment variable to get the test data directory because
Expand Down
Loading