spec_test_on_nuttx.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. name: spec test on nuttx
  4. on:
  5. pull_request:
  6. types:
  7. - opened
  8. - synchronize
  9. paths:
  10. - ".github/workflows/spec_test_on_nuttx.yml"
  11. - "core/**"
  12. - "!core/deps/**"
  13. - "product-mini/**"
  14. - "!samples/workload/**"
  15. - "tests/wamr-test-suites/**"
  16. - "wamr-compiler/**"
  17. - "wamr-sdk/**"
  18. schedule:
  19. - cron: '0 0 * * *'
  20. workflow_dispatch:
  21. # Note on INTERPRETERS_WAMR_STACK_GUARD_SIZE:
  22. # https://github.com/apache/nuttx-apps/pull/2241 is not included in
  23. # releases/12.4 branch as of writing this.
  24. env:
  25. LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
  26. WASI_SDK_PATH: "/opt/wasi-sdk"
  27. jobs:
  28. build_llvm_libraries:
  29. uses: ./.github/workflows/build_llvm_libraries.yml
  30. with:
  31. os: "ubuntu-22.04"
  32. arch: "ARM RISCV AArch64"
  33. container_image: ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
  34. build_llvm_libraries_xtensa:
  35. uses: ./.github/workflows/build_llvm_libraries.yml
  36. with:
  37. os: "ubuntu-22.04"
  38. arch: "Xtensa"
  39. extra_build_llvm_options: "--platform xtensa"
  40. cache_key_suffix: "-xtensa"
  41. container_image: ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
  42. spec_test_on_qemu:
  43. runs-on: ubuntu-latest
  44. needs: [build_llvm_libraries, build_llvm_libraries_xtensa]
  45. container:
  46. image: ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
  47. strategy:
  48. matrix:
  49. target_config: [
  50. # {
  51. # config: "boards/arm64/qemu/qemu-armv8a/configs/nsh",
  52. # target: "aarch64_vfp",
  53. # fpu_type: "fp"
  54. # },
  55. # {
  56. # config: "boards/arm/imx6/sabre-6quad/configs/nsh",
  57. # target: "thumbv7",
  58. # fpu_type: "none"
  59. # },
  60. {
  61. config: "boards/arm/imx6/sabre-6quad/configs/nsh",
  62. target: "thumbv7_vfp",
  63. fpu_type: "dp"
  64. },
  65. {
  66. config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
  67. target: "riscv32",
  68. fpu_type: "none"
  69. },
  70. {
  71. config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
  72. target: "riscv32_ilp32f",
  73. fpu_type: "fp"
  74. },
  75. # {
  76. # config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
  77. # target: "riscv32_ilp32d",
  78. # fpu_type: "dp"
  79. # },
  80. {
  81. config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh64",
  82. target: "riscv64",
  83. fpu_type: "none"
  84. },
  85. {
  86. config: "boards/xtensa/esp32s3/esp32s3-devkit/configs/qemu_debug",
  87. target: "xtensa",
  88. fpu_type: "none"
  89. },
  90. ]
  91. wamr_test_option: [
  92. {
  93. mode: "-t aot",
  94. option: "CONFIG_INTERPRETERS_WAMR_AOT"
  95. },
  96. {
  97. mode: "-t aot -X",
  98. option: "CONFIG_INTERPRETERS_WAMR_AOT"
  99. },
  100. # {
  101. # mode: "-t classic-interp",
  102. # option: "CONFIG_INTERPRETERS_WAMR_CLASSIC"
  103. # },
  104. # {
  105. # mode: "-t fast-interp",
  106. # option: "CONFIG_INTERPRETERS_WAMR_FAST"
  107. # },
  108. ]
  109. wamr_feature_option:
  110. # Empty option for default
  111. - { option: "", mode: "" }
  112. - { option: "CONFIG_INTERPRETERS_WAMR_GC CONFIG_INTERPRETERS_WAMR_AOT_STACK_FRAME", mode: "-G" }
  113. exclude:
  114. # XIP is not fully supported yet on RISCV64, some relocations can not be resolved
  115. - target_config: { config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh64" }
  116. wamr_test_option: { mode: "-t aot -X" }
  117. # XIP is not fully supported yet on RISCV32 ILP32F, some relocations can not be resolved
  118. - target_config: { config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh", fpu_type: "fp" }
  119. wamr_test_option: { mode: "-t aot -X" }
  120. # Our xtensa environment doesn't have enough memory
  121. - target_config: { target: "xtensa" }
  122. wamr_feature_option: { mode: "-G" }
  123. steps:
  124. # Note: we use an unreleased version nuttx for xtensa because
  125. # 12.4 doesn't contain necessary esp32s3 changes.
  126. - name: Checkout NuttX
  127. uses: actions/checkout@v4
  128. with:
  129. repository: apache/nuttx
  130. ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.6' }}
  131. path: nuttx
  132. - name: Checkout NuttX Apps
  133. uses: actions/checkout@v4
  134. with:
  135. repository: apache/nuttx-apps
  136. ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.6' }}
  137. path: apps
  138. - name: Checkout WAMR
  139. uses: actions/checkout@v4
  140. with:
  141. repository: ${{ github.repository }}
  142. path: apps/interpreters/wamr/wamr
  143. - name: Get LLVM libraries
  144. if: contains(matrix.wamr_test_option.mode, 'aot')
  145. id: retrieve_llvm_libs
  146. uses: actions/cache@v4
  147. with:
  148. path: |
  149. ./core/deps/llvm/build/bin
  150. ./core/deps/llvm/build/include
  151. ./core/deps/llvm/build/lib
  152. ./core/deps/llvm/build/libexec
  153. ./core/deps/llvm/build/share
  154. key: ${{ matrix.target_config.target == 'xtensa' && needs.build_llvm_libraries_xtensa.outputs.cache_key || needs.build_llvm_libraries.outputs.cache_key }}
  155. - name: Quit if cache miss
  156. if: contains(matrix.wamr_test_option.mode, 'aot') && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  157. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  158. - name: Copy LLVM
  159. if: contains(matrix.wamr_test_option.mode, 'aot')
  160. run: cp -r core/deps/llvm apps/interpreters/wamr/wamr/core/deps/llvm
  161. # Inject the config option to NuttX
  162. # TODO: Merge this into NuttX once GC is generally available
  163. #
  164. # Note: the version of nuttx-apps we use for xtensa does have
  165. # an equivalent. (the default of INTERPRETERS_WAMR_TAIL_CALL is
  166. # different though.)
  167. - name: Modify Kconfig
  168. if: matrix.target_config.target != 'xtensa'
  169. run: |
  170. echo "\n" >> apps/interpreters/wamr/Kconfig
  171. echo "config INTERPRETERS_WAMR_GC" >> apps/interpreters/wamr/Kconfig
  172. echo "\tbool \"Enable GC\"" >> apps/interpreters/wamr/Kconfig
  173. echo "\tdefault n" >> apps/interpreters/wamr/Kconfig
  174. echo "\n" >> apps/interpreters/wamr/Kconfig
  175. echo "config INTERPRETERS_WAMR_AOT_STACK_FRAME" >> apps/interpreters/wamr/Kconfig
  176. echo "\tbool \"Enable AOT stack frame\"" >> apps/interpreters/wamr/Kconfig
  177. echo "\tdefault n" >> apps/interpreters/wamr/Kconfig
  178. echo "\n" >> apps/interpreters/wamr/Kconfig
  179. echo "config INTERPRETERS_WAMR_TAIL_CALL" >> apps/interpreters/wamr/Kconfig
  180. echo "\tbool \"Enable Tail Call\"" >> apps/interpreters/wamr/Kconfig
  181. echo "\tdefault y" >> apps/interpreters/wamr/Kconfig
  182. - name: Build wamrc
  183. if: contains(matrix.wamr_test_option.mode, 'aot')
  184. working-directory: apps/interpreters/wamr/wamr/wamr-compiler
  185. run: |
  186. cmake -Bbuild .
  187. cmake --build build
  188. # the nuttx version we use for xtensa requires esptool.py newer than
  189. # what we have in our version of the apache-nuttx-ci-linux image.
  190. - name: Install the latest esptool.py (xtensa)
  191. if: matrix.target_config.target == 'xtensa'
  192. run: |
  193. pip3 install esptool==4.7.0
  194. esptool.py version
  195. - name: Configure NuttX
  196. run: |
  197. tools/configure.sh ${{ matrix.target_config.config }}
  198. working-directory: nuttx
  199. # depending on configurations, the iwasm command line generated
  200. # by spec-test-script can be longer than the default NSH_LINELEN,
  201. # which is 64 or 80.
  202. - name: Enable WAMR for NuttX
  203. run: |
  204. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR
  205. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_LOG
  206. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN
  207. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_REF_TYPES
  208. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_ENABLE_SPEC_TEST
  209. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_SHARED_MEMORY
  210. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_BULK_MEMORY
  211. kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACK_GUARD_SIZE 1024
  212. kconfig-tweak --enable CONFIG_FS_HOSTFS
  213. kconfig-tweak --enable CONFIG_ARM_SEMIHOSTING_HOSTFS
  214. kconfig-tweak --enable CONFIG_ARM_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
  215. kconfig-tweak --enable CONFIG_RISCV_SEMIHOSTING_HOSTFS
  216. kconfig-tweak --enable CONFIG_RISCV_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
  217. kconfig-tweak --enable CONFIG_XTENSA_SEMIHOSTING_HOSTFS
  218. kconfig-tweak --enable CONFIG_XTENSA_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
  219. kconfig-tweak --enable CONFIG_LIBC_FLOATINGPOINT
  220. kconfig-tweak --set-val CONFIG_NSH_LINELEN 255
  221. working-directory: nuttx
  222. - name: Set WAMR stack size for NuttX
  223. if: matrix.target_config.target != 'xtensa'
  224. run: |
  225. kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACKSIZE 327680
  226. working-directory: nuttx
  227. # because qemu doesn't have a proper emulation of esp32s3 psram,
  228. # we are limited to the internal ram, which is about 400KB.
  229. - name: Set WAMR stack size for NuttX (xtensa)
  230. if: matrix.target_config.target == 'xtensa'
  231. run: |
  232. kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACKSIZE 25600
  233. working-directory: nuttx
  234. - name: Enable WAMR interpreter/aot runtime for NuttX
  235. if: matrix.wamr_test_option.option != ''
  236. run: |
  237. for x in ${{ matrix.wamr_test_option.option }}; do
  238. kconfig-tweak --enable $x
  239. done
  240. working-directory: nuttx
  241. - name: Enable WAMR Features for NuttX
  242. if: matrix.wamr_feature_option.option != ''
  243. run: |
  244. for x in ${{ matrix.wamr_feature_option.option }}; do
  245. kconfig-tweak --enable $x
  246. done
  247. working-directory: nuttx
  248. - name: Disable FPU for NuttX
  249. if: matrix.target_config.fpu_type == 'none'
  250. run: |
  251. kconfig-tweak --disable CONFIG_ARCH_FPU
  252. working-directory: nuttx
  253. - name: Disable DPFPU for NuttX
  254. if: matrix.target_config.fpu_type == 'fp'
  255. run: |
  256. kconfig-tweak --disable CONFIG_ARCH_DPFPU
  257. working-directory: nuttx
  258. # Note: while a real hardware would need
  259. # INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=y,
  260. # it doesn't work with xtensa qemu which we use on the CI because it
  261. # doesn't have a proper emulation of I/D separate mappings.
  262. # we work it around by using INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=n.
  263. # this configuration won't work on a real hardware.
  264. - name: Tweak NuttX config (xtensa)
  265. if: matrix.target_config.target == 'xtensa'
  266. run: |
  267. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_AOT_WORD_ALIGN_READ
  268. kconfig-tweak --disable CONFIG_INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR
  269. working-directory: nuttx
  270. - name: Build NuttX
  271. run: |
  272. make olddefconfig
  273. make -j$(nproc)
  274. working-directory: nuttx
  275. # for xtensa, build a 8MB firmware image.
  276. # simple boot is assumed. (thus the nuttx.bin offset in the image is 0)
  277. # qemu will infer the flash size from the file size.
  278. - name: Post build processing (xtensa)
  279. if: matrix.target_config.target == 'xtensa'
  280. run: |
  281. cd nuttx
  282. dd if=/dev/zero of=flash.img bs=1024 count=8192
  283. dd if=nuttx.bin of=flash.img conv=notrunc
  284. mv flash.img nuttx
  285. - name: Build firmware path
  286. id: build_firmware_path
  287. run: |
  288. echo "firmware=$PWD/nuttx/nuttx" >> $GITHUB_OUTPUT
  289. # for xtensa, use the espressif fork of qemu, which has esp32s3 support.
  290. - name: Install QEMU (xtensa)
  291. if: matrix.target_config.target == 'xtensa'
  292. run: |
  293. apt-get remove -y qemu-system-misc
  294. apt-get update && apt-get install -y libsdl2-2.0-0
  295. ./.github/scripts/install_qemu_xtensa.sh
  296. qemu-system-xtensa --version
  297. working-directory: apps/interpreters/wamr/wamr
  298. - name: Test
  299. if: matrix.target_config.target != 'xtensa'
  300. run: |
  301. cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
  302. ./test_wamr.sh -s spec ${{ matrix.wamr_test_option.mode }} -m ${{ matrix.target_config.target }} -b -Q -P -F ${{ steps.build_firmware_path.outputs.firmware }} ${{ matrix.wamr_feature_option.mode}}
  303. # for xtensa, for some reasons, when running the tests
  304. # with test_wamr.sh -P, nuttx occasionally hangs after
  305. # "total segments stored 6" on the CI.
  306. # i (yamamoto) couldn't reproduce it locally (macOS) even
  307. # with the identical flash image.
  308. # for now, run the tests without -P.
  309. - name: Test
  310. if: matrix.target_config.target == 'xtensa'
  311. run: |
  312. cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
  313. ./test_wamr.sh -s spec ${{ matrix.wamr_test_option.mode }} -m ${{ matrix.target_config.target }} -b -Q -F ${{ steps.build_firmware_path.outputs.firmware }} ${{ matrix.wamr_feature_option.mode}}
  314. - name: pack the log
  315. if: always()
  316. run: |
  317. mkdir log
  318. cp $PWD/nuttx/.config log/dot-config
  319. cp ${{ steps.build_firmware_path.outputs.firmware }} log
  320. tar -C apps/interpreters/wamr/wamr/tests/wamr-test-suites/workspace -cvzf log/report.tgz report
  321. - name: upload the log
  322. if: always()
  323. uses: actions/upload-artifact@v4
  324. with:
  325. name: spec-test-log-${{ github.run_id }}-${{ strategy.job-index }}-${{ matrix.target_config.target }}
  326. path: log