Replace preprocessor macros with constexpr expressions.

This commit is contained in:
Daniel Kirchner 2019-09-11 13:01:51 +02:00
parent 733d40ddb5
commit 2535091168
4 changed files with 19 additions and 18 deletions

View File

@ -76,7 +76,7 @@ std::string EVMOneEnvOrDefaultPath()
};
for (auto const& basePath: searchPath)
{
fs::path p = basePath / EVMONE_FILENAME;
fs::path p = basePath / evmoneFilename;
if (fs::exists(p))
return p.string();
}
@ -92,7 +92,7 @@ CommonOptions::CommonOptions(std::string _caption):
options.add_options()
("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")
("evmonepath", po::value<fs::path>(&evmonePath)->default_value(EVMOneEnvOrDefaultPath()), "path to " EVMONE_FILENAME)
("evmonepath", po::value<fs::path>(&evmonePath)->default_value(EVMOneEnvOrDefaultPath()), "path to evmone library")
("no-smt", po::bool_switch(&disableSMT), "disable SMT checker");
}

View File

@ -24,23 +24,24 @@
#include <boost/program_options.hpp>
#include <boost/noncopyable.hpp>
#ifdef _WIN32
#define EVMONE_FILENAME "evmone.dll"
#define EVMONE_DOWNLOADLINK "https://github.com/ethereum/evmone/releases/download/v0.1.0/evmone-0.1.0-windows-amd64.zip"
#elif defined(__APPLE__)
#define EVMONE_FILENAME "libevmone.dylib"
#define EVMONE_DOWNLOADLINK "https://github.com/ethereum/evmone/releases/download/v0.1.0/evmone-0.1.0-darwin-x86_64.tar.gz"
#else
#define EVMONE_FILENAME "libevmone.so"
#define EVMONE_DOWNLOADLINK "https://github.com/ethereum/evmone/releases/download/v0.1.0/evmone-0.1.0-linux-x86_64.tar.gz"
#endif
namespace dev
{
namespace test
{
#ifdef _WIN32
static constexpr auto evmoneFilename = "evmone.dll";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.1.0/evmone-0.1.0-windows-amd64.zip";
#elif defined(__APPLE__)
static constexpr auto evmoneFilename = "libevmone.dylib";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.1.0/evmone-0.1.0-darwin-x86_64.tar.gz";
#else
static constexpr auto evmoneFilename = "libevmone.so";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.1.0/evmone-0.1.0-linux-x86_64.tar.gz";
#endif
struct ConfigException : public Exception {};
struct CommonOptions: boost::noncopyable

View File

@ -143,9 +143,9 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
bool disableSemantics = !dev::test::EVMHost::getVM(dev::test::Options::get().evmonePath.string());
if (disableSemantics)
{
cout << "Unable to find " EVMONE_FILENAME ". Please provide the path using -- --evmonepath <path>." << endl;
cout << "Unable to find " << dev::test::evmoneFilename << ". Please provide the path using -- --evmonepath <path>." << endl;
cout << "You can download it at" << endl;
cout << EVMONE_DOWNLOADLINK << endl;
cout << dev::test::evmoneDownloadLink << endl;
cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl;
}
// Include the interactive tests in the automatic tests as well

View File

@ -417,9 +417,9 @@ int main(int argc, char const *argv[])
bool disableSemantics = !dev::test::EVMHost::getVM(options.evmonePath.string());
if (disableSemantics)
{
cout << "Unable to find " EVMONE_FILENAME ". Please provide the path using --evmonepath <path>." << endl;
cout << "Unable to find " << dev::test::evmoneFilename << ". Please provide the path using --evmonepath <path>." << endl;
cout << "You can download it at" << endl;
cout << EVMONE_DOWNLOADLINK << endl;
cout << dev::test::evmoneDownloadLink << endl;
cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl;
}
@ -462,7 +462,7 @@ int main(int argc, char const *argv[])
cout << "." << endl;
if (disableSemantics)
cout << "\nNOTE: Skipped semantics tests because " EVMONE_FILENAME " could not be found.\n" << endl;
cout << "\nNOTE: Skipped semantics tests because " << dev::test::evmoneFilename << " could not be found.\n" << endl;
return global_stats ? 0 : 1;
}