Update WASI thread proposal tests in CI (#1985)

Update CI to run extended WASI threads tests included in the proposal
https://github.com/WebAssembly/wasi-testsuite/tree/prod/testsuite-all/tests/proposals/wasi-threads
This commit is contained in:
Enrico Loparco 2023-02-27 13:28:37 +01:00 committed by GitHub
parent 52e26e59cf
commit 4ca57a0228
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 19 deletions

View File

@ -60,7 +60,7 @@ env:
SIMD_TEST_OPTIONS: "-s spec -b -S -P"
THREADS_TEST_OPTIONS: "-s spec -b -p -P"
X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P"
WASI_TEST_OPTIONS: "-s wasi_certification"
WASI_TEST_OPTIONS: "-s wasi_certification -w"
jobs:
build_llvm_libraries_on_ubuntu_2004:
@ -469,9 +469,6 @@ jobs:
# aot and jit don't support multi module
- running_mode: "aot"
test_option: $MULTI_MODULES_TEST_OPTIONS
# aot is WAMR-specific while wasi-testsuite is generic
- running_mode: "aot"
test_option: $WASI_TEST_OPTIONS
- running_mode: "jit"
test_option: $MULTI_MODULES_TEST_OPTIONS
# fast-jit doesn't support multi module, simd, and threads
@ -481,6 +478,8 @@ jobs:
test_option: $SIMD_TEST_OPTIONS
- running_mode: "fast-jit"
test_option: $THREADS_TEST_OPTIONS
- running_mode: "fast-jit"
test_option: $WASI_TEST_OPTIONS
# multi-tier-jit doesn't support multi module, simd, and threads
- running_mode: "multi-tier-jit"
test_option: $MULTI_MODULES_TEST_OPTIONS
@ -488,6 +487,8 @@ jobs:
test_option: $SIMD_TEST_OPTIONS
- running_mode: "multi-tier-jit"
test_option: $THREADS_TEST_OPTIONS
- running_mode: "multi-tier-jit"
test_option: $WASI_TEST_OPTIONS
steps:
- name: checkout
uses: actions/checkout@v3
@ -521,6 +522,10 @@ jobs:
if: env.USE_LLVM == 'true' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: install jq JSON processor
if: matrix.running_mode == 'aot' && matrix.test_option == '$WASI_TEST_OPTIONS'
run: sudo apt-get update && sudo apt install -y jq
- name: run tests
run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
working-directory: ./tests/wamr-test-suites

View File

@ -26,6 +26,7 @@ function help()
echo "-P run the spec test parallelly"
echo "-Q enable qemu"
echo "-F set the firmware path used by qemu"
echo "-w enable WASI threads"
}
OPT_PARSED=""
@ -34,6 +35,7 @@ WABT_BINARY_RELEASE="NO"
TYPE=("classic-interp" "fast-interp" "jit" "aot" "fast-jit" "multi-tier-jit")
#default target
TARGET="X86_64"
ENABLE_WASI_THREADS=0
ENABLE_MULTI_MODULE=0
ENABLE_MULTI_THREAD=0
COLLECT_CODE_COVERAGE=0
@ -46,9 +48,9 @@ PLATFORM=$(uname -s | tr A-Z a-z)
PARALLELISM=0
ENABLE_QEMU=0
QEMU_FIRMWARE=""
WASI_TESTSUITE_COMMIT="1d913f28b3f0d92086d6f50405cf85768e648b54"
WASI_TESTSUITE_COMMIT="b18247e2161bea263fe924b8189c67b1d2d10a10"
while getopts ":s:cabt:m:MCpSXxPQF:" opt
while getopts ":s:cabt:m:wMCpSXxPQF:" opt
do
OPT_PARSED="TRUE"
case $opt in
@ -98,6 +100,10 @@ do
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
;;
w)
echo "enable WASI threads"
ENABLE_WASI_THREADS=1
;;
M)
echo "enable multi module feature"
ENABLE_MULTI_MODULE=1
@ -483,25 +489,17 @@ function wasi_certification_test()
cd ${WORK_DIR}
if [ ! -d "wasi-testsuite" ]; then
echo "wasi not exist, clone it from github"
git clone -b prod/testsuite-base \
git clone -b prod/testsuite-all \
--single-branch https://github.com/WebAssembly/wasi-testsuite.git
fi
cd wasi-testsuite
git reset --hard ${WASI_TESTSUITE_COMMIT}
python3 -m venv wasi-env && source wasi-env/bin/activate
python3 -m pip install -r test-runner/requirements.txt
IWASM_PATH=$(dirname ${IWASM_CMD})
PATH=${PATH}:${IWASM_PATH} python3 test-runner/wasi_test_runner.py \
-r adapters/wasm-micro-runtime.sh \
-t \
tests/c/testsuite/ \
tests/assemblyscript/testsuite/ \
| tee -a ${REPORT_DIR}/wasi_test_report.txt
exit_code=${PIPESTATUS[0]}
deactivate
bash ../../wasi-test-script/run_wasi_tests.sh $1 $TARGET \
| tee -a ${REPORT_DIR}/wasi_test_report.txt
ret=${PIPESTATUS[0]}
if [[ ${exit_code} -ne 0 ]];then
if [[ ${ret} -ne 0 ]];then
echo -e "\nwasi tests FAILED" | tee -a ${REPORT_DIR}/wasi_test_report.txt
exit 1
fi
@ -641,6 +639,12 @@ function trigger()
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SIMD=0"
fi
if [[ ${ENABLE_WASI_THREADS} == 1 ]]; then
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_LIB_WASI_THREADS=1"
else
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_LIB_WASI_THREADS=0"
fi
for t in "${TYPE[@]}"; do
case $t in
"classic-interp")

View File

@ -0,0 +1,56 @@
#!/bin/bash
#
# Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
readonly MODE=$1
readonly TARGET=$2
readonly WORK_DIR=$PWD
readonly PLATFORM=$(uname -s | tr A-Z a-z)
readonly IWASM_CMD="${WORK_DIR}/../../../../product-mini/platforms/${PLATFORM}/build/iwasm"
readonly WAMRC_CMD="${WORK_DIR}/../../../../wamr-compiler/build/wamrc"
if [[ $MODE != "aot" ]];then
python3 -m venv wasi-env && source wasi-env/bin/activate
python3 -m pip install -r test-runner/requirements.txt
TEST_RUNTIME_EXE="${IWASM_CMD}" python3 test-runner/wasi_test_runner.py \
-r adapters/wasm-micro-runtime.py \
-t \
tests/c/testsuite/ \
tests/assemblyscript/testsuite/ \
tests/proposals/wasi-threads/
exit_code=${PIPESTATUS[0]}
deactivate
else
target_option=""
if [[ $TARGET == "X86_32" ]];then
target_option="--target=i386"
fi
# Run WASI thread proposal tests
exit_code=0
wasm_tests=$(ls tests/proposals/wasi-threads/*.wasm)
for test_wasm in ${wasm_tests}; do
test_aot="${test_wasm%.wasm}.aot"
test_json="${test_wasm%.wasm}.json"
echo "Compiling $test_wasm to $test_aot"
${WAMRC_CMD} --enable-multi-thread ${target_option} \
-o $test_aot $test_wasm
echo "Running $test_aot"
expected=$(jq .exit_code ${test_json})
${IWASM_CMD} $test_aot
ret=${PIPESTATUS[0]}
echo "expected=$expected, actual=$ret"
if [[ $expected != "" ]] && [[ $expected != $ret ]];then
exit_code=1
fi
done
fi
exit ${exit_code}