Add another wamr test (#2411)

Follows up #2364 where we discussed that we might want to have a test
which has really short thread function and creates many threads.
This commit is contained in:
Maks Litskevich
2023-08-17 03:31:05 +01:00
committed by GitHub
parent c820643b2b
commit 4ce675aacd
7 changed files with 127 additions and 22 deletions

View File

@ -14,6 +14,7 @@ readonly WAMR_DIR="${WORK_DIR}/../../../.."
readonly IWASM_CMD="${WORK_DIR}/../../../../product-mini/platforms/${PLATFORM}/build/iwasm \
--allow-resolve=google-public-dns-a.google.com \
--addr-pool=::1/128,127.0.0.1/32"
readonly IWASM_CMD_STRESS="${IWASM_CMD} --max-threads=8"
readonly WAMRC_CMD="${WORK_DIR}/../../../../wamr-compiler/build/wamrc"
readonly C_TESTS="tests/c/testsuite/"
@ -21,18 +22,22 @@ readonly ASSEMBLYSCRIPT_TESTS="tests/assemblyscript/testsuite/"
readonly THREAD_PROPOSAL_TESTS="tests/proposals/wasi-threads/"
readonly THREAD_INTERNAL_TESTS="${WAMR_DIR}/core/iwasm/libraries/lib-wasi-threads/test/"
readonly LIB_SOCKET_TESTS="${WAMR_DIR}/core/iwasm/libraries/lib-socket/test/"
readonly STRESS_TESTS=("spawn_stress_test.wasm" "stress_test_threads_creation.wasm")
run_aot_tests () {
local tests=("$@")
local iwasm="${IWASM_CMD}"
for test_wasm in ${tests[@]}; do
local extra_stress_flags=""
if [[ "$test_wasm" =~ "stress" ]]; then
extra_stress_flags="--max-threads=8"
fi
for stress_test in "${STRESS_TESTS[@]}"; do
if [ "$test_wasm" == "$stress_test" ]; then
iwasm="${IWASM_CMD_STRESS}"
fi
done
test_aot="${test_wasm%.wasm}.aot"
test_json="${test_wasm%.wasm}.json"
if [ -f ${test_wasm} ]; then
expected=$(jq .exit_code ${test_json})
fi
@ -48,7 +53,6 @@ run_aot_tests () {
fi
${IWASM_CMD} $extra_stress_flags $test_aot
ret=${PIPESTATUS[0]}
echo "expected=$expected, actual=$ret"
@ -62,15 +66,18 @@ if [[ $MODE != "aot" ]];then
python3 -m venv wasi-env && source wasi-env/bin/activate
python3 -m pip install -r test-runner/requirements.txt
# Stress test requires max-threads=8 so it's run separately
if [[ -e "${THREAD_INTERNAL_TESTS}spawn_stress_test.wasm" ]]; then
${IWASM_CMD_STRESS} ${THREAD_INTERNAL_TESTS}spawn_stress_test.wasm
ret=${PIPESTATUS[0]}
if [ "${ret}" -ne 0 ]; then
echo "Stress test spawn_stress_test FAILED with code " ${ret}
exit_code=${ret}
# Stress tests require max-threads=8 so they're executed separately
for stress_test in "${STRESS_TESTS[@]}"; do
if [[ -e "${THREAD_INTERNAL_TESTS}${stress_test}" ]]; then
echo "${stress_test}" is a stress test
${IWASM_CMD_STRESS} ${THREAD_INTERNAL_TESTS}${stress_test}
ret=${PIPESTATUS[0]}
if [ "${ret}" -ne 0 ]; then
echo "Stress test ${stress_test} FAILED with code " ${ret}
exit_code=${ret}
fi
fi
fi
done
TEST_RUNTIME_EXE="${IWASM_CMD}" python3 test-runner/wasi_test_runner.py \
-r adapters/wasm-micro-runtime.py \