2020-12-11 19:05:42 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-04-26 09:57:49 +00:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Bash script to execute the Solidity tests by CircleCI.
|
|
|
|
#
|
|
|
|
# The documentation for solidity is hosted at:
|
|
|
|
#
|
2020-11-18 14:20:34 +00:00
|
|
|
# https://docs.soliditylang.org
|
2019-04-26 09:57:49 +00:00
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Configuration Environment Variables:
|
|
|
|
#
|
|
|
|
# EVM=version_string Specifies EVM version to compile for (such as homestead, etc)
|
|
|
|
# OPTIMIZE=1 Enables backend optimizer
|
2020-11-19 15:58:41 +00:00
|
|
|
# ABI_ENCODER_V1=1 Forcibly enables ABI coder version 1
|
2019-11-04 08:48:35 +00:00
|
|
|
# SOLTEST_FLAGS=<flags> Appends <flags> to default SOLTEST_ARGS
|
2019-04-26 09:57:49 +00:00
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# 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-2019 solidity contributors.
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
set -e
|
|
|
|
|
|
|
|
OPTIMIZE=${OPTIMIZE:-"0"}
|
|
|
|
EVM=${EVM:-"invalid"}
|
2020-12-11 17:19:53 +00:00
|
|
|
REPODIR="$(realpath "$(dirname "$0")/..")"
|
2019-04-26 09:57:49 +00:00
|
|
|
|
2020-12-11 20:34:55 +00:00
|
|
|
IFS=" " read -r -a BOOST_TEST_ARGS <<< "$BOOST_TEST_ARGS"
|
|
|
|
IFS=" " read -r -a SOLTEST_FLAGS <<< "$SOLTEST_FLAGS"
|
|
|
|
|
2020-12-12 00:46:21 +00:00
|
|
|
# shellcheck source=scripts/common.sh
|
2019-04-26 09:57:49 +00:00
|
|
|
source "${REPODIR}/scripts/common.sh"
|
|
|
|
# Test result output directory (CircleCI is reading test results from here)
|
|
|
|
mkdir -p test_results
|
|
|
|
|
2021-10-28 17:08:06 +00:00
|
|
|
# in case we run with ASAN enabled, we must increase stack size.
|
2019-04-26 09:57:49 +00:00
|
|
|
ulimit -s 16384
|
|
|
|
|
2019-08-14 14:20:18 +00:00
|
|
|
get_logfile_basename() {
|
2021-12-20 18:03:48 +00:00
|
|
|
local run="$1"
|
2019-08-14 14:20:18 +00:00
|
|
|
local filename="${EVM}"
|
|
|
|
test "${OPTIMIZE}" = "1" && filename="${filename}_opt"
|
2020-11-19 15:58:41 +00:00
|
|
|
test "${ABI_ENCODER_V1}" = "1" && filename="${filename}_abiv1"
|
2021-12-20 18:03:48 +00:00
|
|
|
filename="${filename}_${run}"
|
2019-08-14 14:20:18 +00:00
|
|
|
|
|
|
|
echo -ne "${filename}"
|
|
|
|
}
|
|
|
|
|
2021-12-20 18:03:48 +00:00
|
|
|
[ -z "$CIRCLE_NODE_TOTAL" ] || [ "$CIRCLE_NODE_TOTAL" = 0 ] && CIRCLE_NODE_TOTAL=1
|
|
|
|
[ -z "$CIRCLE_NODE_INDEX" ] && CIRCLE_NODE_INDEX=0
|
|
|
|
[ -z "$INDEX_SHIFT" ] && INDEX_SHIFT=0
|
2020-12-11 20:34:55 +00:00
|
|
|
|
2021-12-20 18:03:48 +00:00
|
|
|
# Multiply by a prime number to get better spread, just in case
|
|
|
|
# long-running test cases are next to each other.
|
|
|
|
CIRCLE_NODE_INDEX=$(((CIRCLE_NODE_INDEX + 23 * INDEX_SHIFT) % CIRCLE_NODE_TOTAL))
|
2019-04-26 09:57:49 +00:00
|
|
|
|
2021-12-20 18:03:48 +00:00
|
|
|
CPUs=3
|
|
|
|
PIDs=()
|
|
|
|
for run in $(seq 0 $((CPUs - 1)))
|
|
|
|
do
|
|
|
|
BOOST_TEST_ARGS_RUN=(
|
|
|
|
"--color_output=no"
|
|
|
|
"--show_progress=yes"
|
2022-04-13 17:50:11 +00:00
|
|
|
"--logger=JUNIT,error,test_results/$(get_logfile_basename "$((CPUs * CIRCLE_NODE_INDEX + run))").xml"
|
2021-12-20 18:03:48 +00:00
|
|
|
"${BOOST_TEST_ARGS[@]}"
|
|
|
|
)
|
|
|
|
SOLTEST_ARGS=("--evm-version=$EVM" "${SOLTEST_FLAGS[@]}")
|
2019-06-24 10:42:05 +00:00
|
|
|
|
2021-12-20 18:03:48 +00:00
|
|
|
test "${OPTIMIZE}" = "1" && SOLTEST_ARGS+=(--optimize)
|
|
|
|
test "${ABI_ENCODER_V1}" = "1" && SOLTEST_ARGS+=(--abiencoderv1)
|
|
|
|
|
|
|
|
BATCH_ARGS=("--batches" "$((CPUs * CIRCLE_NODE_TOTAL))" "--selected-batch" "$((CPUs * CIRCLE_NODE_INDEX + run))")
|
|
|
|
|
|
|
|
echo "Running ${REPODIR}/build/test/soltest ${BOOST_TEST_ARGS_RUN[*]} -- ${SOLTEST_ARGS[*]}"
|
|
|
|
|
|
|
|
"${REPODIR}/build/test/soltest" -l test_suite "${BOOST_TEST_ARGS_RUN[@]}" -- "${SOLTEST_ARGS[@]}" "${BATCH_ARGS[@]}" &
|
|
|
|
PIDs+=($!)
|
|
|
|
done
|
|
|
|
|
|
|
|
# wait for individual processes to get their exit status
|
|
|
|
for pid in ${PIDs[*]}
|
|
|
|
do
|
|
|
|
wait "$pid"
|
|
|
|
done
|