mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
adds --input-file=FILENAME to solfuzzer
This commit is contained in:
parent
f6f0cecc2f
commit
212a6e146a
@ -28,6 +28,7 @@
|
|||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -48,15 +49,17 @@ string contains(string const& _haystack, vector<string> const& _needles)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void testConstantOptimizer()
|
void testConstantOptimizer(string const& input)
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
cout << "Testing constant optimizer" << endl;
|
cout << "Testing constant optimizer" << endl;
|
||||||
vector<u256> numbers;
|
vector<u256> numbers;
|
||||||
while (!cin.eof())
|
stringstream sin(input);
|
||||||
|
|
||||||
|
while (!sin.eof())
|
||||||
{
|
{
|
||||||
h256 data;
|
h256 data;
|
||||||
cin.read(reinterpret_cast<char*>(data.data()), 32);
|
sin.read(reinterpret_cast<char*>(data.data()), 32);
|
||||||
numbers.push_back(u256(data));
|
numbers.push_back(u256(data));
|
||||||
}
|
}
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
@ -108,20 +111,18 @@ void runCompiler(string input)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testStandardCompiler()
|
void testStandardCompiler(string const& input)
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
cout << "Testing compiler via JSON interface." << endl;
|
cout << "Testing compiler via JSON interface." << endl;
|
||||||
string input = readStandardInput();
|
|
||||||
|
|
||||||
runCompiler(input);
|
runCompiler(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testCompiler(bool optimize)
|
void testCompiler(string const& input, bool optimize)
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
cout << "Testing compiler " << (optimize ? "with" : "without") << " optimizer." << endl;
|
cout << "Testing compiler " << (optimize ? "with" : "without") << " optimizer." << endl;
|
||||||
string input = readStandardInput();
|
|
||||||
|
|
||||||
Json::Value config = Json::objectValue;
|
Json::Value config = Json::objectValue;
|
||||||
config["language"] = "Solidity";
|
config["language"] = "Solidity";
|
||||||
@ -167,16 +168,25 @@ Allowed options)",
|
|||||||
"Run the constant optimizer instead of compiling. "
|
"Run the constant optimizer instead of compiling. "
|
||||||
"Expects a binary string of up to 32 bytes on stdin."
|
"Expects a binary string of up to 32 bytes on stdin."
|
||||||
)
|
)
|
||||||
|
(
|
||||||
|
"input-file",
|
||||||
|
po::value<string>(),
|
||||||
|
"input file"
|
||||||
|
)
|
||||||
(
|
(
|
||||||
"without-optimizer",
|
"without-optimizer",
|
||||||
"Run without optimizations. Cannot be used together with standard-json."
|
"Run without optimizations. Cannot be used together with standard-json."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// All positional options should be interpreted as input files
|
||||||
|
po::positional_options_description filesPositions;
|
||||||
|
filesPositions.add("input-file", 1);
|
||||||
|
|
||||||
po::variables_map arguments;
|
po::variables_map arguments;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
po::command_line_parser cmdLineParser(argc, argv);
|
po::command_line_parser cmdLineParser(argc, argv);
|
||||||
cmdLineParser.options(options);
|
cmdLineParser.options(options).positional(filesPositions);
|
||||||
po::store(cmdLineParser.run(), arguments);
|
po::store(cmdLineParser.run(), arguments);
|
||||||
}
|
}
|
||||||
catch (po::error const& _exception)
|
catch (po::error const& _exception)
|
||||||
@ -185,17 +195,23 @@ Allowed options)",
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string input;
|
||||||
|
if (arguments.count("input-file"))
|
||||||
|
input = readFileAsString(arguments["input-file"].as<string>());
|
||||||
|
else
|
||||||
|
input = readStandardInput();
|
||||||
|
|
||||||
if (arguments.count("quiet"))
|
if (arguments.count("quiet"))
|
||||||
quiet = true;
|
quiet = true;
|
||||||
|
|
||||||
if (arguments.count("help"))
|
if (arguments.count("help"))
|
||||||
cout << options;
|
cout << options;
|
||||||
else if (arguments.count("const-opt"))
|
else if (arguments.count("const-opt"))
|
||||||
testConstantOptimizer();
|
testConstantOptimizer(input);
|
||||||
else if (arguments.count("standard-json"))
|
else if (arguments.count("standard-json"))
|
||||||
testStandardCompiler();
|
testStandardCompiler(input);
|
||||||
else
|
else
|
||||||
testCompiler(!arguments.count("without-optimizer"));
|
testCompiler(input, !arguments.count("without-optimizer"));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user