Merge pull request #5899 from ethereum/fuzzer

Minor cleanups and improved debugging in the fuzzer
This commit is contained in:
chriseth 2019-01-30 10:05:27 +01:00 committed by GitHub
commit bf3968d69b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 18 deletions

View File

@ -19,11 +19,16 @@
*/
#include <test/tools/fuzzer_common.h>
#include <libdevcore/CommonIO.h>
#include <boost/program_options.hpp>
#include <string>
#include <iostream>
using namespace std;
using namespace dev;
using namespace dev::eth;
namespace po = boost::program_options;
@ -98,4 +103,4 @@ Allowed options)",
FuzzerUtil::testCompiler(input, !arguments.count("without-optimizer"), quiet);
return 0;
}
}

View File

@ -16,15 +16,25 @@
*/
#include <test/tools/fuzzer_common.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/JSON.h>
#include <libevmasm/Assembly.h>
#include <libevmasm/ConstantOptimiser.h>
#include <libsolc/libsolc.h>
#include <sstream>
using namespace std;
using namespace dev;
using namespace dev::eth;
void FuzzerUtil::runCompiler(string _input)
void FuzzerUtil::runCompiler(string const& _input, bool _quiet)
{
if (!_quiet)
cout << "Input JSON: " << _input << endl;
string outputString(solidity_compile(_input.c_str(), nullptr));
if (!_quiet)
cout << "Output JSON: " << outputString << endl;
Json::Value output;
if (!jsonParseStrict(outputString, output))
{
@ -66,7 +76,7 @@ void FuzzerUtil::testCompiler(string const& _input, bool _optimize, bool _quiet)
// Enable all Contract-level outputs.
config["settings"]["outputSelection"]["*"]["*"][0] = "*";
runCompiler(jsonCompactPrint(config));
runCompiler(jsonCompactPrint(config), _quiet);
}
void FuzzerUtil::testConstantOptimizer(string const& _input, bool _quiet)
@ -112,5 +122,5 @@ void FuzzerUtil::testStandardCompiler(string const& _input, bool _quiet)
if (!_quiet)
cout << "Testing compiler via JSON interface." << endl;
runCompiler(_input);
runCompiler(_input, _quiet);
}

View File

@ -15,21 +15,12 @@
along with solidity. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libdevcore/CommonIO.h>
#include <libevmasm/Assembly.h>
#include <libsolc/libsolc.h>
#include <libevmasm/ConstantOptimiser.h>
#include <libdevcore/JSON.h>
#include <string>
#include <sstream>
#include <iostream>
struct FuzzerUtil
{
static void runCompiler(std::string _input);
static void testCompiler(std::string const& _input, bool _optimize, bool quiet);
static void runCompiler(std::string const& _input, bool _quiet);
static void testCompiler(std::string const& _input, bool _optimize, bool _quiet);
static void testConstantOptimizer(std::string const& _input, bool _quiet);
static void testStandardCompiler(std::string const& _input, bool _quiet);
};
};