run.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. if [[ $2 == "--sgx" ]]; then
  7. readonly IWASM_CMD="../../../product-mini/platforms/linux-sgx/enclave-sample/iwasm"
  8. else
  9. readonly IWASM_CMD="../../../product-mini/platforms/linux/build/iwasm"
  10. fi
  11. readonly WAMRC_CMD="../../../wamr-compiler/build/wamrc"
  12. if [[ $1 != "--aot" ]]; then
  13. echo "============> run create_join.wasm"
  14. ${IWASM_CMD} --heap-size=16384 create_join.wasm
  15. echo "============> run main_thread_return.wasm"
  16. ${IWASM_CMD} --heap-size=16384 main_thread_return.wasm
  17. echo "============> run thread_cancel.wasm"
  18. ${IWASM_CMD} --heap-size=16384 thread_cancel.wasm
  19. echo "============> run thread_exit.wasm"
  20. ${IWASM_CMD} --heap-size=16384 thread_exit.wasm
  21. echo "============> run wasi.wasm"
  22. ${IWASM_CMD} --heap-size=16384 wasi.wasm
  23. echo "============> run pthread_mutex.wasm"
  24. ${IWASM_CMD} --heap-size=16384 pthread_mutex.wasm
  25. echo "============> run pthread_cond.wasm"
  26. ${IWASM_CMD} --heap-size=16384 pthread_cond.wasm
  27. echo "============> run pthread_key.wasm"
  28. ${IWASM_CMD} --heap-size=16384 pthread_key.wasm
  29. else
  30. echo "============> compile create_join.wasm to aot"
  31. if [[ $2 == "--sgx" ]]; then
  32. ${WAMRC_CMD} -sgx --enable-multi-thread -o create_join.aot create_join.wasm
  33. else
  34. ${WAMRC_CMD} --enable-multi-thread -o create_join.aot create_join.wasm
  35. fi
  36. echo "============> run create_join.aot"
  37. ${IWASM_CMD} --heap-size=16384 create_join.aot
  38. echo "============> compile main_thread_return.wasm to aot"
  39. if [[ $2 == "--sgx" ]]; then
  40. ${WAMRC_CMD} -sgx --enable-multi-thread -o main_thread_return.aot main_thread_return.wasm
  41. else
  42. ${WAMRC_CMD} --enable-multi-thread -o main_thread_return.aot main_thread_return.wasm
  43. fi
  44. echo "============> run main_thread_return.aot"
  45. ${IWASM_CMD} --heap-size=16384 main_thread_return.aot
  46. echo "============> compile thread_cancel.wasm to aot"
  47. if [[ $2 == "--sgx" ]]; then
  48. ${WAMRC_CMD} -sgx --enable-multi-thread -o thread_cancel.aot thread_cancel.wasm
  49. else
  50. ${WAMRC_CMD} --enable-multi-thread -o thread_cancel.aot thread_cancel.wasm
  51. fi
  52. echo "============> run thread_cancel.aot"
  53. ${IWASM_CMD} --heap-size=16384 thread_cancel.aot
  54. echo "============> compile thread_exit.wasm to aot"
  55. if [[ $2 == "--sgx" ]]; then
  56. ${WAMRC_CMD} -sgx --enable-multi-thread -o thread_exit.aot thread_exit.wasm
  57. else
  58. ${WAMRC_CMD} --enable-multi-thread -o thread_exit.aot thread_exit.wasm
  59. fi
  60. echo "============> run thread_exit.aot"
  61. ${IWASM_CMD} --heap-size=16384 thread_exit.aot
  62. echo "============> compile wasi.wasm to aot"
  63. if [[ $2 == "--sgx" ]]; then
  64. ${WAMRC_CMD} -sgx --enable-multi-thread -o wasi.aot wasi.wasm
  65. else
  66. ${WAMRC_CMD} --enable-multi-thread -o wasi.aot wasi.wasm
  67. fi
  68. echo "============> run wasi.aot"
  69. ${IWASM_CMD} --heap-size=16384 wasi.aot
  70. echo "============> compile pthread_mutex.wasm to aot"
  71. if [[ $2 == "--sgx" ]]; then
  72. ${WAMRC_CMD} -sgx --enable-multi-thread -o pthread_mutex.aot pthread_mutex.wasm
  73. else
  74. ${WAMRC_CMD} --enable-multi-thread -o pthread_mutex.aot pthread_mutex.wasm
  75. fi
  76. echo "============> run pthread_mutex.aot"
  77. ${IWASM_CMD} --heap-size=16384 pthread_mutex.aot
  78. echo "============> compile pthread_cond.wasm to aot"
  79. if [[ $2 == "--sgx" ]]; then
  80. ${WAMRC_CMD} -sgx --enable-multi-thread -o pthread_cond.aot pthread_cond.wasm
  81. else
  82. ${WAMRC_CMD} --enable-multi-thread -o pthread_cond.aot pthread_cond.wasm
  83. fi
  84. echo "============> run pthread_cond.aot"
  85. ${IWASM_CMD} --heap-size=16384 pthread_cond.aot
  86. echo "============> compile pthread_key.wasm to aot"
  87. if [[ $2 == "--sgx" ]]; then
  88. ${WAMRC_CMD} -sgx --enable-multi-thread -o pthread_key.aot pthread_key.wasm
  89. else
  90. ${WAMRC_CMD} --enable-multi-thread -o pthread_key.aot pthread_key.wasm
  91. fi
  92. echo "============> run pthread_key.aot"
  93. ${IWASM_CMD} --heap-size=16384 pthread_key.aot
  94. fi
  95. cd threads-opcode-wasm-apps
  96. rm -rf build && mkdir build && cd build
  97. cmake .. && make
  98. cd ../..
  99. wasm_files=$(ls threads-opcode-wasm-apps/build/*.wasm)
  100. for wasm_file in $wasm_files; do
  101. wasm_file_name="${wasm_file%.wasm}"
  102. # avoid keep printing warning: warning: SGX pthread_cond_timedwait isn't supported, calling pthread_cond_wait instead!
  103. if [[ $2 == "--sgx" ]] && [[ ${wasm_file_name} == *"atomic_wait_notify"* ]]; then
  104. echo "============> didn't run ${wasm_file_name} on sgx aot mode, it will output too much warning info"
  105. continue
  106. fi
  107. if [[ $1 != "--aot" ]]; then
  108. echo "============> run ${wasm_file_name}.wasm"
  109. ${IWASM_CMD} --heap-size=16384 ${wasm_file_name}.wasm
  110. else
  111. echo "============> compile ${wasm_file_name}.wasm to aot"
  112. if [[ $2 == "--sgx" ]]; then
  113. ${WAMRC_CMD} -sgx --enable-multi-thread --opt-level=0 -o ${wasm_file_name}.aot ${wasm_file_name}.wasm
  114. else
  115. ${WAMRC_CMD} --enable-multi-thread --opt-level=0 -o ${wasm_file_name}.aot ${wasm_file_name}.wasm
  116. fi
  117. echo "============> run ${wasm_file_name}.aot"
  118. ${IWASM_CMD} --heap-size=16384 ${wasm_file_name}.aot
  119. fi
  120. done