Skip to content

Commit 23e9a35

Browse files
authored
Enable to run wasi-thread tests with AOT (#2026)
1 parent 915b4d2 commit 23e9a35

File tree

1 file changed

+45
-24
lines changed

1 file changed

+45
-24
lines changed

tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,54 @@ readonly PLATFORM=$(uname -s | tr A-Z a-z)
1313
readonly WAMR_DIR="${WORK_DIR}/../../../.."
1414
readonly IWASM_CMD="${WORK_DIR}/../../../../product-mini/platforms/${PLATFORM}/build/iwasm"
1515
readonly WAMRC_CMD="${WORK_DIR}/../../../../wamr-compiler/build/wamrc"
16+
readonly C_TESTS="tests/c/testsuite/"
17+
readonly ASSEMBLYSCRIPT_TESTS="tests/assemblyscript/testsuite/"
18+
readonly THREAD_PROPOSAL_TESTS="tests/proposals/wasi-threads/"
19+
readonly THREAD_INTERNAL_TESTS="${WAMR_DIR}/core/iwasm/libraries/lib-wasi-threads/test/"
20+
readonly LIB_SOCKET_TESTS="${WAMR_DIR}/core/iwasm/libraries/lib-socket/test/"
21+
22+
run_aot_tests () {
23+
local tests=("$@")
24+
for test_wasm in ${tests[@]}; do
25+
test_aot="${test_wasm%.wasm}.aot"
26+
test_json="${test_wasm%.wasm}.json"
27+
28+
if [ -f ${test_wasm} ]; then
29+
expected=$(jq .exit_code ${test_json})
30+
fi
31+
32+
echo "Compiling $test_wasm to $test_aot"
33+
${WAMRC_CMD} --enable-multi-thread ${target_option} \
34+
-o ${test_aot} ${test_wasm}
35+
36+
echo "Running $test_aot"
37+
expected=0
38+
if [ -f ${test_json} ]; then
39+
expected=$(jq .exit_code ${test_json})
40+
fi
41+
42+
${IWASM_CMD} $test_aot
43+
44+
ret=${PIPESTATUS[0]}
45+
46+
echo "expected=$expected, actual=$ret"
47+
if [[ $expected != "" ]] && [[ $expected != $ret ]];then
48+
exit_code=1
49+
fi
50+
done
51+
}
1652

1753
if [[ $MODE != "aot" ]];then
1854
python3 -m venv wasi-env && source wasi-env/bin/activate
1955
python3 -m pip install -r test-runner/requirements.txt
2056
TEST_RUNTIME_EXE="${IWASM_CMD}" python3 test-runner/wasi_test_runner.py \
2157
-r adapters/wasm-micro-runtime.py \
2258
-t \
23-
tests/c/testsuite/ \
24-
tests/assemblyscript/testsuite/ \
25-
tests/proposals/wasi-threads/ \
26-
${WAMR_DIR}/core/iwasm/libraries/lib-wasi-threads/test/ \
27-
${WAMR_DIR}/core/iwasm/libraries/lib-socket/test/ \
59+
${C_TESTS} \
60+
${ASSEMBLYSCRIPT_TESTS} \
61+
${THREAD_PROPOSAL_TESTS} \
62+
${THREAD_INTERNAL_TESTS} \
63+
${LIB_SOCKET_TESTS} \
2864
exit_code=${PIPESTATUS[0]}
2965
deactivate
3066
else
@@ -33,26 +69,11 @@ else
3369
target_option="--target=i386"
3470
fi
3571

36-
# Run WASI thread proposal tests
3772
exit_code=0
38-
wasm_tests=$(ls tests/proposals/wasi-threads/*.wasm)
39-
for test_wasm in ${wasm_tests}; do
40-
test_aot="${test_wasm%.wasm}.aot"
41-
test_json="${test_wasm%.wasm}.json"
42-
43-
echo "Compiling $test_wasm to $test_aot"
44-
${WAMRC_CMD} --enable-multi-thread ${target_option} \
45-
-o $test_aot $test_wasm
46-
47-
echo "Running $test_aot"
48-
expected=$(jq .exit_code ${test_json})
49-
${IWASM_CMD} $test_aot
50-
ret=${PIPESTATUS[0]}
51-
52-
echo "expected=$expected, actual=$ret"
53-
if [[ $expected != "" ]] && [[ $expected != $ret ]];then
54-
exit_code=1
55-
fi
73+
for testsuite in ${THREAD_PROPOSAL_TESTS} ${THREAD_INTERNAL_TESTS}; do
74+
tests=$(ls ${testsuite}*.wasm)
75+
tests_array=($tests)
76+
run_aot_tests "${tests_array[@]}"
5677
done
5778
fi
5879

0 commit comments

Comments
 (0)