Add corpus based multi source fuzzer

Co-authored-by: Leonardo <leo@ethereum.org>
This commit is contained in:
Bhargava Shastry
2020-07-21 13:43:29 +02:00
co-authored by Leonardo
parent eab999f753
commit 4067bab7dd
7 changed files with 54 additions and 9 deletions
+16 -1
View File
@@ -18,6 +18,11 @@
#include <test/tools/fuzzer_common.h>
#include <test/TestCaseReader.h>
#include <sstream>
using namespace solidity::frontend::test;
using namespace std;
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
@@ -25,7 +30,17 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
if (_size <= 600)
{
string input(reinterpret_cast<char const*>(_data), _size);
FuzzerUtil::testCompiler(input, /*optimize=*/false);
map<string, string> sourceCode;
try
{
TestCaseReader t = TestCaseReader(std::istringstream(input));
sourceCode = t.sources().sources;
}
catch (runtime_error const&)
{
return 0;
}
FuzzerUtil::testCompiler(sourceCode, /*optimize=*/false, /*_rand=*/_size);
}
return 0;
}