mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Throw exception to allow fuzzer to report which file it failed on.
This commit is contained in:
parent
3795569da6
commit
ef413bb0b3
@ -125,12 +125,12 @@ Allowed options)",
|
|||||||
else
|
else
|
||||||
FuzzerUtil::testCompiler(input, optimize, quiet);
|
FuzzerUtil::testCompiler(input, optimize, quiet);
|
||||||
}
|
}
|
||||||
catch (exception const& _exc)
|
catch (...)
|
||||||
{
|
{
|
||||||
retResult = 1;
|
retResult = 1;
|
||||||
|
|
||||||
if (inputFile.size() == 0)
|
if (inputFile.size() == 0)
|
||||||
throw _exc;
|
throw;
|
||||||
|
|
||||||
cerr << "Fuzzer "
|
cerr << "Fuzzer "
|
||||||
<< (optimize ? "" : "(without optimizer) ")
|
<< (optimize ? "" : "(without optimizer) ")
|
||||||
|
@ -42,8 +42,9 @@ void FuzzerUtil::runCompiler(string const& _input, bool _quiet)
|
|||||||
Json::Value output;
|
Json::Value output;
|
||||||
if (!jsonParseStrict(outputString, output))
|
if (!jsonParseStrict(outputString, output))
|
||||||
{
|
{
|
||||||
cout << "Compiler produced invalid JSON output." << endl;
|
string msg{"Compiler produced invalid JSON output."};
|
||||||
abort();
|
cout << msg << endl;
|
||||||
|
throw std::runtime_error(std::move(msg));
|
||||||
}
|
}
|
||||||
if (output.isMember("errors"))
|
if (output.isMember("errors"))
|
||||||
for (auto const& error: output["errors"])
|
for (auto const& error: output["errors"])
|
||||||
@ -54,8 +55,9 @@ void FuzzerUtil::runCompiler(string const& _input, bool _quiet)
|
|||||||
});
|
});
|
||||||
if (!invalid.empty())
|
if (!invalid.empty())
|
||||||
{
|
{
|
||||||
cout << "Invalid error: \"" << error["type"].asString() << "\"" << endl;
|
string msg = "Invalid error: \"" + error["type"].asString() + "\"";
|
||||||
abort();
|
cout << msg << endl;
|
||||||
|
throw std::runtime_error(std::move(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Functions to be used for fuzz-testing of various components.
|
||||||
|
* They throw exceptions or error.
|
||||||
|
*/
|
||||||
struct FuzzerUtil
|
struct FuzzerUtil
|
||||||
{
|
{
|
||||||
static void runCompiler(std::string const& _input, bool _quiet);
|
static void runCompiler(std::string const& _input, bool _quiet);
|
||||||
|
Loading…
Reference in New Issue
Block a user