Skip to content

Commit c5b7b9d

Browse files
authored
feat: Integrate wasi test suite to wamr-test-suites and CI (#1832)
Add [wasi-testsuite](https://github.com/WebAssembly/wasi-testsuite) to set of tests executed from `test_wamr.sh`. Additional description here: #1761
1 parent bf2be80 commit c5b7b9d

2 files changed

Lines changed: 45 additions & 4 deletions

File tree

.github/workflows/compilation_on_android_ubuntu.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ env:
6161
SIMD_TEST_OPTIONS: "-s spec -b -S -P"
6262
THREADS_TEST_OPTIONS: "-s spec -b -p -P"
6363
X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P"
64+
WASI_TEST_OPTIONS: "-s wasi_certification"
6465

6566
jobs:
6667
build_llvm_libraries:
@@ -376,7 +377,7 @@ jobs:
376377
exit $?
377378
working-directory: ./samples/simple
378379

379-
spec_test:
380+
test:
380381
needs: [build_iwasm, build_llvm_libraries, build_wamrc]
381382
runs-on: ubuntu-20.04
382383
strategy:
@@ -389,6 +390,7 @@ jobs:
389390
$MULTI_MODULES_TEST_OPTIONS,
390391
$SIMD_TEST_OPTIONS,
391392
$THREADS_TEST_OPTIONS,
393+
$WASI_TEST_OPTIONS,
392394
]
393395
exclude:
394396
# uncompatiable modes and features
@@ -400,6 +402,9 @@ jobs:
400402
# aot and jit don't support multi module
401403
- running_mode: "aot"
402404
test_option: $MULTI_MODULES_TEST_OPTIONS
405+
# aot is WAMR-specific while wasi-testsuite is generic
406+
- running_mode: "aot"
407+
test_option: $WASI_TEST_OPTIONS
403408
- running_mode: "jit"
404409
test_option: $MULTI_MODULES_TEST_OPTIONS
405410
# fast-jit is only tested on default mode, exclude other three
@@ -441,7 +446,7 @@ jobs:
441446
if: env.USE_LLVM == 'true' && steps.cache_llvm.outputs.cache-hit != 'true'
442447
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
443448

444-
- name: run spec tests default and extra
449+
- name: run tests
445450
run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
446451
working-directory: ./tests/wamr-test-suites
447452

@@ -456,7 +461,7 @@ jobs:
456461
sudo apt-get update &&
457462
sudo apt install -y g++-multilib lib32gcc-9-dev
458463

459-
- name: run spec tests x86_32
464+
- name: run tests x86_32
460465
if: env.TEST_ON_X86_32 == 'true'
461466
run: ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
462467
working-directory: ./tests/wamr-test-suites

tests/wamr-test-suites/test_wamr.sh

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ PLATFORM=$(uname -s | tr A-Z a-z)
4646
PARALLELISM=0
4747
ENABLE_QEMU=0
4848
QEMU_FIRMWARE=""
49+
WASI_TESTSUITE_COMMIT="1d913f28b3f0d92086d6f50405cf85768e648b54"
4950

5051
while getopts ":s:cabt:m:MCpSXxPQF:" opt
5152
do
@@ -447,7 +448,10 @@ function spec_test()
447448
cd ${WORK_DIR}
448449
echo "python3 ./all.py ${ARGS_FOR_SPEC_TEST} | tee -a ${REPORT_DIR}/spec_test_report.txt"
449450
python3 ./all.py ${ARGS_FOR_SPEC_TEST} | tee -a ${REPORT_DIR}/spec_test_report.txt
450-
[[ ${PIPESTATUS[0]} -ne 0 ]] && exit 1
451+
if [[ ${PIPESTATUS[0]} -ne 0 ]];then
452+
echo -e "\nspec tests FAILED" | tee -a ${REPORT_DIR}/spec_test_report.txt
453+
exit 1
454+
fi
451455
cd -
452456

453457
echo -e "\nFinish spec tests" | tee -a ${REPORT_DIR}/spec_test_report.txt
@@ -469,6 +473,38 @@ function wasi_test()
469473
echo "Finish wasi tests"
470474
}
471475

476+
function wasi_certification_test()
477+
{
478+
echo "Now start wasi tests"
479+
480+
cd ${WORK_DIR}
481+
if [ ! -d "wasi-testsuite" ]; then
482+
echo "wasi not exist, clone it from github"
483+
git clone -b prod/testsuite-base \
484+
--single-branch https://github.com/WebAssembly/wasi-testsuite.git
485+
fi
486+
cd wasi-testsuite
487+
git reset --hard ${WASI_TESTSUITE_COMMIT}
488+
489+
python3 -m venv wasi-env && source wasi-env/bin/activate
490+
python3 -m pip install -r test-runner/requirements.txt
491+
IWASM_PATH=$(dirname ${IWASM_CMD})
492+
PATH=${PATH}:${IWASM_PATH} python3 test-runner/wasi_test_runner.py \
493+
-r adapters/wasm-micro-runtime.sh \
494+
-t \
495+
tests/c/testsuite/ \
496+
tests/assemblyscript/testsuite/ \
497+
| tee -a ${REPORT_DIR}/wasi_test_report.txt
498+
exit_code=${PIPESTATUS[0]}
499+
deactivate
500+
501+
if [[ ${exit_code} -ne 0 ]];then
502+
echo -e "\nwasi tests FAILED" | tee -a ${REPORT_DIR}/wasi_test_report.txt
503+
exit 1
504+
fi
505+
echo -e "\nFinish wasi tests" | tee -a ${REPORT_DIR}/wasi_test_report.txt
506+
}
507+
472508
function polybench_test()
473509
{
474510
echo "Now start polybench tests"

0 commit comments

Comments
 (0)