From e18c7b99cb440639adc0063c33c26566ba9589a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 12 Mar 2015 11:55:00 +0100 Subject: testeth: optional VM tracing (--vmtrace), command line options refactoring. Closes ethereum/cpp-ethereum#1280 --- TestHelper.cpp | 80 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 30 deletions(-) (limited to 'TestHelper.cpp') diff --git a/TestHelper.cpp b/TestHelper.cpp index 9ac64107..fcca4630 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -439,8 +439,6 @@ void userDefinedTest(string testTypeFlag, std::function 0, "Contents of " + dir.string() + "/" + _name + "Filler.json is empty."); - json_spirit::read_string(s, v); - doTests(v, true); - writeFile(testPath + "/" + _name + ".json", asBytes(json_spirit::write_string(v, true))); - } - catch (Exception const& _e) - { - BOOST_ERROR("Failed filling test with Exception: " << diagnostic_information(_e)); - } - catch (std::exception const& _e) - { - BOOST_ERROR("Failed filling test with Exception: " << _e.what()); - } - break; + cnote << "Populating tests..."; + json_spirit::mValue v; + boost::filesystem::path p(__FILE__); + boost::filesystem::path dir = p.parent_path(); + string s = asString(dev::contents(dir.string() + "/" + _name + "Filler.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + dir.string() + "/" + _name + "Filler.json is empty."); + json_spirit::read_string(s, v); + doTests(v, true); + writeFile(testPath + "/" + _name + ".json", asBytes(json_spirit::write_string(v, true))); + } + catch (Exception const& _e) + { + BOOST_ERROR("Failed filling test with Exception: " << diagnostic_information(_e)); + } + catch (std::exception const& _e) + { + BOOST_ERROR("Failed filling test with Exception: " << _e.what()); } } @@ -541,21 +534,48 @@ RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject& _tObj) return rlpStream; } -void processCommandLineOptions() +Options::Options() { auto argc = boost::unit_test::framework::master_test_suite().argc; auto argv = boost::unit_test::framework::master_test_suite().argv; - for (auto i = 0; i < argc; ++i) + for (auto i = 0; i < argc; ++i) { - if (std::string(argv[i]) == "--jit") + auto arg = std::string{argv[i]}; + if (arg == "--jit") { + jit = true; eth::VMFactory::setKind(eth::VMKind::JIT); - break; + } + else if (arg == "--vmtrace") + vmtrace = true; + else if (arg == "--performance") + performance = true; + else if (arg == "--quadratic") + quadratic = true; + else if (arg == "--memory") + memory = true; + else if (arg == "--inputlimits") + inputLimits = true; + else if (arg == "--bigdata") + bigData = true; + else if (arg == "--all") + { + performance = true; + quadratic = true; + memory = true; + inputLimits = true; + bigData = true; } } } +Options const& Options::get() +{ + static Options instance; + return instance; +} + LastHashes lastHashes(u256 _currentBlockNumber) { LastHashes ret; -- cgit v1.2.3