spec_test_on_nuttx.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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. # Our xtensa environment doesn't have enough memory
  118. - target_config: { target: "xtensa" }
  119. wamr_feature_option: { mode: "-G" }
  120. steps:
  121. # Note: we use an unreleased version nuttx for xtensa because
  122. # 12.4 doesn't contain necessary esp32s3 changes.
  123. - name: Checkout NuttX
  124. uses: actions/checkout@v4
  125. with:
  126. repository: apache/nuttx
  127. ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.6' }}
  128. path: nuttx
  129. - name: Checkout NuttX Apps
  130. uses: actions/checkout@v4
  131. with:
  132. repository: apache/nuttx-apps
  133. ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.6' }}
  134. path: apps
  135. - name: Checkout WAMR
  136. uses: actions/checkout@v4
  137. with:
  138. repository: ${{ github.repository }}
  139. path: apps/interpreters/wamr/wamr
  140. - name: Get LLVM libraries
  141. if: contains(matrix.wamr_test_option.mode, 'aot')
  142. id: retrieve_llvm_libs
  143. uses: actions/cache@v4
  144. with:
  145. path: |
  146. ./core/deps/llvm/build/bin
  147. ./core/deps/llvm/build/include
  148. ./core/deps/llvm/build/lib
  149. ./core/deps/llvm/build/libexec
  150. ./core/deps/llvm/build/share
  151. key: ${{ matrix.target_config.target == 'xtensa' && needs.build_llvm_libraries_xtensa.outputs.cache_key || needs.build_llvm_libraries.outputs.cache_key }}
  152. - name: Quit if cache miss
  153. if: contains(matrix.wamr_test_option.mode, 'aot') && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  154. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  155. - name: Copy LLVM
  156. if: contains(matrix.wamr_test_option.mode, 'aot')
  157. run: cp -r core/deps/llvm apps/interpreters/wamr/wamr/core/deps/llvm
  158. # Inject the config option to NuttX
  159. # TODO: Merge this into NuttX once GC is generally available
  160. #
  161. # Note: the version of nuttx-apps we use for xtensa does have
  162. # an equivalent. (the default of INTERPRETERS_WAMR_TAIL_CALL is
  163. # different though.)
  164. - name: Modify Kconfig
  165. if: matrix.target_config.target != 'xtensa'
  166. run: |
  167. echo "\n" >> apps/interpreters/wamr/Kconfig
  168. echo "config INTERPRETERS_WAMR_GC" >> apps/interpreters/wamr/Kconfig
  169. echo "\tbool \"Enable GC\"" >> apps/interpreters/wamr/Kconfig
  170. echo "\tdefault n" >> apps/interpreters/wamr/Kconfig
  171. echo "\n" >> apps/interpreters/wamr/Kconfig
  172. echo "config INTERPRETERS_WAMR_AOT_STACK_FRAME" >> apps/interpreters/wamr/Kconfig
  173. echo "\tbool \"Enable AOT stack frame\"" >> apps/interpreters/wamr/Kconfig
  174. echo "\tdefault n" >> apps/interpreters/wamr/Kconfig
  175. echo "\n" >> apps/interpreters/wamr/Kconfig
  176. echo "config INTERPRETERS_WAMR_TAIL_CALL" >> apps/interpreters/wamr/Kconfig
  177. echo "\tbool \"Enable Tail Call\"" >> apps/interpreters/wamr/Kconfig
  178. echo "\tdefault y" >> apps/interpreters/wamr/Kconfig
  179. - name: Build wamrc
  180. if: contains(matrix.wamr_test_option.mode, 'aot')
  181. working-directory: apps/interpreters/wamr/wamr/wamr-compiler
  182. run: |
  183. cmake -Bbuild .
  184. cmake --build build
  185. # the nuttx version we use for xtensa requires esptool.py newer than
  186. # what we have in our version of the apache-nuttx-ci-linux image.
  187. - name: Install the latest esptool.py (xtensa)
  188. if: matrix.target_config.target == 'xtensa'
  189. run: |
  190. pip3 install esptool==4.7.0
  191. esptool.py version
  192. - name: Configure NuttX
  193. run: |
  194. tools/configure.sh ${{ matrix.target_config.config }}
  195. working-directory: nuttx
  196. # depending on configurations, the iwasm command line generated
  197. # by spec-test-script can be longer than the default NSH_LINELEN,
  198. # which is 64 or 80.
  199. - name: Enable WAMR for NuttX
  200. run: |
  201. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR
  202. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_LOG
  203. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN
  204. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_REF_TYPES
  205. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_ENABLE_SPEC_TEST
  206. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_SHARED_MEMORY
  207. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_BULK_MEMORY
  208. kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACK_GUARD_SIZE 1024
  209. kconfig-tweak --enable CONFIG_FS_HOSTFS
  210. kconfig-tweak --enable CONFIG_ARM_SEMIHOSTING_HOSTFS
  211. kconfig-tweak --enable CONFIG_ARM_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
  212. kconfig-tweak --enable CONFIG_RISCV_SEMIHOSTING_HOSTFS
  213. kconfig-tweak --enable CONFIG_RISCV_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
  214. kconfig-tweak --enable CONFIG_XTENSA_SEMIHOSTING_HOSTFS
  215. kconfig-tweak --enable CONFIG_XTENSA_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
  216. kconfig-tweak --enable CONFIG_LIBC_FLOATINGPOINT
  217. kconfig-tweak --set-val CONFIG_NSH_LINELEN 255
  218. working-directory: nuttx
  219. - name: Set WAMR stack size for NuttX
  220. if: matrix.target_config.target != 'xtensa'
  221. run: |
  222. kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACKSIZE 327680
  223. working-directory: nuttx
  224. # because qemu doesn't have a proper emulation of esp32s3 psram,
  225. # we are limited to the internal ram, which is about 400KB.
  226. - name: Set WAMR stack size for NuttX (xtensa)
  227. if: matrix.target_config.target == 'xtensa'
  228. run: |
  229. kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACKSIZE 25600
  230. working-directory: nuttx
  231. - name: Enable WAMR interpreter/aot runtime for NuttX
  232. if: matrix.wamr_test_option.option != ''
  233. run: |
  234. for x in ${{ matrix.wamr_test_option.option }}; do
  235. kconfig-tweak --enable $x
  236. done
  237. working-directory: nuttx
  238. - name: Enable WAMR Features for NuttX
  239. if: matrix.wamr_feature_option.option != ''
  240. run: |
  241. for x in ${{ matrix.wamr_feature_option.option }}; do
  242. kconfig-tweak --enable $x
  243. done
  244. working-directory: nuttx
  245. - name: Disable FPU for NuttX
  246. if: matrix.target_config.fpu_type == 'none'
  247. run: |
  248. kconfig-tweak --disable CONFIG_ARCH_FPU
  249. working-directory: nuttx
  250. - name: Disable DPFPU for NuttX
  251. if: matrix.target_config.fpu_type == 'fp'
  252. run: |
  253. kconfig-tweak --disable CONFIG_ARCH_DPFPU
  254. working-directory: nuttx
  255. # Note: while a real hardware would need
  256. # INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=y,
  257. # it doesn't work with xtensa qemu which we use on the CI because it
  258. # doesn't have a proper emulation of I/D separate mappings.
  259. # we work it around by using INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=n.
  260. # this configuration won't work on a real hardware.
  261. - name: Tweak NuttX config (xtensa)
  262. if: matrix.target_config.target == 'xtensa'
  263. run: |
  264. kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_AOT_WORD_ALIGN_READ
  265. kconfig-tweak --disable CONFIG_INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR
  266. working-directory: nuttx
  267. - name: Build NuttX
  268. run: |
  269. make olddefconfig
  270. make -j$(nproc)
  271. working-directory: nuttx
  272. # for xtensa, build a 8MB firmware image.
  273. # simple boot is assumed. (thus the nuttx.bin offset in the image is 0)
  274. # qemu will infer the flash size from the file size.
  275. - name: Post build processing (xtensa)
  276. if: matrix.target_config.target == 'xtensa'
  277. run: |
  278. cd nuttx
  279. dd if=/dev/zero of=flash.img bs=1024 count=8192
  280. dd if=nuttx.bin of=flash.img conv=notrunc
  281. mv flash.img nuttx
  282. - name: Build firmware path
  283. id: build_firmware_path
  284. run: |
  285. echo "firmware=$PWD/nuttx/nuttx" >> $GITHUB_OUTPUT
  286. # for xtensa, use the espressif fork of qemu, which has esp32s3 support.
  287. - name: Install QEMU (xtensa)
  288. if: matrix.target_config.target == 'xtensa'
  289. run: |
  290. apt-get remove -y qemu-system-misc
  291. apt-get update && apt-get install -y libsdl2-2.0-0
  292. ./.github/scripts/install_qemu_xtensa.sh
  293. qemu-system-xtensa --version
  294. working-directory: apps/interpreters/wamr/wamr
  295. - name: Test
  296. if: matrix.target_config.target != 'xtensa'
  297. run: |
  298. cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
  299. ./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}}
  300. # for xtensa, for some reasons, when running the tests
  301. # with test_wamr.sh -P, nuttx occasionally hangs after
  302. # "total segments stored 6" on the CI.
  303. # i (yamamoto) couldn't reproduce it locally (macOS) even
  304. # with the identical flash image.
  305. # for now, run the tests without -P.
  306. - name: Test
  307. if: matrix.target_config.target == 'xtensa'
  308. run: |
  309. cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
  310. ./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}}
  311. - name: pack the log
  312. if: always()
  313. run: |
  314. mkdir log
  315. cp $PWD/nuttx/.config log/dot-config
  316. cp ${{ steps.build_firmware_path.outputs.firmware }} log
  317. tar -C apps/interpreters/wamr/wamr/tests/wamr-test-suites/workspace -cvzf log/report.tgz report
  318. - name: upload the log
  319. if: always()
  320. uses: actions/upload-artifact@v4
  321. with:
  322. name: spec-test-log-${{ github.run_id }}-${{ strategy.job-index }}-${{ matrix.target_config.target }}
  323. path: log