mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
specified user defined test
This commit is contained in:
parent
a77d78d994
commit
b4d8ff5fdc
39
state.cpp
39
state.cpp
@ -128,4 +128,43 @@ BOOST_AUTO_TEST_CASE(stPreCompiledContracts)
|
||||
dev::test::executeTests("stPreCompiledContracts", "/StateTests", dev::test::doStateTests);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(userDefinedFileState)
|
||||
{
|
||||
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
|
||||
{
|
||||
string arg = boost::unit_test::framework::master_test_suite().argv[i];
|
||||
if (arg == "--statetest")
|
||||
{
|
||||
if (i + 1 >= boost::unit_test::framework::master_test_suite().argc)
|
||||
{
|
||||
cnote << "Missing filename\nUsage: testeth --statetest <filename>\n";
|
||||
return;
|
||||
}
|
||||
string filename = boost::unit_test::framework::master_test_suite().argv[i+1];
|
||||
int currentVerbosity = g_logVerbosity;
|
||||
g_logVerbosity = 12;
|
||||
try
|
||||
{
|
||||
cnote << "Testing VM..." << "user defined test";
|
||||
json_spirit::mValue v;
|
||||
string s = asString(contents(filename));
|
||||
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + filename + " is empty. ");
|
||||
json_spirit::read_string(s, v);
|
||||
dev::test::doStateTests(v, false);
|
||||
}
|
||||
catch (Exception const& _e)
|
||||
{
|
||||
BOOST_ERROR("Failed state test with Exception: " << diagnostic_information(_e));
|
||||
}
|
||||
catch (std::exception const& _e)
|
||||
{
|
||||
BOOST_ERROR("Failed state test with Exception: " << _e.what());
|
||||
}
|
||||
g_logVerbosity = currentVerbosity;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
53
vm.cpp
53
vm.cpp
@ -459,31 +459,42 @@ BOOST_AUTO_TEST_CASE(vmRandom)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(userDefinedFile)
|
||||
BOOST_AUTO_TEST_CASE(userDefinedFileVM)
|
||||
{
|
||||
if (boost::unit_test::framework::master_test_suite().argc == 2)
|
||||
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
|
||||
{
|
||||
string filename = boost::unit_test::framework::master_test_suite().argv[1];
|
||||
int currentVerbosity = g_logVerbosity;
|
||||
g_logVerbosity = 12;
|
||||
try
|
||||
string arg = boost::unit_test::framework::master_test_suite().argv[i];
|
||||
if (arg == "--vmtest")
|
||||
{
|
||||
cnote << "Testing VM..." << "user defined test";
|
||||
json_spirit::mValue v;
|
||||
string s = asString(contents(filename));
|
||||
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + filename + " is empty. ");
|
||||
json_spirit::read_string(s, v);
|
||||
dev::test::doVMTests(v, false);
|
||||
if (i + 1 >= boost::unit_test::framework::master_test_suite().argc)
|
||||
{
|
||||
cnote << "Missing filename\nUsage: testeth --vmtest <filename>\n";
|
||||
return;
|
||||
}
|
||||
string filename = boost::unit_test::framework::master_test_suite().argv[i+1];
|
||||
int currentVerbosity = g_logVerbosity;
|
||||
g_logVerbosity = 12;
|
||||
try
|
||||
{
|
||||
cnote << "Testing VM..." << "user defined test";
|
||||
json_spirit::mValue v;
|
||||
string s = asString(contents(filename));
|
||||
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + filename + " is empty. ");
|
||||
json_spirit::read_string(s, v);
|
||||
dev::test::doVMTests(v, false);
|
||||
}
|
||||
catch (Exception const& _e)
|
||||
{
|
||||
BOOST_ERROR("Failed VM Test with Exception: " << diagnostic_information(_e));
|
||||
}
|
||||
catch (std::exception const& _e)
|
||||
{
|
||||
BOOST_ERROR("Failed VM Test with Exception: " << _e.what());
|
||||
}
|
||||
g_logVerbosity = currentVerbosity;
|
||||
}
|
||||
catch (Exception const& _e)
|
||||
{
|
||||
BOOST_ERROR("Failed VM Test with Exception: " << diagnostic_information(_e));
|
||||
}
|
||||
catch (std::exception const& _e)
|
||||
{
|
||||
BOOST_ERROR("Failed VM Test with Exception: " << _e.what());
|
||||
}
|
||||
g_logVerbosity = currentVerbosity;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user