From 787ebd369e7fa7206bfc73702c8e9a151240d2f9 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Thu, 30 Apr 2020 13:43:57 -0700 Subject: [PATCH] Improve standalone fuzzer driver error messages --- src/fuzzers/standalone-driver.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/fuzzers/standalone-driver.cc b/src/fuzzers/standalone-driver.cc index e603d73735..840b8d8e52 100644 --- a/src/fuzzers/standalone-driver.cc +++ b/src/fuzzers/standalone-driver.cc @@ -1,6 +1,7 @@ #include #include -#include +#include +#include #include #include @@ -26,7 +27,12 @@ int main(int argc, char** argv) fflush(stdout); auto f = fopen(input_file_name, "r"); - assert(f); + + if ( ! f ) + { + printf(" failed to open file: %s\n", strerror(errno)); + abort(); + } fseek(f, 0, SEEK_END); auto input_length = ftell(f); @@ -34,7 +40,13 @@ int main(int argc, char** argv) auto input_buffer = std::make_unique(input_length); auto bytes_read = fread(input_buffer.get(), 1, input_length, f); - assert(bytes_read == static_cast(input_length)); + + if ( bytes_read != static_cast(input_length) ) + { + printf(" failed to read full file: %zu/%ld\n", + bytes_read, input_length); + abort(); + } auto start = high_resolution_clock::now(); LLVMFuzzerTestOneInput(input_buffer.get(), input_length);