spec_test_on_nuttx.yml 13 KB

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