Add mutex stress test (#2472)
As a part of stress-testing we want to ensure that mutex implementation is working correctly and protecting shared resource to be allocated from other threads when mutex is locked. This test covers the most common situations that happen when some program uses mutexes like locks from various threads, locks from the same thread etc.
This commit is contained in:
@ -15,25 +15,22 @@ readonly IWASM_CMD="${WORK_DIR}/../../../../product-mini/platforms/${PLATFORM}/b
|
||||
--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 IWASM_CMD_STRESS="${IWASM_CMD} --max-threads=12"
|
||||
readonly WAMRC_CMD="${WORK_DIR}/../../../../wamr-compiler/build/wamrc"
|
||||
readonly C_TESTS="tests/c/testsuite/"
|
||||
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 THREAD_STRESS_TESTS="${WAMR_DIR}/core/iwasm/libraries/lib-wasi-threads/stress-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=""
|
||||
for stress_test in "${STRESS_TESTS[@]}"; do
|
||||
if [ "$test_wasm" == "$stress_test" ]; then
|
||||
iwasm="${IWASM_CMD_STRESS}"
|
||||
fi
|
||||
done
|
||||
local iwasm="${IWASM_CMD}"
|
||||
if [[ $test_wasm =~ "stress" ]]; then
|
||||
iwasm="${IWASM_CMD_STRESS}"
|
||||
fi
|
||||
|
||||
test_aot="${test_wasm%.wasm}.aot"
|
||||
test_json="${test_wasm%.wasm}.json"
|
||||
@ -52,7 +49,7 @@ run_aot_tests () {
|
||||
expected=$(jq .exit_code ${test_json})
|
||||
fi
|
||||
|
||||
${IWASM_CMD} $extra_stress_flags $test_aot
|
||||
${iwasm} $test_aot
|
||||
ret=${PIPESTATUS[0]}
|
||||
|
||||
echo "expected=$expected, actual=$ret"
|
||||
@ -66,19 +63,6 @@ if [[ $MODE != "aot" ]];then
|
||||
python3 -m venv wasi-env && source wasi-env/bin/activate
|
||||
python3 -m pip install -r test-runner/requirements.txt
|
||||
|
||||
# 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
|
||||
done
|
||||
|
||||
TEST_RUNTIME_EXE="${IWASM_CMD}" python3 test-runner/wasi_test_runner.py \
|
||||
-r adapters/wasm-micro-runtime.py \
|
||||
-t \
|
||||
@ -87,12 +71,20 @@ if [[ $MODE != "aot" ]];then
|
||||
${THREAD_PROPOSAL_TESTS} \
|
||||
${THREAD_INTERNAL_TESTS} \
|
||||
${LIB_SOCKET_TESTS} \
|
||||
--exclude-filter "${THREAD_INTERNAL_TESTS}skip.json"
|
||||
|
||||
ret=${PIPESTATUS[0]}
|
||||
if [ "${ret}" -ne 0 ]; then
|
||||
exit_code=${ret}
|
||||
|
||||
TEST_RUNTIME_EXE="${IWASM_CMD_STRESS}" python3 test-runner/wasi_test_runner.py \
|
||||
-r adapters/wasm-micro-runtime.py \
|
||||
-t \
|
||||
${THREAD_STRESS_TESTS}
|
||||
|
||||
if [ "${ret}" -eq 0 ]; then
|
||||
ret=${PIPESTATUS[0]}
|
||||
fi
|
||||
|
||||
exit_code=${ret}
|
||||
|
||||
deactivate
|
||||
else
|
||||
target_option=""
|
||||
@ -101,7 +93,7 @@ else
|
||||
fi
|
||||
|
||||
exit_code=0
|
||||
for testsuite in ${THREAD_PROPOSAL_TESTS} ${THREAD_INTERNAL_TESTS}; do
|
||||
for testsuite in ${THREAD_STRESS_TESTS} ${THREAD_PROPOSAL_TESTS} ${THREAD_INTERNAL_TESTS}; do
|
||||
tests=$(ls ${testsuite}*.wasm)
|
||||
tests_array=($tests)
|
||||
run_aot_tests "${tests_array[@]}"
|
||||
|
||||
Reference in New Issue
Block a user