diff --git a/test/tools/afl_fuzzer.cpp b/test/tools/afl_fuzzer.cpp index 31e05716e..2a8632899 100644 --- a/test/tools/afl_fuzzer.cpp +++ b/test/tools/afl_fuzzer.cpp @@ -125,12 +125,12 @@ Allowed options)", else FuzzerUtil::testCompiler(input, optimize, quiet); } - catch (exception const& _exc) + catch (...) { retResult = 1; if (inputFile.size() == 0) - throw _exc; + throw; cerr << "Fuzzer " << (optimize ? "" : "(without optimizer) ") diff --git a/test/tools/fuzzer_common.cpp b/test/tools/fuzzer_common.cpp index 0c031c9da..0a193b410 100644 --- a/test/tools/fuzzer_common.cpp +++ b/test/tools/fuzzer_common.cpp @@ -42,8 +42,9 @@ void FuzzerUtil::runCompiler(string const& _input, bool _quiet) Json::Value output; if (!jsonParseStrict(outputString, output)) { - cout << "Compiler produced invalid JSON output." << endl; - abort(); + string msg{"Compiler produced invalid JSON output."}; + cout << msg << endl; + throw std::runtime_error(std::move(msg)); } if (output.isMember("errors")) for (auto const& error: output["errors"]) @@ -54,8 +55,9 @@ void FuzzerUtil::runCompiler(string const& _input, bool _quiet) }); if (!invalid.empty()) { - cout << "Invalid error: \"" << error["type"].asString() << "\"" << endl; - abort(); + string msg = "Invalid error: \"" + error["type"].asString() + "\""; + cout << msg << endl; + throw std::runtime_error(std::move(msg)); } } } diff --git a/test/tools/fuzzer_common.h b/test/tools/fuzzer_common.h index ded0b6730..edf196c1c 100644 --- a/test/tools/fuzzer_common.h +++ b/test/tools/fuzzer_common.h @@ -17,6 +17,10 @@ #include +/** + * Functions to be used for fuzz-testing of various components. + * They throw exceptions or error. + */ struct FuzzerUtil { static void runCompiler(std::string const& _input, bool _quiet);