run_wasi_tests.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. #
  3. # Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  5. #
  6. readonly MODE=$1
  7. readonly TARGET=$2
  8. readonly WORK_DIR=$PWD
  9. readonly PLATFORM=$(uname -s | tr A-Z a-z)
  10. readonly WAMR_DIR="${WORK_DIR}/../../../.."
  11. readonly IWASM_CMD="${WORK_DIR}/../../../../product-mini/platforms/${PLATFORM}/build/iwasm"
  12. readonly WAMRC_CMD="${WORK_DIR}/../../../../wamr-compiler/build/wamrc"
  13. if [[ $MODE != "aot" ]];then
  14. python3 -m venv wasi-env && source wasi-env/bin/activate
  15. python3 -m pip install -r test-runner/requirements.txt
  16. TEST_RUNTIME_EXE="${IWASM_CMD}" python3 test-runner/wasi_test_runner.py \
  17. -r adapters/wasm-micro-runtime.py \
  18. -t \
  19. tests/c/testsuite/ \
  20. tests/assemblyscript/testsuite/ \
  21. tests/proposals/wasi-threads/ \
  22. ${WAMR_DIR}/core/iwasm/libraries/lib-wasi-threads/test/ \
  23. ${WAMR_DIR}/core/iwasm/libraries/lib-socket/test/ \
  24. exit_code=${PIPESTATUS[0]}
  25. deactivate
  26. else
  27. target_option=""
  28. if [[ $TARGET == "X86_32" ]];then
  29. target_option="--target=i386"
  30. fi
  31. # Run WASI thread proposal tests
  32. exit_code=0
  33. wasm_tests=$(ls tests/proposals/wasi-threads/*.wasm)
  34. for test_wasm in ${wasm_tests}; do
  35. test_aot="${test_wasm%.wasm}.aot"
  36. test_json="${test_wasm%.wasm}.json"
  37. echo "Compiling $test_wasm to $test_aot"
  38. ${WAMRC_CMD} --enable-multi-thread ${target_option} \
  39. -o $test_aot $test_wasm
  40. echo "Running $test_aot"
  41. expected=$(jq .exit_code ${test_json})
  42. ${IWASM_CMD} $test_aot
  43. ret=${PIPESTATUS[0]}
  44. echo "expected=$expected, actual=$ret"
  45. if [[ $expected != "" ]] && [[ $expected != $ret ]];then
  46. exit_code=1
  47. fi
  48. done
  49. fi
  50. exit ${exit_code}