2021-09-09 04:49:46 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
#
|
|
|
|
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#
|
|
|
|
|
|
|
|
function DEBUG() {
|
|
|
|
[[ -n $(env | grep "\<DEBUG\>") ]] && $@
|
|
|
|
}
|
2022-08-02 08:03:50 +00:00
|
|
|
DEBUG set -xv pipefail
|
2021-09-09 04:49:46 +00:00
|
|
|
|
|
|
|
function help()
|
|
|
|
{
|
|
|
|
echo "test_wamr.sh [options]"
|
|
|
|
echo "-c clean previous test results, not start test"
|
2023-10-07 11:55:14 +00:00
|
|
|
echo "-s {suite_name} test only one suite (spec|wasi_certification|wamr_compiler)"
|
2023-11-27 07:24:02 +00:00
|
|
|
echo "-m set compile target of iwasm(x86_64|x86_32|armv7|armv7_vfp|thumbv7|thumbv7_vfp|"
|
|
|
|
echo " riscv32|riscv32_ilp32f|riscv32_ilp32d|riscv64|"
|
|
|
|
echo " riscv64_lp64f|riscv64_lp64d|aarch64|aarch64_vfp)"
|
2023-02-28 09:38:18 +00:00
|
|
|
echo "-t set compile type of iwasm(classic-interp|fast-interp|jit|aot|fast-jit|multi-tier-jit)"
|
2021-12-06 09:25:10 +00:00
|
|
|
echo "-M enable multi module feature"
|
2021-09-09 04:49:46 +00:00
|
|
|
echo "-p enable multi thread feature"
|
2021-12-06 09:25:10 +00:00
|
|
|
echo "-S enable SIMD feature"
|
2023-02-28 09:38:18 +00:00
|
|
|
echo "-G enable GC feature"
|
2021-12-06 09:25:10 +00:00
|
|
|
echo "-X enable XIP feature"
|
2021-09-09 04:49:46 +00:00
|
|
|
echo "-x test SGX"
|
2023-02-28 09:38:18 +00:00
|
|
|
echo "-w enable WASI threads"
|
2021-11-10 01:41:42 +00:00
|
|
|
echo "-b use the wabt binary release package instead of compiling from the source code"
|
2023-02-28 09:38:18 +00:00
|
|
|
echo "-g build iwasm with debug version"
|
|
|
|
echo "-v enable GC heap verification"
|
2021-11-10 01:41:42 +00:00
|
|
|
echo "-P run the spec test parallelly"
|
2022-11-28 02:45:32 +00:00
|
|
|
echo "-Q enable qemu"
|
|
|
|
echo "-F set the firmware path used by qemu"
|
2023-02-28 09:38:18 +00:00
|
|
|
echo "-C enable code coverage collect"
|
2023-10-04 13:55:37 +00:00
|
|
|
echo "-j set the platform to test"
|
2023-11-01 10:30:25 +00:00
|
|
|
echo "-T set sanitizer to use in tests(ubsan|tsan|asan)"
|
2021-09-09 04:49:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OPT_PARSED=""
|
|
|
|
WABT_BINARY_RELEASE="NO"
|
|
|
|
#default type
|
2022-12-19 03:24:46 +00:00
|
|
|
TYPE=("classic-interp" "fast-interp" "jit" "aot" "fast-jit" "multi-tier-jit")
|
2021-09-09 04:49:46 +00:00
|
|
|
#default target
|
|
|
|
TARGET="X86_64"
|
2023-02-27 12:28:37 +00:00
|
|
|
ENABLE_WASI_THREADS=0
|
2021-09-09 04:49:46 +00:00
|
|
|
ENABLE_MULTI_MODULE=0
|
|
|
|
ENABLE_MULTI_THREAD=0
|
|
|
|
COLLECT_CODE_COVERAGE=0
|
|
|
|
ENABLE_SIMD=0
|
2023-02-28 09:38:18 +00:00
|
|
|
ENABLE_GC=0
|
2021-12-06 09:25:10 +00:00
|
|
|
ENABLE_XIP=0
|
2023-02-28 09:38:18 +00:00
|
|
|
ENABLE_DEBUG_VERSION=0
|
|
|
|
ENABLE_GC_HEAP_VERIFY=0
|
2021-09-09 04:49:46 +00:00
|
|
|
#unit test case arrary
|
|
|
|
TEST_CASE_ARR=()
|
|
|
|
SGX_OPT=""
|
2023-08-09 01:40:59 +00:00
|
|
|
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
|
|
|
|
PLATFORM=windows
|
|
|
|
PYTHON_EXE=python
|
|
|
|
else
|
|
|
|
PLATFORM=$(uname -s | tr A-Z a-z)
|
|
|
|
PYTHON_EXE=python3
|
|
|
|
fi
|
2021-11-08 04:39:02 +00:00
|
|
|
PARALLELISM=0
|
2022-11-28 02:45:32 +00:00
|
|
|
ENABLE_QEMU=0
|
|
|
|
QEMU_FIRMWARE=""
|
2023-09-26 01:20:13 +00:00
|
|
|
# prod/testsuite-all branch
|
2023-10-06 12:12:08 +00:00
|
|
|
WASI_TESTSUITE_COMMIT="ee807fc551978490bf1c277059aabfa1e589a6c2"
|
2023-11-27 07:24:02 +00:00
|
|
|
TARGET_LIST=("AARCH64" "AARCH64_VFP" "ARMV7" "ARMV7_VFP" "THUMBV7" "THUMBV7_VFP" \
|
|
|
|
"RISCV32" "RISCV32_ILP32F" "RISCV32_ILP32D" "RISCV64" "RISCV64_LP64F" "RISCV64_LP64D")
|
2021-09-09 04:49:46 +00:00
|
|
|
|
2023-11-01 10:30:25 +00:00
|
|
|
while getopts ":s:cabgvt:m:MCpSXxwPGQF:j:T:" opt
|
2021-09-09 04:49:46 +00:00
|
|
|
do
|
|
|
|
OPT_PARSED="TRUE"
|
|
|
|
case $opt in
|
|
|
|
s)
|
|
|
|
TEST_CASE_ARR+=($OPTARG)
|
|
|
|
# get next suite if there are multiple vaule in -s
|
|
|
|
eval "nxarg=\${$((OPTIND))}"
|
|
|
|
# just get test cases, loop until the next symbol '-'
|
|
|
|
# IN ====> -s spec wasi unit -t fast-classic
|
|
|
|
# GET ====> spec wasi unit
|
|
|
|
while [[ "${nxarg}" != -* && ${nxarg} ]];
|
|
|
|
do
|
|
|
|
TEST_CASE_ARR+=(${nxarg})
|
|
|
|
OPTIND=$((OPTIND+1))
|
|
|
|
eval "nxarg=\${$((OPTIND))}"
|
|
|
|
done
|
|
|
|
echo "test following cases: ${TEST_CASE_ARR[@]}"
|
|
|
|
;;
|
|
|
|
c)
|
|
|
|
read -t 5 -p "Are you sure to delete all reports. y/n " cmd
|
|
|
|
if [[ $cmd == "y" && $(ls -A workspace/report) ]];then
|
2023-02-28 09:38:18 +00:00
|
|
|
rm -fr workspace/report/*
|
|
|
|
rm -fr /tmp/*.wasm /tmp/*.wast /tmp/*.aot
|
|
|
|
echo "cleaned all reports and temp files"
|
2021-09-09 04:49:46 +00:00
|
|
|
fi
|
|
|
|
exit 0;;
|
|
|
|
a)
|
|
|
|
TEST_ALL_AOT_RUNTIME="all"
|
|
|
|
echo "test all runtimes in sightglass_aot"
|
|
|
|
;;
|
|
|
|
b)
|
|
|
|
WABT_BINARY_RELEASE="YES"
|
|
|
|
echo "use a WABT binary release instead of compiling from source code"
|
|
|
|
;;
|
|
|
|
t)
|
|
|
|
echo "set compile type of wamr " ${OPTARG}
|
|
|
|
if [[ ${OPTARG} != "classic-interp" && ${OPTARG} != "fast-interp" \
|
2022-12-19 03:24:46 +00:00
|
|
|
&& ${OPTARG} != "jit" && ${OPTARG} != "aot"
|
|
|
|
&& ${OPTARG} != "fast-jit" && ${OPTARG} != "multi-tier-jit" ]]; then
|
2021-09-09 04:49:46 +00:00
|
|
|
echo "*----- please varify a type of compile when using -t! -----*"
|
|
|
|
help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
TYPE=(${OPTARG})
|
|
|
|
;;
|
|
|
|
m)
|
|
|
|
echo "set compile target of wamr" ${OPTARG}
|
|
|
|
TARGET=${OPTARG^^} # set target to uppercase if input x86_32 or x86_64 --> X86_32 and X86_64
|
|
|
|
;;
|
2023-02-27 12:28:37 +00:00
|
|
|
w)
|
|
|
|
echo "enable WASI threads"
|
|
|
|
ENABLE_WASI_THREADS=1
|
|
|
|
;;
|
2021-09-09 04:49:46 +00:00
|
|
|
M)
|
|
|
|
echo "enable multi module feature"
|
|
|
|
ENABLE_MULTI_MODULE=1
|
|
|
|
;;
|
|
|
|
C)
|
|
|
|
echo "enable code coverage"
|
|
|
|
COLLECT_CODE_COVERAGE=1
|
|
|
|
;;
|
|
|
|
p)
|
|
|
|
echo "enable multi thread feature"
|
|
|
|
ENABLE_MULTI_THREAD=1
|
|
|
|
;;
|
|
|
|
S)
|
|
|
|
echo "enable SIMD feature"
|
|
|
|
ENABLE_SIMD=1
|
|
|
|
;;
|
2021-12-06 09:25:10 +00:00
|
|
|
X)
|
|
|
|
echo "enable XIP feature"
|
|
|
|
ENABLE_XIP=1
|
|
|
|
;;
|
2021-09-09 04:49:46 +00:00
|
|
|
x)
|
|
|
|
echo "test SGX"
|
|
|
|
SGX_OPT="--sgx"
|
|
|
|
;;
|
2023-02-28 09:38:18 +00:00
|
|
|
g)
|
|
|
|
echo "enable build iwasm with debug version"
|
|
|
|
ENABLE_DEBUG_VERSION=1
|
|
|
|
;;
|
|
|
|
v)
|
|
|
|
echo "enable GC heap verification"
|
|
|
|
ENABLE_GC_HEAP_VERIFY=1
|
|
|
|
;;
|
|
|
|
G)
|
|
|
|
echo "enable GC feature"
|
|
|
|
ENABLE_GC=1
|
|
|
|
;;
|
2021-11-08 04:39:02 +00:00
|
|
|
P)
|
|
|
|
PARALLELISM=1
|
|
|
|
;;
|
2022-11-28 02:45:32 +00:00
|
|
|
Q)
|
|
|
|
echo "enable QEMU"
|
|
|
|
ENABLE_QEMU=1
|
|
|
|
;;
|
|
|
|
F)
|
|
|
|
echo "QEMU firmware" ${OPTARG}
|
|
|
|
QEMU_FIRMWARE=${OPTARG}
|
|
|
|
;;
|
2023-10-04 13:55:37 +00:00
|
|
|
j)
|
|
|
|
echo "test platform " ${OPTARG}
|
|
|
|
PLATFORM=${OPTARG}
|
|
|
|
;;
|
2023-11-01 10:30:25 +00:00
|
|
|
T)
|
|
|
|
echo "sanitizer is " ${OPTARG}
|
|
|
|
WAMR_BUILD_SANITIZER=${OPTARG}
|
|
|
|
;;
|
2021-09-09 04:49:46 +00:00
|
|
|
?)
|
|
|
|
help
|
2023-11-01 10:30:25 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
2021-09-09 04:49:46 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# Parameters are not allowed, use options instead
|
|
|
|
if [ -z "$OPT_PARSED" ];
|
|
|
|
then
|
|
|
|
if [ ! -z "$1" ];
|
|
|
|
then
|
|
|
|
help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p workspace
|
|
|
|
cd workspace
|
|
|
|
|
|
|
|
readonly WORK_DIR=$PWD
|
|
|
|
|
|
|
|
readonly DATE=$(date +%Y-%m-%d_%H:%M:%S)
|
|
|
|
readonly REPORT_DIR=${WORK_DIR}/report/${DATE}
|
|
|
|
mkdir -p ${REPORT_DIR}
|
|
|
|
|
|
|
|
readonly WAMR_DIR=${WORK_DIR}/../../..
|
|
|
|
|
|
|
|
if [[ ${SGX_OPT} == "--sgx" ]];then
|
|
|
|
readonly IWASM_LINUX_ROOT_DIR="${WAMR_DIR}/product-mini/platforms/linux-sgx"
|
|
|
|
readonly IWASM_CMD="${WAMR_DIR}/product-mini/platforms/linux-sgx/enclave-sample/iwasm"
|
|
|
|
else
|
2021-09-10 02:11:46 +00:00
|
|
|
readonly IWASM_LINUX_ROOT_DIR="${WAMR_DIR}/product-mini/platforms/${PLATFORM}"
|
|
|
|
readonly IWASM_CMD="${WAMR_DIR}/product-mini/platforms/${PLATFORM}/build/iwasm"
|
2021-09-09 04:49:46 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
readonly WAMRC_CMD="${WAMR_DIR}/wamr-compiler/build/wamrc"
|
|
|
|
|
|
|
|
readonly CLASSIC_INTERP_COMPILE_FLAGS="\
|
|
|
|
-DWAMR_BUILD_TARGET=${TARGET} \
|
|
|
|
-DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 \
|
|
|
|
-DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0 \
|
|
|
|
-DWAMR_BUILD_SPEC_TEST=1 \
|
|
|
|
-DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}"
|
|
|
|
|
|
|
|
readonly FAST_INTERP_COMPILE_FLAGS="\
|
|
|
|
-DWAMR_BUILD_TARGET=${TARGET} \
|
|
|
|
-DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1 \
|
|
|
|
-DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0 \
|
|
|
|
-DWAMR_BUILD_SPEC_TEST=1 \
|
|
|
|
-DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}"
|
|
|
|
|
|
|
|
# jit: report linking error if set COLLECT_CODE_COVERAGE,
|
|
|
|
# now we don't collect code coverage of jit type
|
2022-10-18 12:17:34 +00:00
|
|
|
readonly ORC_EAGER_JIT_COMPILE_FLAGS="\
|
2021-09-09 04:49:46 +00:00
|
|
|
-DWAMR_BUILD_TARGET=${TARGET} \
|
|
|
|
-DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_INTERP=0 \
|
|
|
|
-DWAMR_BUILD_JIT=1 -DWAMR_BUILD_AOT=1 \
|
2022-10-18 12:17:34 +00:00
|
|
|
-DWAMR_BUILD_LAZY_JIT=0 \
|
2023-02-28 09:38:18 +00:00
|
|
|
-DWAMR_BUILD_SPEC_TEST=1 \
|
|
|
|
-DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}"
|
2022-10-18 12:17:34 +00:00
|
|
|
|
|
|
|
readonly ORC_LAZY_JIT_COMPILE_FLAGS="\
|
|
|
|
-DWAMR_BUILD_TARGET=${TARGET} \
|
|
|
|
-DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_INTERP=0 \
|
|
|
|
-DWAMR_BUILD_JIT=1 -DWAMR_BUILD_AOT=1 \
|
|
|
|
-DWAMR_BUILD_LAZY_JIT=1 \
|
2023-02-28 09:38:18 +00:00
|
|
|
-DWAMR_BUILD_SPEC_TEST=1 \
|
|
|
|
-DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}"
|
2021-09-09 04:49:46 +00:00
|
|
|
|
|
|
|
readonly AOT_COMPILE_FLAGS="\
|
|
|
|
-DWAMR_BUILD_TARGET=${TARGET} \
|
|
|
|
-DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_INTERP=0 \
|
|
|
|
-DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=1 \
|
|
|
|
-DWAMR_BUILD_SPEC_TEST=1 \
|
|
|
|
-DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}"
|
|
|
|
|
2022-08-02 08:03:50 +00:00
|
|
|
readonly FAST_JIT_COMPILE_FLAGS="\
|
|
|
|
-DWAMR_BUILD_TARGET=${TARGET} \
|
|
|
|
-DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 \
|
|
|
|
-DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0 \
|
|
|
|
-DWAMR_BUILD_FAST_JIT=1 \
|
2023-02-28 09:38:18 +00:00
|
|
|
-DWAMR_BUILD_SPEC_TEST=1 \
|
|
|
|
-DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}"
|
2022-08-02 08:03:50 +00:00
|
|
|
|
2022-12-19 03:24:46 +00:00
|
|
|
readonly MULTI_TIER_JIT_COMPILE_FLAGS="\
|
|
|
|
-DWAMR_BUILD_TARGET=${TARGET} \
|
|
|
|
-DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 \
|
|
|
|
-DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
|
2023-02-28 09:38:18 +00:00
|
|
|
-DWAMR_BUILD_SPEC_TEST=1 \
|
|
|
|
-DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}"
|
2022-12-19 03:24:46 +00:00
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
readonly COMPILE_FLAGS=(
|
|
|
|
"${CLASSIC_INTERP_COMPILE_FLAGS}"
|
|
|
|
"${FAST_INTERP_COMPILE_FLAGS}"
|
2022-10-18 12:17:34 +00:00
|
|
|
"${ORC_EAGER_JIT_COMPILE_FLAGS}"
|
|
|
|
"${ORC_LAZY_JIT_COMPILE_FLAGS}"
|
2021-09-09 04:49:46 +00:00
|
|
|
"${AOT_COMPILE_FLAGS}"
|
2022-08-02 08:03:50 +00:00
|
|
|
"${FAST_JIT_COMPILE_FLAGS}"
|
2022-12-19 03:24:46 +00:00
|
|
|
"${MULTI_TIER_JIT_COMPILE_FLAGS}"
|
2021-09-09 04:49:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
function unit_test()
|
|
|
|
{
|
|
|
|
echo "Now start unit tests"
|
|
|
|
|
|
|
|
cd ${WORK_DIR}
|
2023-02-28 09:38:18 +00:00
|
|
|
rm -fr unittest-build && mkdir unittest-build
|
|
|
|
cd unittest-build
|
2021-09-09 04:49:46 +00:00
|
|
|
|
|
|
|
echo "Build unit test"
|
|
|
|
touch ${REPORT_DIR}/unit_test_report.txt
|
2023-02-28 09:38:18 +00:00
|
|
|
cmake ${WORK_DIR}/../../unit -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}
|
|
|
|
make -j
|
|
|
|
make test | tee -a ${REPORT_DIR}/unit_test_report.txt
|
2021-09-09 04:49:46 +00:00
|
|
|
|
|
|
|
echo "Finish unit tests"
|
|
|
|
}
|
|
|
|
|
|
|
|
function sightglass_test()
|
|
|
|
{
|
|
|
|
echo "Now start sightglass benchmark tests"
|
|
|
|
|
|
|
|
cd ${WORK_DIR}/../sightglass/benchmarks
|
|
|
|
|
|
|
|
# build iwasm first
|
|
|
|
if [[ $1 == "classic-interp" || $1 == "fast-interp" ]];then
|
|
|
|
./test_interp.sh ${SGX_OPT}
|
|
|
|
cp report.txt ${REPORT_DIR}/sightglass_$1_test_report.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $1 == "aot" ]];then
|
|
|
|
./test_aot.sh ${SGX_OPT}
|
|
|
|
cp report.txt ${REPORT_DIR}/sightglass_aot_test_report.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $1 == "jit" ]];then
|
|
|
|
[[ $TEST_ALL_AOT_RUNTIME ]] && ./test_aot.sh ${TEST_ALL_AOT_RUNTIME} ${SGX_OPT} \
|
|
|
|
|| ./test_aot.sh jit ${SGX_OPT}
|
|
|
|
cp report.txt ${REPORT_DIR}/sightglass_jit_test_report.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Finish sightglass benchmark tests"
|
|
|
|
}
|
|
|
|
|
2023-10-07 11:55:14 +00:00
|
|
|
function setup_wabt()
|
|
|
|
{
|
|
|
|
if [ ${WABT_BINARY_RELEASE} == "YES" ]; then
|
|
|
|
echo "download a binary release and install"
|
|
|
|
local WAT2WASM=${WORK_DIR}/wabt/out/gcc/Release/wat2wasm
|
|
|
|
if [ ! -f ${WAT2WASM} ]; then
|
|
|
|
case ${PLATFORM} in
|
|
|
|
cosmopolitan)
|
2023-11-24 08:21:05 +00:00
|
|
|
;;
|
2023-10-07 11:55:14 +00:00
|
|
|
linux)
|
|
|
|
WABT_PLATFORM=ubuntu
|
|
|
|
;;
|
|
|
|
darwin)
|
2023-11-24 08:21:05 +00:00
|
|
|
WABT_PLATFORM=macos-12
|
2023-10-07 11:55:14 +00:00
|
|
|
;;
|
2023-10-08 07:03:35 +00:00
|
|
|
windows)
|
|
|
|
WABT_PLATFORM=windows
|
|
|
|
;;
|
2023-10-07 11:55:14 +00:00
|
|
|
*)
|
|
|
|
echo "wabt platform for ${PLATFORM} in unknown"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if [ ! -f /tmp/wabt-1.0.31-${WABT_PLATFORM}.tar.gz ]; then
|
2023-10-08 07:03:35 +00:00
|
|
|
curl -L \
|
2023-10-07 11:55:14 +00:00
|
|
|
https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-${WABT_PLATFORM}.tar.gz \
|
2023-10-08 07:03:35 +00:00
|
|
|
-o /tmp/wabt-1.0.31-${WABT_PLATFORM}.tar.gz
|
2023-10-07 11:55:14 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd /tmp \
|
|
|
|
&& tar zxf wabt-1.0.31-${WABT_PLATFORM}.tar.gz \
|
|
|
|
&& mkdir -p ${WORK_DIR}/wabt/out/gcc/Release/ \
|
|
|
|
&& install wabt-1.0.31/bin/wa* ${WORK_DIR}/wabt/out/gcc/Release/ \
|
|
|
|
&& cd -
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "download source code and compile and install"
|
|
|
|
if [ ! -d "wabt" ];then
|
|
|
|
echo "wabt not exist, clone it from github"
|
|
|
|
git clone --recursive https://github.com/WebAssembly/wabt
|
|
|
|
fi
|
|
|
|
echo "upate wabt"
|
|
|
|
cd wabt
|
|
|
|
git pull
|
|
|
|
git reset --hard origin/main
|
|
|
|
cd ..
|
|
|
|
make -C wabt gcc-release -j 4
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
# TODO: with iwasm only
|
|
|
|
function spec_test()
|
|
|
|
{
|
|
|
|
echo "Now start spec tests"
|
|
|
|
touch ${REPORT_DIR}/spec_test_report.txt
|
|
|
|
|
|
|
|
cd ${WORK_DIR}
|
|
|
|
if [ ! -d "spec" ];then
|
|
|
|
echo "spec not exist, clone it from github"
|
|
|
|
git clone -b master --single-branch https://github.com/WebAssembly/spec
|
|
|
|
fi
|
|
|
|
|
|
|
|
pushd spec
|
|
|
|
|
|
|
|
# restore and clean everything
|
|
|
|
git reset --hard HEAD
|
|
|
|
|
|
|
|
# update basic test cases
|
|
|
|
echo "update spec test cases"
|
2022-06-28 08:05:16 +00:00
|
|
|
git fetch origin main
|
2021-09-09 04:49:46 +00:00
|
|
|
# restore from XX_ignore_cases.patch
|
|
|
|
# resotre branch
|
2022-06-28 08:05:16 +00:00
|
|
|
git checkout -B main
|
|
|
|
# [spec] Update note on module initialization trapping (#1493)
|
|
|
|
git reset --hard 044d0d2e77bdcbe891f7e0b9dd2ac01d56435f0b
|
2021-09-09 04:49:46 +00:00
|
|
|
git apply ../../spec-test-script/ignore_cases.patch
|
2021-12-15 06:39:54 +00:00
|
|
|
if [[ ${ENABLE_SIMD} == 1 ]]; then
|
|
|
|
git apply ../../spec-test-script/simd_ignore_cases.patch
|
|
|
|
fi
|
2023-09-28 00:56:11 +00:00
|
|
|
if [[ ${ENABLE_MULTI_MODULE} == 1 && $1 == 'aot' ]]; then
|
2023-10-24 01:19:45 +00:00
|
|
|
git apply ../../spec-test-script/multi_module_aot_ignore_cases.patch
|
2023-09-28 00:56:11 +00:00
|
|
|
fi
|
2021-09-09 04:49:46 +00:00
|
|
|
|
|
|
|
# udpate thread cases
|
|
|
|
if [ ${ENABLE_MULTI_THREAD} == 1 ]; then
|
|
|
|
echo "checkout spec for threads proposal"
|
|
|
|
if [[ -z $(git remote -v | grep "\<threads\>") ]]; then
|
|
|
|
git remote add threads https://github.com/WebAssembly/threads
|
|
|
|
fi
|
|
|
|
|
|
|
|
# fetch spec for threads proposal
|
|
|
|
git fetch threads
|
2022-06-28 08:05:16 +00:00
|
|
|
# Fix error in Web embedding desc for atomic.notify (#185)
|
|
|
|
git reset --hard 85b562cd6805947876ec5e8b975ab0127c55a0a2
|
2021-10-08 09:47:11 +00:00
|
|
|
git checkout threads/main
|
2021-09-09 04:49:46 +00:00
|
|
|
|
|
|
|
git apply ../../spec-test-script/thread_proposal_ignore_cases.patch
|
2022-10-13 05:53:09 +00:00
|
|
|
git apply ../../spec-test-script/thread_proposal_fix_atomic_case.patch
|
2021-09-09 04:49:46 +00:00
|
|
|
fi
|
|
|
|
|
2023-02-28 09:38:18 +00:00
|
|
|
# update GC cases
|
|
|
|
if [[ ${ENABLE_GC} == 1 ]]; then
|
|
|
|
echo "checkout spec for GC proposal"
|
|
|
|
|
|
|
|
popd
|
|
|
|
rm -fr spec
|
|
|
|
# check spec test cases for GC
|
|
|
|
git clone -b main --single-branch https://github.com/WebAssembly/gc.git spec
|
|
|
|
pushd spec
|
|
|
|
|
|
|
|
git restore . && git clean -ffd .
|
|
|
|
# Sync constant expression descriptions
|
|
|
|
git reset --hard 62beb94ddd41987517781732f17f213d8b866dcc
|
|
|
|
git apply ../../spec-test-script/gc_ignore_cases.patch
|
|
|
|
|
|
|
|
echo "compile the reference intepreter"
|
|
|
|
pushd interpreter
|
|
|
|
make opt
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
popd
|
|
|
|
echo $(pwd)
|
|
|
|
|
2023-10-07 11:55:14 +00:00
|
|
|
setup_wabt
|
2021-09-09 04:49:46 +00:00
|
|
|
|
2021-11-08 04:39:02 +00:00
|
|
|
ln -sf ${WORK_DIR}/../spec-test-script/all.py .
|
2021-09-09 04:49:46 +00:00
|
|
|
ln -sf ${WORK_DIR}/../spec-test-script/runtest.py .
|
|
|
|
|
|
|
|
local ARGS_FOR_SPEC_TEST=""
|
|
|
|
|
|
|
|
# multi-module only enable in interp mode
|
|
|
|
if [[ 1 == ${ENABLE_MULTI_MODULE} ]]; then
|
2023-09-28 00:56:11 +00:00
|
|
|
if [[ $1 == 'classic-interp' || $1 == 'fast-interp' || $1 == 'aot' ]]; then
|
2021-09-09 04:49:46 +00:00
|
|
|
ARGS_FOR_SPEC_TEST+="-M "
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# sgx only enable in interp mode and aot mode
|
|
|
|
if [[ ${SGX_OPT} == "--sgx" ]];then
|
2023-05-24 09:41:45 +00:00
|
|
|
if [[ $1 == 'classic-interp' || $1 == 'fast-interp' || $1 == 'aot' || $1 == 'fast-jit' ]]; then
|
2021-09-09 04:49:46 +00:00
|
|
|
ARGS_FOR_SPEC_TEST+="-x "
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# simd only enable in jit mode and aot mode
|
|
|
|
if [[ ${ENABLE_SIMD} == 1 ]]; then
|
|
|
|
if [[ $1 == 'jit' || $1 == 'aot' ]]; then
|
|
|
|
ARGS_FOR_SPEC_TEST+="-S "
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-11-18 09:42:49 +00:00
|
|
|
if [[ ${ENABLE_MULTI_THREAD} == 1 ]]; then
|
2021-12-06 09:25:10 +00:00
|
|
|
ARGS_FOR_SPEC_TEST+="-p "
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${ENABLE_XIP} == 1 ]]; then
|
|
|
|
ARGS_FOR_SPEC_TEST+="-X "
|
2021-09-09 04:49:46 +00:00
|
|
|
fi
|
|
|
|
|
2022-11-28 02:45:32 +00:00
|
|
|
# set the current running target
|
2023-02-02 01:42:25 +00:00
|
|
|
ARGS_FOR_SPEC_TEST+="-m ${TARGET} "
|
2022-11-28 02:45:32 +00:00
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
# require warmc only in aot mode
|
|
|
|
if [[ $1 == 'aot' ]]; then
|
2022-11-28 02:45:32 +00:00
|
|
|
ARGS_FOR_SPEC_TEST+="-t "
|
2021-09-09 04:49:46 +00:00
|
|
|
fi
|
|
|
|
|
2021-11-08 04:39:02 +00:00
|
|
|
if [[ ${PARALLELISM} == 1 ]]; then
|
|
|
|
ARGS_FOR_SPEC_TEST+="--parl "
|
|
|
|
fi
|
|
|
|
|
2023-02-28 09:38:18 +00:00
|
|
|
if [[ ${ENABLE_GC} == 1 ]]; then
|
|
|
|
ARGS_FOR_SPEC_TEST+="--gc "
|
|
|
|
fi
|
|
|
|
|
2022-11-28 02:45:32 +00:00
|
|
|
if [[ ${ENABLE_QEMU} == 1 ]]; then
|
|
|
|
ARGS_FOR_SPEC_TEST+="--qemu "
|
2023-02-06 03:04:28 +00:00
|
|
|
ARGS_FOR_SPEC_TEST+="--qemu-firmware ${QEMU_FIRMWARE} "
|
2022-11-28 02:45:32 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-09 01:40:59 +00:00
|
|
|
if [[ ${PLATFORM} == "windows" ]]; then
|
|
|
|
ARGS_FOR_SPEC_TEST+="--no-pty "
|
|
|
|
fi
|
|
|
|
|
2023-02-06 03:04:28 +00:00
|
|
|
# set log directory
|
|
|
|
ARGS_FOR_SPEC_TEST+="--log ${REPORT_DIR}"
|
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
cd ${WORK_DIR}
|
2023-08-09 01:40:59 +00:00
|
|
|
echo "${PYTHON_EXE} ./all.py ${ARGS_FOR_SPEC_TEST} | tee -a ${REPORT_DIR}/spec_test_report.txt"
|
|
|
|
${PYTHON_EXE} ./all.py ${ARGS_FOR_SPEC_TEST} | tee -a ${REPORT_DIR}/spec_test_report.txt
|
2023-01-05 09:16:44 +00:00
|
|
|
if [[ ${PIPESTATUS[0]} -ne 0 ]];then
|
|
|
|
echo -e "\nspec tests FAILED" | tee -a ${REPORT_DIR}/spec_test_report.txt
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-09-09 04:49:46 +00:00
|
|
|
cd -
|
|
|
|
|
|
|
|
echo -e "\nFinish spec tests" | tee -a ${REPORT_DIR}/spec_test_report.txt
|
|
|
|
}
|
|
|
|
|
|
|
|
function wasi_test()
|
|
|
|
{
|
|
|
|
echo "Now start wasi tests"
|
|
|
|
touch ${REPORT_DIR}/wasi_test_report.txt
|
|
|
|
|
|
|
|
cd ${WORK_DIR}/../../wasi
|
|
|
|
[[ $1 != "aot" ]] && \
|
|
|
|
python wasi_test.py --interpreter ${IWASM_CMD} ${SGX_OPT}\
|
|
|
|
| tee ${REPORT_DIR}/wasi_test_report.txt \
|
|
|
|
|| \
|
|
|
|
python wasi_test.py --aot --aot-compiler ${WAMRC_CMD} ${SGX_OPT}\
|
|
|
|
--interpreter ${IWASM_CMD} \
|
|
|
|
| tee ${REPORT_DIR}/wasi_test_report.txt
|
|
|
|
echo "Finish wasi tests"
|
|
|
|
}
|
|
|
|
|
2023-10-07 11:55:14 +00:00
|
|
|
function wamr_compiler_test()
|
|
|
|
{
|
|
|
|
if [[ $1 != "aot" ]]; then
|
|
|
|
echo "WAMR compiler tests only support AOT mode"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Now start WAMR compiler tests"
|
|
|
|
setup_wabt
|
|
|
|
cd ${WORK_DIR}/../wamr-compiler-test-script
|
|
|
|
./run_wamr_compiler_tests.sh ${WORK_DIR}/wabt/out/gcc/Release/wat2wasm $WAMRC_CMD $IWASM_CMD \
|
|
|
|
| tee -a ${REPORT_DIR}/wamr_compiler_test_report.txt
|
|
|
|
|
|
|
|
ret=${PIPESTATUS[0]}
|
|
|
|
|
|
|
|
if [[ ${ret} -ne 0 ]];then
|
|
|
|
echo -e "\nWAMR compiler tests FAILED" | tee -a ${REPORT_DIR}/wamr_compiler_test_report.txt
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo -e "\nFinish WAMR compiler tests" | tee -a ${REPORT_DIR}/wamr_compiler_test_report.txt
|
|
|
|
}
|
|
|
|
|
2023-01-05 09:16:44 +00:00
|
|
|
function wasi_certification_test()
|
|
|
|
{
|
2023-02-28 09:38:18 +00:00
|
|
|
echo "Now start wasi certification tests"
|
2023-01-05 09:16:44 +00:00
|
|
|
|
|
|
|
cd ${WORK_DIR}
|
|
|
|
if [ ! -d "wasi-testsuite" ]; then
|
2023-09-21 10:39:12 +00:00
|
|
|
echo "wasi-testsuite not exist, clone it from github"
|
2023-02-27 12:28:37 +00:00
|
|
|
git clone -b prod/testsuite-all \
|
2023-01-05 09:16:44 +00:00
|
|
|
--single-branch https://github.com/WebAssembly/wasi-testsuite.git
|
|
|
|
fi
|
|
|
|
cd wasi-testsuite
|
|
|
|
git reset --hard ${WASI_TESTSUITE_COMMIT}
|
|
|
|
|
2023-11-09 02:13:59 +00:00
|
|
|
TSAN_OPTIONS=${TSAN_OPTIONS} bash ../../wasi-test-script/run_wasi_tests.sh $1 $TARGET $WASI_TEST_FILTER \
|
2023-02-27 12:28:37 +00:00
|
|
|
| tee -a ${REPORT_DIR}/wasi_test_report.txt
|
|
|
|
ret=${PIPESTATUS[0]}
|
|
|
|
|
|
|
|
if [[ ${ret} -ne 0 ]];then
|
2023-01-05 09:16:44 +00:00
|
|
|
echo -e "\nwasi tests FAILED" | tee -a ${REPORT_DIR}/wasi_test_report.txt
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo -e "\nFinish wasi tests" | tee -a ${REPORT_DIR}/wasi_test_report.txt
|
|
|
|
}
|
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
function polybench_test()
|
|
|
|
{
|
|
|
|
echo "Now start polybench tests"
|
|
|
|
|
|
|
|
cd ${WORK_DIR}/../polybench
|
|
|
|
if [[ $1 == "aot" || $1 == "jit" ]];then
|
|
|
|
./build.sh AOT ${SGX_OPT}
|
|
|
|
./test_aot.sh $1 ${SGX_OPT}
|
|
|
|
else
|
|
|
|
./build.sh
|
|
|
|
./test_interp.sh ${SGX_OPT}
|
|
|
|
fi
|
|
|
|
cp report.txt ${REPORT_DIR}/polybench_$1_test_report.txt
|
|
|
|
|
|
|
|
echo "Finish polybench tests"
|
|
|
|
}
|
|
|
|
|
2023-02-28 09:38:18 +00:00
|
|
|
function libsodium_test()
|
|
|
|
{
|
|
|
|
echo "Now start libsodium tests"
|
|
|
|
|
|
|
|
cd ${WORK_DIR}/../libsodium
|
|
|
|
if [[ $1 == "aot" || $1 == "jit" ]];then
|
|
|
|
./build.sh ${SGX_OPT}
|
|
|
|
./test_aot.sh $1 ${SGX_OPT}
|
|
|
|
else
|
|
|
|
./test_interp.sh ${SGX_OPT}
|
|
|
|
fi
|
|
|
|
cp report.txt ${REPORT_DIR}/libsodium_$1_test_report.txt
|
|
|
|
|
|
|
|
echo "Finish libsodium tests"
|
|
|
|
}
|
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
function malformed_test()
|
|
|
|
{
|
|
|
|
# build iwasm firstly
|
|
|
|
cd ${WORK_DIR}/../../malformed
|
|
|
|
./malformed_test.py --run ${IWASM_CMD} | tee ${REPORT_DIR}/malfomed_$1_test_report.txt
|
|
|
|
}
|
|
|
|
|
2023-03-07 00:45:03 +00:00
|
|
|
function collect_standalone()
|
|
|
|
{
|
|
|
|
if [[ ${COLLECT_CODE_COVERAGE} == 1 ]]; then
|
|
|
|
pushd ${WORK_DIR} > /dev/null 2>&1
|
|
|
|
|
|
|
|
CODE_COV_FILE=""
|
|
|
|
if [[ -z "${CODE_COV_FILE}" ]]; then
|
|
|
|
CODE_COV_FILE="${WORK_DIR}/wamr.lcov"
|
|
|
|
else
|
|
|
|
CODE_COV_FILE="${CODE_COV_FILE}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
STANDALONE_DIR=${WORK_DIR}/../../standalone
|
|
|
|
|
|
|
|
echo "Collect code coverage of standalone dump-call-stack"
|
|
|
|
./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/dump-call-stack/build"
|
|
|
|
echo "Collect code coverage of standalone dump-mem-profiling"
|
|
|
|
./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/dump-mem-profiling/build"
|
|
|
|
echo "Collect code coverage of standalone dump-perf-profiling"
|
|
|
|
./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/dump-perf-profiling/build"
|
|
|
|
if [[ $1 == "aot" ]]; then
|
|
|
|
echo "Collect code coverage of standalone pad-test"
|
|
|
|
./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/pad-test/build"
|
|
|
|
fi
|
|
|
|
echo "Collect code coverage of standalone test-invoke-native"
|
|
|
|
./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/test-invoke-native/build"
|
|
|
|
echo "Collect code coverage of standalone test-running-modes"
|
|
|
|
./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/test-running-modes/build"
|
|
|
|
echo "Collect code coverage of standalone test-running-modes/c-embed"
|
|
|
|
./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/test-running-modes/c-embed/build"
|
|
|
|
echo "Collect code coverage of standalone test-ts2"
|
|
|
|
./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/test-ts2/build"
|
|
|
|
|
|
|
|
popd > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
function standalone_test()
|
|
|
|
{
|
2023-03-07 00:45:03 +00:00
|
|
|
if [[ ${COLLECT_CODE_COVERAGE} == 1 ]]; then
|
|
|
|
export COLLECT_CODE_COVERAGE=1
|
|
|
|
fi
|
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
cd ${WORK_DIR}/../../standalone
|
|
|
|
|
2023-02-28 09:38:18 +00:00
|
|
|
args="--$1"
|
2021-09-09 04:49:46 +00:00
|
|
|
|
|
|
|
[[ ${SGX_OPT} == "--sgx" ]] && args="$args --sgx" || args="$args --no-sgx"
|
|
|
|
|
2023-03-07 00:45:03 +00:00
|
|
|
[[ ${ENABLE_MULTI_THREAD} == 1 ]] && args="$args --thread" || args="$args --no-thread"
|
2023-02-28 09:38:18 +00:00
|
|
|
|
2023-03-07 00:45:03 +00:00
|
|
|
[[ ${ENABLE_SIMD} == 1 ]] && args="$args --simd" || args="$args --no-simd"
|
|
|
|
|
|
|
|
args="$args ${TARGET}"
|
2021-09-09 04:49:46 +00:00
|
|
|
|
|
|
|
./standalone.sh $args | tee ${REPORT_DIR}/standalone_$1_test_report.txt
|
2023-03-07 00:45:03 +00:00
|
|
|
|
|
|
|
collect_standalone "$1"
|
2021-09-09 04:49:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function build_iwasm_with_cfg()
|
|
|
|
{
|
2023-05-26 01:45:37 +00:00
|
|
|
echo "Build iwasm with compile flags " $* " for spec test" \
|
2021-09-09 04:49:46 +00:00
|
|
|
| tee -a ${REPORT_DIR}/spec_test_report.txt
|
|
|
|
|
|
|
|
if [[ ${SGX_OPT} == "--sgx" ]];then
|
|
|
|
cd ${WAMR_DIR}/product-mini/platforms/linux-sgx \
|
|
|
|
&& if [ -d build ]; then rm -rf build/*; else mkdir build; fi \
|
|
|
|
&& cd build \
|
|
|
|
&& cmake $* .. \
|
2021-10-30 13:03:46 +00:00
|
|
|
&& make -j 4
|
2021-09-09 04:49:46 +00:00
|
|
|
cd ${WAMR_DIR}/product-mini/platforms/linux-sgx/enclave-sample \
|
|
|
|
&& make clean \
|
|
|
|
&& make SPEC_TEST=1
|
|
|
|
else
|
2021-09-10 02:11:46 +00:00
|
|
|
cd ${WAMR_DIR}/product-mini/platforms/${PLATFORM} \
|
2021-09-09 04:49:46 +00:00
|
|
|
&& if [ -d build ]; then rm -rf build/*; else mkdir build; fi \
|
|
|
|
&& cd build \
|
|
|
|
&& cmake $* .. \
|
2023-12-01 10:12:55 +00:00
|
|
|
&& cmake --build . -j 4 --config RelWithDebInfo --target iwasm
|
2021-09-09 04:49:46 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$?" != 0 ];then
|
2022-09-29 06:02:58 +00:00
|
|
|
echo -e "build iwasm failed"
|
2021-09-09 04:49:46 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2023-10-04 13:55:37 +00:00
|
|
|
|
|
|
|
if [[ ${PLATFORM} == "cosmopolitan" ]]; then
|
|
|
|
# convert from APE to ELF so it can be ran easier
|
|
|
|
# HACK: link to linux so tests work when platform is detected by uname
|
|
|
|
cp iwasm.com iwasm \
|
|
|
|
&& ./iwasm --assimilate \
|
|
|
|
&& rm -rf ../../linux/build \
|
|
|
|
&& mkdir ../../linux/build \
|
|
|
|
&& ln -s ../../cosmopolitan/build/iwasm ../../linux/build/iwasm
|
|
|
|
if [ "$?" != 0 ];then
|
|
|
|
echo -e "build iwasm failed (cosmopolitan)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2021-09-09 04:49:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function build_wamrc()
|
|
|
|
{
|
2023-11-27 07:24:02 +00:00
|
|
|
if [[ "${TARGET_LIST[*]}" =~ "${TARGET}" ]]; then
|
2021-09-09 04:49:46 +00:00
|
|
|
echo "suppose wamrc is already built"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Build wamrc for spec test under aot compile type"
|
|
|
|
cd ${WAMR_DIR}/wamr-compiler \
|
|
|
|
&& ./build_llvm.sh \
|
|
|
|
&& if [ -d build ]; then rm -r build/*; else mkdir build; fi \
|
|
|
|
&& cd build \
|
2023-02-28 09:38:18 +00:00
|
|
|
&& cmake .. -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE} \
|
2021-10-30 13:03:46 +00:00
|
|
|
&& make -j 4
|
2021-09-09 04:49:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
### Need to add a test suite?
|
|
|
|
### The function name should be ${suite_name}_test
|
|
|
|
# function xxx_test()
|
|
|
|
# {
|
|
|
|
#
|
|
|
|
# }
|
|
|
|
|
|
|
|
function collect_coverage()
|
|
|
|
{
|
2023-02-28 09:38:18 +00:00
|
|
|
if [[ ${COLLECT_CODE_COVERAGE} == 1 ]]; then
|
|
|
|
ln -sf ${WORK_DIR}/../spec-test-script/collect_coverage.sh ${WORK_DIR}
|
|
|
|
|
|
|
|
CODE_COV_FILE=""
|
2023-03-07 00:45:03 +00:00
|
|
|
if [[ -z "${CODE_COV_FILE}" ]]; then
|
2023-02-28 09:38:18 +00:00
|
|
|
CODE_COV_FILE="${WORK_DIR}/wamr.lcov"
|
|
|
|
else
|
2023-03-07 00:45:03 +00:00
|
|
|
CODE_COV_FILE="${CODE_COV_FILE}"
|
2023-02-28 09:38:18 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
pushd ${WORK_DIR} > /dev/null 2>&1
|
|
|
|
echo "Collect code coverage of iwasm"
|
|
|
|
./collect_coverage.sh ${CODE_COV_FILE} ${IWASM_LINUX_ROOT_DIR}/build
|
|
|
|
if [[ $1 == "llvm-aot" ]]; then
|
|
|
|
echo "Collect code coverage of wamrc"
|
|
|
|
./collect_coverage.sh ${CODE_COV_FILE} ${WAMR_DIR}/wamr-compiler/build
|
|
|
|
fi
|
|
|
|
for suite in "${TEST_CASE_ARR[@]}"; do
|
|
|
|
if [[ ${suite} = "unit" ]]; then
|
|
|
|
echo "Collect code coverage of unit test"
|
|
|
|
./collect_coverage.sh ${CODE_COV_FILE} ${WORK_DIR}/unittest-build
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
popd > /dev/null 2>&1
|
2021-09-09 04:49:46 +00:00
|
|
|
else
|
2023-02-28 09:38:18 +00:00
|
|
|
echo "code coverage isn't collected"
|
2021-09-09 04:49:46 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function trigger()
|
|
|
|
{
|
|
|
|
local EXTRA_COMPILE_FLAGS=""
|
2021-11-18 09:42:49 +00:00
|
|
|
# default enabled features
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_BULK_MEMORY=1"
|
|
|
|
|
|
|
|
if [[ ${ENABLE_MULTI_MODULE} == 1 ]];then
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_MULTI_MODULE=1"
|
|
|
|
else
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_MULTI_MODULE=0"
|
|
|
|
fi
|
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
if [[ ${ENABLE_MULTI_THREAD} == 1 ]];then
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_LIB_PTHREAD=1"
|
2021-11-18 09:42:49 +00:00
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_REF_TYPES=0"
|
|
|
|
else
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_REF_TYPES=1"
|
2021-09-09 04:49:46 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${ENABLE_SIMD} == 1 ]]; then
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SIMD=1"
|
2021-11-18 09:42:49 +00:00
|
|
|
else
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SIMD=0"
|
2021-09-09 04:49:46 +00:00
|
|
|
fi
|
|
|
|
|
2023-02-28 09:38:18 +00:00
|
|
|
if [[ ${ENABLE_GC} == 1 ]]; then
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_GC=1"
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_REF_TYPES=1"
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_BULK_MEMORY=1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${ENABLE_DEBUG_VERSION} == 1 ]]; then
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DCMAKE_BUILD_TYPE=Debug"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${ENABLE_GC_HEAP_VERIFY} == 1 ]]; then
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_GC_HEAP_VERIFY=1"
|
|
|
|
fi
|
|
|
|
|
2023-02-27 12:28:37 +00:00
|
|
|
if [[ ${ENABLE_WASI_THREADS} == 1 ]]; then
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_LIB_WASI_THREADS=1"
|
|
|
|
fi
|
|
|
|
|
2023-05-26 01:45:37 +00:00
|
|
|
echo "SANITIZER IS" $WAMR_BUILD_SANITIZER
|
|
|
|
|
|
|
|
if [[ "$WAMR_BUILD_SANITIZER" == "ubsan" ]]; then
|
|
|
|
echo "Setting run with ubsan"
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SANITIZER=ubsan"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$WAMR_BUILD_SANITIZER" == "asan" ]]; then
|
|
|
|
echo "Setting run with asan"
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SANITIZER=asan"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$WAMR_BUILD_SANITIZER" == "tsan" ]]; then
|
|
|
|
echo "Setting run with tsan"
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SANITIZER=tsan"
|
|
|
|
fi
|
|
|
|
|
2023-11-06 11:24:06 +00:00
|
|
|
# Make sure we're using the builtin WASI libc implementation
|
|
|
|
# if we're running the wasi certification tests.
|
|
|
|
if [[ $TEST_CASE_ARR ]]; then
|
|
|
|
for test in "${TEST_CASE_ARR[@]}"; do
|
|
|
|
if [[ "$test" == "wasi_certification" ]]; then
|
|
|
|
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_LIBC_UVWASI=0 -DWAMR_BUILD_LIBC_WASI=1"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
for t in "${TYPE[@]}"; do
|
|
|
|
case $t in
|
|
|
|
"classic-interp")
|
|
|
|
if [[ ${ENABLE_SIMD} == 1 ]]; then
|
|
|
|
echo "does not support SIMD in interp mode, bypass"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "work in classic-interp mode"
|
|
|
|
# classic-interp
|
|
|
|
BUILD_FLAGS="$CLASSIC_INTERP_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
|
2022-11-28 02:45:32 +00:00
|
|
|
if [[ ${ENABLE_QEMU} == 0 ]]; then
|
|
|
|
build_iwasm_with_cfg $BUILD_FLAGS
|
|
|
|
fi
|
2021-09-09 04:49:46 +00:00
|
|
|
for suite in "${TEST_CASE_ARR[@]}"; do
|
|
|
|
$suite"_test" classic-interp
|
|
|
|
done
|
|
|
|
collect_coverage classic-interp
|
|
|
|
;;
|
|
|
|
|
|
|
|
"fast-interp")
|
|
|
|
if [[ ${ENABLE_SIMD} == 1 ]]; then
|
|
|
|
echo "does not support SIMD in interp mode, bypass"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "work in fast-interp mode"
|
|
|
|
# fast-interp
|
|
|
|
BUILD_FLAGS="$FAST_INTERP_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
|
2022-11-28 02:45:32 +00:00
|
|
|
if [[ ${ENABLE_QEMU} == 0 ]]; then
|
|
|
|
build_iwasm_with_cfg $BUILD_FLAGS
|
|
|
|
fi
|
2021-09-09 04:49:46 +00:00
|
|
|
for suite in "${TEST_CASE_ARR[@]}"; do
|
|
|
|
$suite"_test" fast-interp
|
|
|
|
done
|
|
|
|
collect_coverage fast-interp
|
|
|
|
;;
|
|
|
|
|
|
|
|
"jit")
|
2021-10-15 09:05:07 +00:00
|
|
|
if [[ ${TARGET} == "X86_32" ]]; then
|
|
|
|
echo "does not support an X86_32 target in JIT mode, bypass"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2022-10-18 12:17:34 +00:00
|
|
|
echo "work in orc jit eager compilation mode"
|
|
|
|
BUILD_FLAGS="$ORC_EAGER_JIT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
|
|
|
|
build_iwasm_with_cfg $BUILD_FLAGS
|
|
|
|
for suite in "${TEST_CASE_ARR[@]}"; do
|
|
|
|
$suite"_test" jit
|
|
|
|
done
|
2023-02-28 09:38:18 +00:00
|
|
|
collect_coverage llvm-jit
|
2022-10-18 12:17:34 +00:00
|
|
|
|
|
|
|
echo "work in orc jit lazy compilation mode"
|
2023-08-04 01:41:25 +00:00
|
|
|
BUILD_FLAGS="$ORC_LAZY_JIT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
|
2021-09-09 04:49:46 +00:00
|
|
|
build_iwasm_with_cfg $BUILD_FLAGS
|
|
|
|
for suite in "${TEST_CASE_ARR[@]}"; do
|
|
|
|
$suite"_test" jit
|
|
|
|
done
|
2023-02-28 09:38:18 +00:00
|
|
|
collect_coverage llvm-jit
|
2021-09-09 04:49:46 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
"aot")
|
|
|
|
echo "work in aot mode"
|
|
|
|
# aot
|
|
|
|
BUILD_FLAGS="$AOT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
|
2022-11-28 02:45:32 +00:00
|
|
|
if [[ ${ENABLE_QEMU} == 0 ]]; then
|
|
|
|
build_iwasm_with_cfg $BUILD_FLAGS
|
|
|
|
fi
|
2021-09-09 04:49:46 +00:00
|
|
|
build_wamrc
|
|
|
|
for suite in "${TEST_CASE_ARR[@]}"; do
|
|
|
|
$suite"_test" aot
|
|
|
|
done
|
2023-02-28 09:38:18 +00:00
|
|
|
collect_coverage llvm-aot
|
2021-09-09 04:49:46 +00:00
|
|
|
;;
|
|
|
|
|
2022-08-02 08:03:50 +00:00
|
|
|
"fast-jit")
|
|
|
|
echo "work in fast-jit mode"
|
2022-12-19 03:24:46 +00:00
|
|
|
# fast-jit
|
2022-08-02 08:03:50 +00:00
|
|
|
BUILD_FLAGS="$FAST_JIT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
|
|
|
|
build_iwasm_with_cfg $BUILD_FLAGS
|
|
|
|
for suite in "${TEST_CASE_ARR[@]}"; do
|
|
|
|
$suite"_test" fast-jit
|
|
|
|
done
|
2023-02-28 09:38:18 +00:00
|
|
|
collect_coverage fast-jit
|
2022-08-02 08:03:50 +00:00
|
|
|
;;
|
|
|
|
|
2022-12-19 03:24:46 +00:00
|
|
|
"multi-tier-jit")
|
|
|
|
echo "work in multi-tier-jit mode"
|
|
|
|
# multi-tier-jit
|
|
|
|
BUILD_FLAGS="$MULTI_TIER_JIT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
|
|
|
|
build_iwasm_with_cfg $BUILD_FLAGS
|
|
|
|
for suite in "${TEST_CASE_ARR[@]}"; do
|
|
|
|
$suite"_test" multi-tier-jit
|
|
|
|
done
|
2023-02-28 09:38:18 +00:00
|
|
|
collect_coverage multi-tier-jit
|
2022-12-19 03:24:46 +00:00
|
|
|
;;
|
|
|
|
|
2021-09-09 04:49:46 +00:00
|
|
|
*)
|
|
|
|
echo "unexpected mode, do nothing"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# if collect code coverage, ignore -s, test all test cases.
|
2023-02-28 09:38:18 +00:00
|
|
|
if [[ $TEST_CASE_ARR ]];then
|
2021-10-11 12:32:29 +00:00
|
|
|
trigger || (echo "TEST FAILED"; exit 1)
|
2021-09-09 04:49:46 +00:00
|
|
|
else
|
2023-02-28 09:38:18 +00:00
|
|
|
# test all suite, ignore polybench and libsodium because of long time cost
|
|
|
|
TEST_CASE_ARR=("spec")
|
|
|
|
: '
|
|
|
|
if [[ $COLLECT_CODE_COVERAGE == 1 ]];then
|
|
|
|
# add polybench if collecting code coverage data
|
|
|
|
TEST_CASE_ARR+=("polybench")
|
|
|
|
# add libsodium if needed, which takes long time to run
|
|
|
|
TEST_CASE_ARR+=("libsodium")
|
|
|
|
fi
|
|
|
|
'
|
2021-10-11 12:32:29 +00:00
|
|
|
trigger || (echo "TEST FAILED"; exit 1)
|
2021-09-09 04:49:46 +00:00
|
|
|
# Add more suites here
|
|
|
|
fi
|
|
|
|
|
2022-09-29 06:02:58 +00:00
|
|
|
echo -e "Test finish. Reports are under ${REPORT_DIR}"
|
2022-08-02 08:03:50 +00:00
|
|
|
DEBUG set +xv pipefail
|
2021-10-11 12:32:29 +00:00
|
|
|
echo "TEST SUCCESSFUL"
|
|
|
|
exit 0
|