File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -348,10 +348,20 @@ internal::Configuration CreateConfigurationsFromFlags(
348348 << " If specified, --" << FUZZTEST_FLAG (jobs).Name ()
349349 << " must be positive." ;
350350 std::string corpus_database = absl::GetFlag (FUZZTEST_FLAG (corpus_database));
351- if (!corpus_database.empty () && corpus_database[0 ] != ' /' &&
352- std::getenv (" TEST_SRCDIR" )) {
353- corpus_database =
354- absl::StrCat (std::getenv (" TEST_SRCDIR" ), " /" , corpus_database);
351+ if (!corpus_database.empty () && corpus_database[0 ] != ' /' ) {
352+ // When fuzzing, pick the undeclared output directory for a relative corpus
353+ // database path, because the output directory is writable. Otherwise, pick
354+ // the test srcdir (read-only) as the current directory when dealing with a
355+ // relative corpus database path.
356+ if (fuzzing_time_limit) { // Need a writable directory.
357+ if (std::getenv (" TEST_UNDECLARED_OUTPUTS_DIR" )) {
358+ corpus_database = absl::StrCat (
359+ std::getenv (" TEST_UNDECLARED_OUTPUTS_DIR" ), " /" , corpus_database);
360+ }
361+ } else if (std::getenv (" TEST_SRCDIR" )) { // Need a read-only directory.
362+ corpus_database =
363+ absl::StrCat (std::getenv (" TEST_SRCDIR" ), " /" , corpus_database);
364+ }
355365 }
356366 return internal::Configuration{
357367 corpus_database,
You can’t perform that action at this time.
0 commit comments