Skip to content

Commit

Permalink
Merge pull request #86 from ethereum/develop
Browse files Browse the repository at this point in the history
develop branch
  • Loading branch information
winsvega authored Apr 22, 2020
2 parents a984214 + 6b1f8c1 commit e801888
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 19 deletions.
27 changes: 23 additions & 4 deletions retesteth/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,21 @@ void printHelp()
cout << "\nAll options below must be followed by `--`\n";
cout << "\nRetesteth options\n";
cout << setw(40) << "-j <ThreadNumber>" << setw(0) << "Run test execution using threads\n";
cout << setw(40) << "--clients `<client1, client2>`" << setw(0)
<< "Use following configurations from the testpath/Retesteth\n";
cout << setw(40) << "--clients `client1, client2`" << setw(0)
<< "Use following configurations from datadir path (default: ~/.retesteth)\n";
cout << setw(40) << "--datadir" << setw(0) << "Path to configs (default: ~/.retesteth)\n";
cout << setw(40) << "--nodes" << setw(0) << "List of client tcp ports (\"addr:ip, addr:ip\")\n";
cout << setw(42) << " " << setw(0) << "Overrides the config file \"socketAddress\" section \n";
cout << setw(40) << "--help" << setw(25) << "Display list of command arguments\n";
cout << setw(40) << "--version" << setw(25) << "Display build information\n";
cout << setw(40) << "--list" << setw(25) << "Display available test suites\n";

cout << "\nSetting test suite and test\n";
cout << setw(40) << "--testpath <PathToTheTestRepo>" << setw(25) << "Set path to the test repo\n";
cout << setw(40) << "--testfile <TestFile>" << setw(0) << "Run tests from a file. Requires -t <TestSuite>\n";
cout << setw(40) << "--singletest <TestName>/<Subtest>" << setw(0) << "Run on a single test (Testname is filename without Filler.json, Subtest is a test name inside the file)\n";
cout << setw(40) << "--singletest <TestName>" << setw(0)
<< "Run on a single test. `Testname` is filename without Filler.json\n";
cout << setw(40) << "--singletest <TestName>/<Subtest>" << setw(0) << "`Subtest` is a test name inside the file\n";

cout << "\nDebugging\n";
cout << setw(30) << "-d <index>" << setw(25) << "Set the transaction data array index when running GeneralStateTests\n";
Expand All @@ -77,6 +82,7 @@ void printHelp()
cout << setw(30) << "--showhash" << setw(25) << "Show filler hash debug information\n";
cout << setw(30) << "--poststate" << setw(25) << "Show post state hash or fullstate\n";
cout << setw(30) << "--fullstate" << setw(25) << "Do not compress large states to hash\n";

