Test both EVM versions.

This commit is contained in:
chriseth 2018-02-22 17:21:26 +01:00
parent 83515eadcf
commit f2f61f1c2f
7 changed files with 58 additions and 21 deletions

View File

@ -5,10 +5,6 @@ jobs:
- image: trzeci/emscripten:sdk-tag-1.37.21-64bit - image: trzeci/emscripten:sdk-tag-1.37.21-64bit
steps: steps:
- checkout - checkout
- run:
name: Init submodules
command: |
git submodule update --init
- restore_cache: - restore_cache:
name: Restore Boost build name: Restore Boost build
key: &boost-cache-key emscripten-boost-{{ checksum "scripts/travis-emscripten/install_deps.sh" }}{{ checksum "scripts/travis-emscripten/build_emscripten.sh" }} key: &boost-cache-key emscripten-boost-{{ checksum "scripts/travis-emscripten/install_deps.sh" }}{{ checksum "scripts/travis-emscripten/build_emscripten.sh" }}
@ -94,10 +90,6 @@ jobs:
command: | command: |
apt-get -qq update apt-get -qq update
apt-get -qy install ccache cmake libboost-all-dev libz3-dev apt-get -qy install ccache cmake libboost-all-dev libz3-dev
- run:
name: Init submodules
command: |
git submodule update --init
- run: - run:
name: Store commit hash and prerelease name: Store commit hash and prerelease
command: | command: |

View File

@ -37,11 +37,9 @@ then
echo "Usage: $0 [--junit_report <report_directory>]" echo "Usage: $0 [--junit_report <report_directory>]"
exit 1 exit 1
fi fi
testargs_no_opt="--logger=JUNIT,test_suite,$2/no_opt.xml" log_directory="$2"
testargs_opt="--logger=JUNIT,test_suite,$2/opt.xml"
else else
testargs_no_opt='' log_directory=""
testargs_opt=''
fi fi
echo "Running commandline tests..." echo "Running commandline tests..."
@ -98,10 +96,31 @@ then
progress="" progress=""
fi fi
echo "--> Running tests without optimizer..." ERROR_CODE=0
"$REPO_ROOT"/build/test/soltest $testargs_no_opt $progress -- --ipcpath /tmp/test/geth.ipc # And then run the Solidity unit-tests in the matrix combination of optimizer / no optimizer
echo "--> Running tests WITH optimizer..." # and homestead / byzantium VM, # pointing to that IPC endpoint.
"$REPO_ROOT"/build/test/soltest $testargs_opt $progress -- --optimize --ipcpath /tmp/test/geth.ipc for optimize in "" "--optimize"
do
for vm in homestead byzantium
do
echo "--> Running tests using "$optimize" --evm-version "$vm"..."
log=""
if [ -n "$log_directory" ]
then
if [ -n "$optimize" ]
then
log=--logger=JUNIT,test_suite,$log_directory/opt_$vm.xml $testargs
else
log=--logger=JUNIT,test_suite,$log_directory/noopt_$vm.xml $testargs_no_opt
fi
fi
set +e
"$REPO_ROOT"/build/test/soltest $progress $log -- "$optimize" --evm-version "$vm" --ipcpath /tmp/test/geth.ipc
THIS_ERR=$?
set -e
if [ $? -ne 0 ]; then ERROR_CODE=$?; fi
done
done
wait $CMDLINE_PID wait $CMDLINE_PID

View File

@ -20,13 +20,15 @@
* Framework for executing contracts and testing them using RPC. * Framework for executing contracts and testing them using RPC.
*/ */
#include <cstdlib>
#include <boost/test/framework.hpp>
#include <libdevcore/CommonIO.h>
#include <test/ExecutionFramework.h> #include <test/ExecutionFramework.h>
#include <libdevcore/CommonIO.h>
#include <boost/test/framework.hpp>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <cstdlib>
using namespace std; using namespace std;
using namespace dev; using namespace dev;
using namespace dev::test; using namespace dev::test;
@ -53,6 +55,13 @@ ExecutionFramework::ExecutionFramework() :
m_showMessages(dev::test::Options::get().showMessages), m_showMessages(dev::test::Options::get().showMessages),
m_sender(m_rpc.account(0)) m_sender(m_rpc.account(0))
{ {
if (!dev::test::Options::get().evmVersion.empty())
{
auto version = solidity::EVMVersion::fromString(dev::test::Options::get().evmVersion);
BOOST_REQUIRE_MESSAGE(version, "Invalid EVM version: " + dev::test::Options::get().evmVersion);
m_evmVersion = *version;
}
m_rpc.test_rewindToBlock(0); m_rpc.test_rewindToBlock(0);
} }

View File

@ -25,6 +25,8 @@
#include <test/TestHelper.h> #include <test/TestHelper.h>
#include <test/RPCSession.h> #include <test/RPCSession.h>
#include <libsolidity/interface/EVMVersion.h>
#include <libdevcore/FixedHash.h> #include <libdevcore/FixedHash.h>
#include <libdevcore/SHA3.h> #include <libdevcore/SHA3.h>
@ -227,6 +229,7 @@ protected:
bytes data; bytes data;
}; };
solidity::EVMVersion m_evmVersion;
unsigned m_optimizeRuns = 200; unsigned m_optimizeRuns = 200;
bool m_optimize = false; bool m_optimize = false;
bool m_showMessages = false; bool m_showMessages = false;

View File

@ -19,8 +19,12 @@
* @date 2014 * @date 2014
*/ */
#include <test/TestHelper.h>
#include <libsolidity/interface/EVMVersion.h>
#include <boost/test/framework.hpp> #include <boost/test/framework.hpp>
#include "TestHelper.h"
using namespace std; using namespace std;
using namespace dev::test; using namespace dev::test;
@ -41,6 +45,11 @@ Options::Options()
} }
else if (string(suite.argv[i]) == "--optimize") else if (string(suite.argv[i]) == "--optimize")
optimize = true; optimize = true;
else if (string(suite.argv[i]) == "--evm-version")
{
evmVersion = i + 1 < suite.argc ? suite.argv[i + 1] : "INVALID";
++i;
}
else if (string(suite.argv[i]) == "--show-messages") else if (string(suite.argv[i]) == "--show-messages")
showMessages = true; showMessages = true;
else if (string(suite.argv[i]) == "--no-ipc") else if (string(suite.argv[i]) == "--no-ipc")

View File

@ -19,11 +19,14 @@
#pragma once #pragma once
#include <functional> #include <libsolidity/interface/EVMVersion.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/version.hpp> #include <boost/version.hpp>
#include <functional>
namespace dev namespace dev
{ {
namespace test namespace test
@ -33,6 +36,7 @@ struct Options: boost::noncopyable
{ {
std::string ipcPath; std::string ipcPath;
bool showMessages = false; bool showMessages = false;
std::string evmVersion;
bool optimize = false; bool optimize = false;
bool disableIPC = false; bool disableIPC = false;
bool disableSMT = false; bool disableSMT = false;

View File

@ -68,6 +68,7 @@ public:
m_compiler.reset(false); m_compiler.reset(false);
m_compiler.addSource("", sourceCode); m_compiler.addSource("", sourceCode);
m_compiler.setLibraries(_libraryAddresses); m_compiler.setLibraries(_libraryAddresses);
m_compiler.setEVMVersion(m_evmVersion);
m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns); m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns);
if (!m_compiler.compile()) if (!m_compiler.compile())
{ {