mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Provide path to libevmone.
This commit is contained in:
parent
13e2a6fe52
commit
f692cec11d
@ -57,15 +57,12 @@ boost::filesystem::path testPath()
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string IPCEnvOrDefaultPath()
|
string EVMOneEnvOrDefaultPath()
|
||||||
{
|
{
|
||||||
if (auto path = getenv("ETH_TEST_IPC"))
|
if (auto path = getenv("ETH_EVMONE"))
|
||||||
return path;
|
return path;
|
||||||
|
else
|
||||||
if (auto home = getenv("HOME"))
|
return "./libevmone.so";
|
||||||
return std::string(home) + "/.ethereum/geth.ipc";
|
|
||||||
|
|
||||||
return std::string{};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonOptions::CommonOptions(std::string _caption):
|
CommonOptions::CommonOptions(std::string _caption):
|
||||||
@ -77,8 +74,7 @@ CommonOptions::CommonOptions(std::string _caption):
|
|||||||
options.add_options()
|
options.add_options()
|
||||||
("evm-version", po::value(&evmVersionString), "which evm version to use")
|
("evm-version", po::value(&evmVersionString), "which evm version to use")
|
||||||
("testpath", po::value<fs::path>(&this->testPath)->default_value(dev::test::testPath()), "path to test files")
|
("testpath", po::value<fs::path>(&this->testPath)->default_value(dev::test::testPath()), "path to test files")
|
||||||
("ipcpath", po::value<fs::path>(&ipcPath)->default_value(IPCEnvOrDefaultPath()), "path to ipc socket")
|
("evmonepath", po::value<fs::path>(&evmonePath)->default_value(EVMOneEnvOrDefaultPath()), "path to libevmone.so")
|
||||||
("no-ipc", po::bool_switch(&disableIPC), "disable semantic tests")
|
|
||||||
("no-smt", po::bool_switch(&disableSMT), "disable SMT checker");
|
("no-smt", po::bool_switch(&disableSMT), "disable SMT checker");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,19 +91,6 @@ void CommonOptions::validate() const
|
|||||||
"Invalid test path specified."
|
"Invalid test path specified."
|
||||||
);
|
);
|
||||||
|
|
||||||
// if (!disableIPC)
|
|
||||||
// {
|
|
||||||
// assertThrow(
|
|
||||||
// !ipcPath.empty(),
|
|
||||||
// ConfigException,
|
|
||||||
// "No ipc path specified. The --ipcpath argument must not be empty when given."
|
|
||||||
// );
|
|
||||||
// assertThrow(
|
|
||||||
// fs::exists(ipcPath),
|
|
||||||
// ConfigException,
|
|
||||||
// "Invalid ipc path specified."
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommonOptions::parse(int argc, char const* const* argv)
|
bool CommonOptions::parse(int argc, char const* const* argv)
|
||||||
|
@ -34,11 +34,10 @@ struct ConfigException : public Exception {};
|
|||||||
|
|
||||||
struct CommonOptions: boost::noncopyable
|
struct CommonOptions: boost::noncopyable
|
||||||
{
|
{
|
||||||
boost::filesystem::path ipcPath;
|
boost::filesystem::path evmonePath;
|
||||||
boost::filesystem::path testPath;
|
boost::filesystem::path testPath;
|
||||||
bool optimize = false;
|
bool optimize = false;
|
||||||
bool optimizeYul = false;
|
bool optimizeYul = false;
|
||||||
bool disableIPC = false;
|
|
||||||
bool disableSMT = false;
|
bool disableSMT = false;
|
||||||
|
|
||||||
langutil::EVMVersion evmVersion() const;
|
langutil::EVMVersion evmVersion() const;
|
||||||
|
@ -35,41 +35,18 @@ using namespace std;
|
|||||||
using namespace dev;
|
using namespace dev;
|
||||||
using namespace dev::test;
|
using namespace dev::test;
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
|
evmc::vm* EVMHost::getVM(string const& _path)
|
||||||
evmc::vm& getVM()
|
|
||||||
{
|
{
|
||||||
static unique_ptr<evmc::vm> theVM;
|
static unique_ptr<evmc::vm> theVM;
|
||||||
if (!theVM)
|
if (!theVM && !_path.empty())
|
||||||
{
|
{
|
||||||
// TODO make this an option
|
evmc_loader_error_code errorCode = {};
|
||||||
for (auto path: {
|
evmc_instance* vm = evmc_load_and_create(_path.c_str(), &errorCode);
|
||||||
"deps/lib/libevmone.so",
|
if (vm && errorCode == EVMC_LOADER_SUCCESS)
|
||||||
"../deps/lib/libevmone.so",
|
|
||||||
"/usr/lib/libevmone.so",
|
|
||||||
"/usr/local/lib/libevmone.so",
|
|
||||||
// TODO the circleci docker image somehow only has the .a file
|
|
||||||
"/usr/lib/libevmone.a"
|
|
||||||
})
|
|
||||||
{
|
|
||||||
evmc_loader_error_code errorCode = {};
|
|
||||||
evmc_instance* vm = evmc_load_and_create(path, &errorCode);
|
|
||||||
if (!vm || errorCode != EVMC_LOADER_SUCCESS)
|
|
||||||
continue;
|
|
||||||
theVM = make_unique<evmc::vm>(vm);
|
theVM = make_unique<evmc::vm>(vm);
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!theVM)
|
|
||||||
{
|
|
||||||
cerr << "Unable to find library libevmone.so" << endl;
|
|
||||||
assertThrow(false, Exception, "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return *theVM;
|
return theVM.get();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::vm* _vm):
|
EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::vm* _vm):
|
||||||
|
@ -38,6 +38,11 @@ using Address = h160;
|
|||||||
class EVMHost: public evmc::Host
|
class EVMHost: public evmc::Host
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// Tries to dynamically load libevmone. @returns nullptr on failure.
|
||||||
|
/// The path has to be provided for the first successful run and will be ignored
|
||||||
|
/// afterwards.
|
||||||
|
static evmc::vm* getVM(std::string const& _path = {});
|
||||||
|
|
||||||
explicit EVMHost(langutil::EVMVersion _evmVersion, evmc::vm* _vm = getVM());
|
explicit EVMHost(langutil::EVMVersion _evmVersion, evmc::vm* _vm = getVM());
|
||||||
|
|
||||||
struct Account
|
struct Account
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#include <test/InteractiveTests.h>
|
#include <test/InteractiveTests.h>
|
||||||
#include <test/Options.h>
|
#include <test/Options.h>
|
||||||
|
#include <test/EVMHost.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
@ -140,6 +141,14 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
|
|||||||
master.p_name.value = "SolidityTests";
|
master.p_name.value = "SolidityTests";
|
||||||
dev::test::Options::get().validate();
|
dev::test::Options::get().validate();
|
||||||
|
|
||||||
|
bool disableIPC = !dev::test::EVMHost::getVM();
|
||||||
|
if (disableIPC)
|
||||||
|
{
|
||||||
|
cout << "Unable to find libevmone.so. Please provide the path using -- --evmonepath <path>." << endl;
|
||||||
|
cout << "You can download it at" << endl;
|
||||||
|
cout << "https://github.com/ethereum/evmone/releases/download/v0.1.0/evmone-0.1.0-linux-x86_64.tar.gz" << endl;
|
||||||
|
cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl;
|
||||||
|
}
|
||||||
// Include the interactive tests in the automatic tests as well
|
// Include the interactive tests in the automatic tests as well
|
||||||
for (auto const& ts: g_interactiveTestsuites)
|
for (auto const& ts: g_interactiveTestsuites)
|
||||||
{
|
{
|
||||||
@ -148,19 +157,19 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
|
|||||||
if (ts.smt && options.disableSMT)
|
if (ts.smt && options.disableSMT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ts.ipc && options.disableIPC)
|
if (ts.ipc && disableIPC)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
solAssert(registerTests(
|
solAssert(registerTests(
|
||||||
master,
|
master,
|
||||||
options.testPath / ts.path,
|
options.testPath / ts.path,
|
||||||
ts.subpath,
|
ts.subpath,
|
||||||
options.ipcPath.string(),
|
options.evmonePath.string(),
|
||||||
ts.testCaseCreator
|
ts.testCaseCreator
|
||||||
) > 0, std::string("no ") + ts.title + " tests found");
|
) > 0, std::string("no ") + ts.title + " tests found");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev::test::Options::get().disableIPC)
|
if (disableIPC)
|
||||||
{
|
{
|
||||||
for (auto suite: {
|
for (auto suite: {
|
||||||
"ABIDecoderTest",
|
"ABIDecoderTest",
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <test/tools/IsolTestOptions.h>
|
#include <test/tools/IsolTestOptions.h>
|
||||||
#include <test/libsolidity/AnalysisFramework.h>
|
#include <test/libsolidity/AnalysisFramework.h>
|
||||||
#include <test/InteractiveTests.h>
|
#include <test/InteractiveTests.h>
|
||||||
|
#include <test/EVMHost.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
@ -156,7 +157,7 @@ TestTool::Result TestTool::process()
|
|||||||
{
|
{
|
||||||
(AnsiColorized(cout, formatted, {BOLD}) << m_name << ": ").flush();
|
(AnsiColorized(cout, formatted, {BOLD}) << m_name << ": ").flush();
|
||||||
|
|
||||||
m_test = m_testCaseCreator(TestCase::Config{m_path.string(), m_options.ipcPath.string(), m_options.evmVersion()});
|
m_test = m_testCaseCreator(TestCase::Config{m_path.string(), m_options.evmonePath.string(), m_options.evmVersion()});
|
||||||
if (m_test->validateSettings(m_options.evmVersion()))
|
if (m_test->validateSettings(m_options.evmVersion()))
|
||||||
switch (TestCase::TestResult result = m_test->run(outputMessages, " ", formatted))
|
switch (TestCase::TestResult result = m_test->run(outputMessages, " ", formatted))
|
||||||
{
|
{
|
||||||
@ -413,6 +414,15 @@ int main(int argc, char const *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool disableSemantics = !dev::test::EVMHost::getVM();
|
||||||
|
if (disableSemantics)
|
||||||
|
{
|
||||||
|
cout << "Unable to find libevmone.so. Please provide the path using --evmonepath <path>." << endl;
|
||||||
|
cout << "You can download it at" << endl;
|
||||||
|
cout << "https://github.com/ethereum/evmone/releases/download/v0.1.0/evmone-0.1.0-linux-x86_64.tar.gz" << endl;
|
||||||
|
cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
TestStats global_stats{0, 0};
|
TestStats global_stats{0, 0};
|
||||||
cout << "Running tests..." << endl << endl;
|
cout << "Running tests..." << endl << endl;
|
||||||
|
|
||||||
@ -420,7 +430,7 @@ int main(int argc, char const *argv[])
|
|||||||
// Interactive tests are added in InteractiveTests.h
|
// Interactive tests are added in InteractiveTests.h
|
||||||
for (auto const& ts: g_interactiveTestsuites)
|
for (auto const& ts: g_interactiveTestsuites)
|
||||||
{
|
{
|
||||||
if (ts.ipc && options.disableIPC)
|
if (ts.ipc && disableSemantics)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ts.smt && options.disableSMT)
|
if (ts.smt && options.disableSMT)
|
||||||
@ -451,5 +461,8 @@ int main(int argc, char const *argv[])
|
|||||||
}
|
}
|
||||||
cout << "." << endl;
|
cout << "." << endl;
|
||||||
|
|
||||||
|
if (disableSemantics)
|
||||||
|
cout << "\nNOTE: Skipped semantics tests because libevmone.so could not be found.\n" << endl;
|
||||||
|
|
||||||
return global_stats ? 0 : 1;
|
return global_stats ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user