spec_test_on_nuttx.yml 12 KB

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