Skip to content

Commit

Permalink
Print input loading stats only when something was loaded.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 657276764
  • Loading branch information
lszekeres authored and copybara-github committed Aug 8, 2024
1 parent ec01ce6 commit 7bd2fe9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fuzztest/internal/io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ std::optional<std::string> ReadFile(absl::string_view path) {
// Using stderr instead of GetStderr() to avoid initialization-order-fiasco
// when reading files at static init time with
// `.WithSeeds(fuzztest::ReadFilesFromDirectory(...))`.
absl::FPrintF(stderr, "[!] %s:%d: Error reading %s: (%d) %s\n",
__FILE__, __LINE__, path, errno, strerror(errno));
absl::FPrintF(stderr, "[!] %s:%d: Error reading %s: (%d) %s\n", __FILE__,
__LINE__, path, errno, strerror(errno));
return std::nullopt;
}
std::stringstream buffer;
Expand Down Expand Up @@ -284,10 +284,12 @@ void ForEachSerializedInput(absl::Span<const std::string> file_paths,
result.message());
}
}
absl::FPrintF(
GetStderr(),
"[*] In total, loaded %d inputs and ignored %d invalid inputs.\n",
total_loaded_inputs, total_invalid_inputs);
if (total_loaded_inputs != 0) {
absl::FPrintF(
GetStderr(),
"[*] In total, loaded %d inputs and ignored %d invalid inputs.\n",
total_loaded_inputs, total_invalid_inputs);
}
}

} // namespace fuzztest::internal

0 comments on commit 7bd2fe9

Please sign in to comment.