// cout << setw(30) << "--randomcode <MaxOpcodeNum>" << setw(25) << "Generate smart random EVM
//code\n"; cout << setw(30) << "--createRandomTest" << setw(25) << "Create random test and
//output it to the console\n"; cout << setw(30) << "--createRandomTest <PathToOptions.json>" <<
Expand Down Expand Up @@ -243,7 +249,18 @@ Options::Options(int argc, const char** argv)
if (logVerbosity > (size_t)g_logVerbosity)
g_logVerbosity = logVerbosity;
}
else if (arg == "--options")
else if (arg == "--datadir")
{
throwIfNoArgumentFollows();
datadir = fs::path(std::string{argv[++i]});
}
else if (arg == "--nodes")
{
throwIfNoArgumentFollows();
for (auto const& el : explode(std::string{argv[++i]}, ','))
nodesoverride.addArrayObject(el);
}
else if (arg == "--options")
{
throwIfNoArgumentFollows();
boost::filesystem::path file(std::string{argv[++i]});
Expand Down Expand Up @@ -392,6 +409,8 @@ void displayTestSuites()
cout << setw(40) << "-t BlockchainTests/ValidBlocks" << setw(0) << "Subset of correct blocks\n";
cout << setw(40) << "-t BlockchainTests/InvalidBlocks" << setw(0) << "Subset of malicious blocks\n";
cout << setw(40) << "-t BlockchainTests/TransitionTests" << setw(0) << "Subset of fork transition tests\n";
cout << setw(40) << "-t BlockchainTests/ValidBlocks/VMTests" << setw(0)
<< "VMTests converted\n";
cout << "(Use --filltests to generate the tests, --fillchain to generate BCGeneralStateTests)\n";

cout << "\nLegacy test suites (Frontier .. ConstantinopleFix):\n";
Expand Down
4 changes: 3 additions & 1 deletion retesteth/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class Options
bool stats = false; ///< Execution time and stats for state tests
bool poststate = false;
std::string statsOutFile; ///< Stats output file. "out" for standard output
bool exectimelog = false; ///< Print execution time for each test suite
fs::path datadir; ///< Path to datadir (~/.retesteth)
DataObject nodesoverride; ///< ["IP:port", ""IP:port""] array
bool exectimelog = false; ///< Print execution time for each test suite
std::string rCurrentTestSuite; ///< Remember test suite before boost overwrite (for random tests)
bool statediff = false; ///< Fill full post state in General tests
bool fullstate = false; ///< Replace large state output to it's hash
Expand Down
6 changes: 5 additions & 1 deletion retesteth/RPCSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@ void RPCSession::runNewInstanceOfAClient(string const& _threadID, ClientConfig c
{
std::lock_guard<std::mutex> lock(g_socketMapMutex); // function must be called from lock

DataObject const& ports = (Options::get().nodesoverride.getSubObjects().size() > 0 ?
Options::get().nodesoverride :
_config.getAddressObject());

// Create sessionInfo for a tcp address that is still not present in socketMap
for (auto const& addr : _config.getAddressObject().getSubObjects())
for (auto const& addr : ports.getSubObjects())
{
bool unused = true;
for (auto const& socket : socketMap)
Expand Down
11 changes: 11 additions & 0 deletions retesteth/TestHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,17 @@ string replaceCode(string const& _code)
return compiledCode;
}

/// Explode string into array of strings by `delim`
std::vector<std::string> explode(std::string const& s, char delim)
{
std::vector<std::string> result;
std::istringstream iss(s);
for (std::string token; std::getline(iss, token, delim);)
result.push_back(std::move(token));
return result;
}


#include <sys/wait.h>
#define READ 0
#define WRITE 1
Expand Down
2 changes: 2 additions & 0 deletions retesteth/TestHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ bool inArray(std::vector<T> const& _array, const T& _val)
return false;
}

/// Explode string into array of strings by `delim`
std::vector<std::string> explode(std::string const& s, char delim);

/// popen with pid at return
enum popenOutput
Expand Down
18 changes: 16 additions & 2 deletions retesteth/configs/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,23 @@ using namespace std;
using namespace test;
namespace fs = boost::filesystem;

namespace
{
fs::path getRetestethDataDir()
{
fs::path const& dir = Options::get().datadir;
bool optionsEmpty = dir.empty();
if (!optionsEmpty && !fs::exists(dir))
ETH_LOG(
"Options path `" + dir.string() + "` doesn't exist, attempt to create a new directory",
3);
return optionsEmpty ? getDataDir("retesteth") : dir;
}
} // namespace

void deployFirstRunConfigs()
{
fs::path homeDir = getDataDir("retesteth");
fs::path homeDir = getRetestethDataDir();

if (fs::exists(homeDir))
{
Expand Down Expand Up @@ -105,7 +119,7 @@ std::vector<ClientConfig> const& Options::DynamicOptions::getClientConfigs()

for (auto const& clientName : cfgs)
{
fs::path configDirectory = getDataDir("retesteth"); // getTestPath();
fs::path configDirectory = getRetestethDataDir();
ETH_FAIL_REQUIRE_MESSAGE(fs::exists(configDirectory),
"Could not locate provided testpath: " + string(configDirectory.c_str()));
fs::path configPath = configDirectory / clientName;
Expand Down
14 changes: 3 additions & 11 deletions retesteth/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
#include <retesteth/ExitHandler.h>
#include <retesteth/Options.h>
#include <retesteth/RPCSession.h>
#include <retesteth/TestHelper.h>
#include <retesteth/TestOutputHelper.h>
#include <retesteth/testSuites/StateTests.h>
#include <retesteth/testSuites/blockchain/BlockchainTests.h>
#include <boost/test/included/unit_test.hpp>
#include <clocale>
#include <cstdlib>
#include <iostream>
#include <thread>
#include <retesteth/testSuites/StateTests.h>
#include <retesteth/testSuites/blockchain/BlockchainTests.h>

using namespace boost::unit_test;
static std::ostringstream strCout;
Expand Down Expand Up @@ -103,15 +104,6 @@ void setDefaultOrCLocale()
#endif
}

std::vector<std::string> explode(std::string const& s, char delim)
{
std::vector<std::string> result;
std::istringstream iss(s);
for (std::string token; std::getline(iss, token, delim);)
result.push_back(std::move(token));
return result;
}

// Custom Boost Unit Test Main
int main(int argc, const char* argv[])
{
Expand Down

0 comments on commit e801888

Please sign in to comment.