all.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #!/bin/bash
  2. #
  3. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  4. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  5. #
  6. # exit if meet an exception
  7. function DEBUG() {
  8. [[ -n $(env | grep "\<DEBUG\>") ]] && $@
  9. }
  10. DEBUG set -xevu
  11. # Run the following command to test a single wast file:
  12. # ./spec-test-script/runtest.py --wast2wasm ./workspace/wabt/out/gcc/Release/wat2wasm \
  13. # --interpreter iwasm <wast file>
  14. readonly SPEC_TEST_DIR="spec/test/core"
  15. readonly WAST2WASM_CMD="./wabt/out/gcc/Release/wat2wasm"
  16. readonly WAMRC_CMD="../../../wamr-compiler/build/wamrc"
  17. PLATFORM=$(uname -s | tr A-Z a-z)
  18. IWASM_CMD="../../../product-mini/platforms/${PLATFORM}/build/iwasm"
  19. # "imports" and "linking" are only avilable when enabling multi modules
  20. # "comments" is for runtest.py
  21. IGNORE_LIST=(
  22. "comments" "inline-module" "imports" "linking" "names"
  23. )
  24. readonly -a MULTI_MODULE_LIST=(
  25. "imports" "linking"
  26. )
  27. SGX_IGNORE_LIST=("conversions" "f32_bitwise" "f64_bitwise")
  28. # these cases run failed due to native stack overflow check failed
  29. SGX_AOT_IGNORE_LIST=("call_indirect" "call" "fac" "skip-stack-guard-page")
  30. function usage() {
  31. echo "Usage: all.sh [-t] [-m <x86_64|x86_32|ARMV7_VFP|THUMBV7_VFP>] [-M] [-x] [-S] [-r]"
  32. exit 1
  33. }
  34. function run_case_w_aot() {
  35. local test_case=$1
  36. echo "============> run ${test_case} with AOT"
  37. python2.7 runtest.py \
  38. --wast2wasm ${WAST2WASM_CMD} \
  39. --interpreter ${IWASM_CMD} \
  40. ${SPEC_TEST_DIR}/${test_case} \
  41. --aot-compiler ${WAMRC_CMD} \
  42. --aot --aot-target ${TARGET} \
  43. ${SGX_OPT} \
  44. ${SIMD_OPT} \
  45. ${REF_TYPES_OPT}
  46. #--no_cleanup
  47. if [[ $? != 0 ]]; then
  48. echo "============> run ${test_case} failed"
  49. exit 1
  50. fi
  51. }
  52. function run_case_wo_aot() {
  53. local test_case=$1
  54. echo "============> run ${test_case}"
  55. python2.7 runtest.py \
  56. --wast2wasm ${WAST2WASM_CMD} \
  57. --interpreter ${IWASM_CMD} \
  58. ${SPEC_TEST_DIR}/${test_case} \
  59. --aot-compiler ${WAMRC_CMD} \
  60. ${SGX_OPT} \
  61. ${SIMD_OPT} \
  62. ${REF_TYPES_OPT}
  63. #--no_cleanup
  64. if [[ $? != 0 ]]; then
  65. echo "============> run ${test_case} failed"
  66. exit 1
  67. fi
  68. }
  69. ENABLE_MULTI_MODULE=0
  70. TARGET="X86_64"
  71. SGX_OPT=""
  72. AOT=false
  73. SIMD_OPT=""
  74. REF_TYPES_OPT=""
  75. while getopts ":Mm:txSr" opt; do
  76. case $opt in
  77. t) AOT=true ;;
  78. m)
  79. TARGET=$OPTARG
  80. if [[ ${TARGET} == 'X86_32' ]]; then
  81. TARGET='i386'
  82. elif [[ ${TARGET} == 'X86_64' ]]; then
  83. TARGET='x86_64'
  84. elif [[ ${TARGET} == 'ARMV7_VFP' ]]; then
  85. TARGET='armv7'
  86. elif [[ ${TARGET} == 'THUMBV7_VFP' ]]; then
  87. TARGET='thumbv7'
  88. elif [[ ${TARGET} == 'RISCV64' || ${TARGET} == 'RISCV64_LP64D' ]]; then
  89. TARGET='riscv64_lp64d'
  90. elif [[ ${TARGET} == 'RISCV64_LP64' ]]; then
  91. TARGET='riscv64_lp64'
  92. else
  93. usage
  94. fi ;;
  95. M) ENABLE_MULTI_MODULE=1 ;;
  96. x) SGX_OPT="--sgx" ;;
  97. S) SIMD_OPT="--simd" ;;
  98. r) REF_TYPES_OPT="--ref_types" ;;
  99. *) usage ;;
  100. esac
  101. done
  102. function contain() {
  103. # [$1, $-1)
  104. local list=${@:0:${#}}
  105. # [$-1]
  106. local item=${@:${#}}
  107. [[ ${list} =~ (^| )${item}($| ) ]] && return 0 || return 1
  108. }
  109. if [[ ${SGX_OPT} ]]; then
  110. IWASM_CMD="../../../product-mini/platforms/linux-sgx/enclave-sample/iwasm"
  111. IGNORE_LIST+=("${SGX_IGNORE_LIST[@]}")
  112. if [[ "true" == ${AOT} ]]; then
  113. IGNORE_LIST+=("${SGX_AOT_IGNORE_LIST[@]}")
  114. fi
  115. fi
  116. if [[ ${TARGET} == "i386" ]]; then
  117. IGNORE_LIST+=("float_exprs")
  118. fi
  119. declare -i COUNTER=0
  120. for wast in $(find ${SPEC_TEST_DIR} -name "*.wast" -type f | sort -n); do
  121. # remove a prefix spec/test/core/
  122. wast=${wast#${SPEC_TEST_DIR}/}
  123. # ${wast%.wast} will remove a surfix .wast
  124. if contain "${IGNORE_LIST[@]}" ${wast%.wast}; then
  125. echo "============> ignore ${wast}"
  126. continue
  127. else
  128. [[ "true" == ${AOT} ]] && run_case_w_aot ${wast} ||
  129. run_case_wo_aot ${wast}
  130. ((COUNTER += 1))
  131. fi
  132. done
  133. # for now, Multi_Module is always disabled while AOT is true
  134. if [[ "false" == ${AOT} && 1 == ${ENABLE_MULTI_MODULE} ]]; then
  135. echo "============> run cases about multi module"
  136. for wast in ${MULTI_MODULE_LIST[@]}; do
  137. run_case_wo_aot ${wast}.wast
  138. ((COUNTER += 1))
  139. done
  140. fi
  141. echo "PASS ALL ${COUNTER} SPEC CASES"
  142. DEBUG set -xevu
  143. exit 0