2016-08-01 05:25:37 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Bash script to execute the Solidity tests.
|
|
|
|
#
|
|
|
|
# The documentation for solidity is hosted at:
|
|
|
|
#
|
|
|
|
# https://solidity.readthedocs.org
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# This file is part of solidity.
|
|
|
|
#
|
|
|
|
# solidity is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# solidity is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with solidity. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
#
|
|
|
|
# (c) 2016 solidity contributors.
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2016-08-01 13:33:01 +00:00
|
|
|
set -e
|
|
|
|
|
2016-11-02 11:32:55 +00:00
|
|
|
REPO_ROOT="$(dirname "$0")"/..
|
|
|
|
|
2018-02-13 10:54:22 +00:00
|
|
|
if [ "$1" = --junit_report ]
|
|
|
|
then
|
|
|
|
if [ -z "$2" ]
|
|
|
|
then
|
|
|
|
echo "Usage: $0 [--junit_report <report_directory>]"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-02-22 16:21:26 +00:00
|
|
|
log_directory="$2"
|
2018-02-13 10:54:22 +00:00
|
|
|
else
|
2018-02-22 16:21:26 +00:00
|
|
|
log_directory=""
|
2018-02-13 10:54:22 +00:00
|
|
|
fi
|
|
|
|
|
2018-04-17 06:53:21 +00:00
|
|
|
function printError() { echo "$(tput setaf 1)$1$(tput sgr0)"; }
|
|
|
|
function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
|
|
|
|
|
|
|
|
|
|
|
|
printTask "Running commandline tests..."
|
2018-02-26 19:41:18 +00:00
|
|
|
"$REPO_ROOT/test/cmdlineTests.sh" &
|
|
|
|
CMDLINE_PID=$!
|
|
|
|
# Only run in parallel if this is run on CI infrastructure
|
|
|
|
if [ -z "$CI" ]
|
|
|
|
then
|
2018-04-17 06:53:21 +00:00
|
|
|
if ! wait $CMDLINE_PID
|
|
|
|
then
|
|
|
|
printError "Commandline tests FAILED"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-02-26 19:41:18 +00:00
|
|
|
fi
|
2017-07-05 10:28:15 +00:00
|
|
|
|
2018-02-26 19:41:18 +00:00
|
|
|
function download_eth()
|
|
|
|
{
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
ETH_PATH="$REPO_ROOT/eth"
|
|
|
|
elif [ -z $CI ]; then
|
|
|
|
ETH_PATH="eth"
|
|
|
|
else
|
|
|
|
mkdir -p /tmp/test
|
|
|
|
if grep -i trusty /etc/lsb-release >/dev/null 2>&1
|
|
|
|
then
|
2018-04-05 17:00:32 +00:00
|
|
|
# built from 5ac09111bd0b6518365fe956e1bdb97a2db82af1 at 2018-04-05
|
|
|
|
ETH_BINARY=eth_2018-04-05_trusty
|
|
|
|
ETH_HASH="1e5e178b005e5b51f9d347df4452875ba9b53cc6"
|
2018-03-06 10:04:29 +00:00
|
|
|
else
|
2018-04-05 17:00:32 +00:00
|
|
|
# built from 5ac09111bd0b6518365fe956e1bdb97a2db82af1 at 2018-04-05
|
|
|
|
ETH_BINARY=eth_2018-04-05_artful
|
|
|
|
ETH_HASH="eb2d0df022753bb2b442ba73e565a9babf6828d6"
|
2018-02-26 19:41:18 +00:00
|
|
|
fi
|
|
|
|
wget -q -O /tmp/test/eth https://github.com/ethereum/cpp-ethereum/releases/download/solidityTester/$ETH_BINARY
|
|
|
|
test "$(shasum /tmp/test/eth)" = "$ETH_HASH /tmp/test/eth"
|
|
|
|
sync
|
|
|
|
chmod +x /tmp/test/eth
|
|
|
|
sync # Otherwise we might get a "text file busy" error
|
|
|
|
ETH_PATH="/tmp/test/eth"
|
2018-02-13 10:54:22 +00:00
|
|
|
fi
|
2016-08-01 05:25:37 +00:00
|
|
|
|
2018-02-26 19:41:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# $1: data directory
|
|
|
|
# echos the PID
|
|
|
|
function run_eth()
|
|
|
|
{
|
|
|
|
$ETH_PATH --test -d "$1" >/dev/null 2>&1 &
|
|
|
|
echo $!
|
|
|
|
# Wait until the IPC endpoint is available.
|
|
|
|
while [ ! -S "$1"/geth.ipc ] ; do sleep 1; done
|
|
|
|
sleep 2
|
|
|
|
}
|
|
|
|
|
|
|
|
download_eth
|
|
|
|
ETH_PID=$(run_eth /tmp/test)
|
|
|
|
|
|
|
|
progress="--show-progress"
|
2018-04-16 20:12:30 +00:00
|
|
|
if [ "$CIRCLECI" ]
|
2018-02-26 19:41:18 +00:00
|
|
|
then
|
|
|
|
progress=""
|
|
|
|
fi
|
2016-08-01 05:25:37 +00:00
|
|
|
|
2018-04-06 10:20:01 +00:00
|
|
|
EVM_VERSIONS="homestead byzantium"
|
|
|
|
|
|
|
|
if [ "$CIRCLECI" ] || [ -z "$CI" ]
|
|
|
|
then
|
|
|
|
EVM_VERSIONS+=" constantinople"
|
|
|
|
fi
|
|
|
|
|
2018-02-22 16:21:26 +00:00
|
|
|
# And then run the Solidity unit-tests in the matrix combination of optimizer / no optimizer
|
|
|
|
# and homestead / byzantium VM, # pointing to that IPC endpoint.
|
|
|
|
for optimize in "" "--optimize"
|
|
|
|
do
|
2018-04-06 10:20:01 +00:00
|
|
|
for vm in $EVM_VERSIONS
|
2018-02-22 16:21:26 +00:00
|
|
|
do
|
2018-04-17 06:53:21 +00:00
|
|
|
printTask "--> Running tests using "$optimize" --evm-version "$vm"..."
|
2018-02-22 16:21:26 +00:00
|
|
|
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
|
2018-03-06 19:45:34 +00:00
|
|
|
"$REPO_ROOT"/build/test/soltest $progress $log -- --testpath "$REPO_ROOT"/test "$optimize" --evm-version "$vm" --ipcpath /tmp/test/geth.ipc
|
2018-02-22 16:21:26 +00:00
|
|
|
done
|
|
|
|
done
|
2018-02-26 19:41:18 +00:00
|
|
|
|
2018-04-17 06:53:21 +00:00
|
|
|
if ! wait $CMDLINE_PID
|
|
|
|
then
|
|
|
|
printError "Commandline tests FAILED"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-02-26 19:41:18 +00:00
|
|
|
|
2017-02-08 12:56:23 +00:00
|
|
|
pkill "$ETH_PID" || true
|
2016-08-01 13:33:01 +00:00
|
|
|
sleep 4
|
2018-03-06 10:04:29 +00:00
|
|
|
pgrep "$ETH_PID" && pkill -9 "$ETH_PID" || true
|