Merge pull request #6433 from ethereum/fuzzhelp

Run several instances of solfuzzer in parallel
This commit is contained in:
chriseth 2019-04-01 17:49:58 +02:00 committed by GitHub
commit 862ad28edd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 29 deletions

View File

@ -392,26 +392,9 @@ SOLTMPDIR=$(mktemp -d)
cd "$SOLTMPDIR"
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/test/
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs
for f in *.sol
do
set +e
"$REPO_ROOT"/build/test/tools/solfuzzer --quiet < "$f"
if [ $? -ne 0 ]
then
printError "Fuzzer failed on:"
cat "$f"
exit 1
fi
"$REPO_ROOT"/build/test/tools/solfuzzer --without-optimizer --quiet < "$f"
if [ $? -ne 0 ]
then
printError "Fuzzer (without optimizer) failed on:"
cat "$f"
exit 1
fi
set -e
done
echo *.sol | xargs -P 4 -n 50 "$REPO_ROOT"/build/test/tools/solfuzzer --quiet --input-files
echo *.sol | xargs -P 4 -n 50 "$REPO_ROOT"/build/test/tools/solfuzzer --without-optimizer --quiet --input-files
)
rm -rf "$SOLTMPDIR"

View File

@ -60,6 +60,10 @@ Allowed options)",
"input-file",
po::value<string>(),
"input file"
)(
"input-files",
po::value<std::vector<string>>()->multitoken(),
"input files"
)
(
"without-optimizer",
@ -93,18 +97,47 @@ Allowed options)",
return 0;
}
string input;
vector<string> inputs;
if (arguments.count("input-file"))
input = readFileAsString(arguments["input-file"].as<string>());
inputs.push_back(arguments["input-file"].as<string>());
else if (arguments.count("input-files"))
inputs = arguments["input-files"].as<vector<string>>();
else
input = readStandardInput();
inputs.push_back("");
if (arguments.count("const-opt"))
FuzzerUtil::testConstantOptimizer(input, quiet);
else if (arguments.count("standard-json"))
FuzzerUtil::testStandardCompiler(input, quiet);
else
FuzzerUtil::testCompiler(input, !arguments.count("without-optimizer"), quiet);
bool optimize = !arguments.count("without-optimizer");
int retResult = 0;
return 0;
for (string const& inputFile: inputs)
{
string input;
if (inputFile.size() == 0)
input = readStandardInput();
else
input = readFileAsString(inputFile);
try
{
if (arguments.count("const-opt"))
FuzzerUtil::testConstantOptimizer(input, quiet);
else if (arguments.count("standard-json"))
FuzzerUtil::testStandardCompiler(input, quiet);
else
FuzzerUtil::testCompiler(input, optimize, quiet);
}
catch (exception const& _exc)
{
retResult = 1;
if (inputFile.size() == 0)
throw _exc;
cerr << "Fuzzer "
<< (optimize ? "" : "(without optimizer) ")
<< "failed on "
<< inputFile;
}
}
return retResult;
}