test.yml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. name: test
  2. on: [push, pull_request]
  3. env:
  4. CFLAGS: -Werror
  5. MAKEFLAGS: -j
  6. jobs:
  7. # run tests
  8. test:
  9. runs-on: ubuntu-latest
  10. strategy:
  11. fail-fast: false
  12. matrix:
  13. arch: [x86_64, thumb, mips, powerpc]
  14. steps:
  15. - uses: actions/checkout@v2
  16. - name: install
  17. run: |
  18. # need toml, also pip3 isn't installed by default?
  19. sudo apt-get update
  20. sudo apt-get install python3 python3-pip
  21. sudo pip3 install toml
  22. mkdir status
  23. # cross-compile with ARM Thumb (32-bit, little-endian)
  24. - name: install-thumb
  25. if: matrix.arch == 'thumb'
  26. run: |
  27. sudo apt-get install \
  28. gcc-arm-linux-gnueabi \
  29. libc6-dev-armel-cross \
  30. qemu-user
  31. echo "CC=arm-linux-gnueabi-gcc -mthumb --static" >> $GITHUB_ENV
  32. echo "EXEC=qemu-arm" >> $GITHUB_ENV
  33. arm-linux-gnueabi-gcc --version
  34. qemu-arm -version
  35. # cross-compile with MIPS (32-bit, big-endian)
  36. - name: install-mips
  37. if: matrix.arch == 'mips'
  38. run: |
  39. sudo apt-get install \
  40. gcc-mips-linux-gnu \
  41. libc6-dev-mips-cross \
  42. qemu-user
  43. echo "CC=mips-linux-gnu-gcc --static" >> $GITHUB_ENV
  44. echo "EXEC=qemu-mips" >> $GITHUB_ENV
  45. mips-linux-gnu-gcc --version
  46. qemu-mips -version
  47. # cross-compile with PowerPC (32-bit, big-endian)
  48. - name: install-powerpc
  49. if: matrix.arch == 'powerpc'
  50. run: |
  51. sudo apt-get install \
  52. gcc-powerpc-linux-gnu \
  53. libc6-dev-powerpc-cross \
  54. qemu-user
  55. echo "CC=powerpc-linux-gnu-gcc --static" >> $GITHUB_ENV
  56. echo "EXEC=qemu-ppc" >> $GITHUB_ENV
  57. powerpc-linux-gnu-gcc --version
  58. qemu-ppc -version
  59. # test configurations
  60. # make sure example can at least compile
  61. - name: test-example
  62. run: |
  63. sed -n '/``` c/,/```/{/```/d; p}' README.md > test.c && \
  64. make all CFLAGS+=" \
  65. -Duser_provided_block_device_read=NULL \
  66. -Duser_provided_block_device_prog=NULL \
  67. -Duser_provided_block_device_erase=NULL \
  68. -Duser_provided_block_device_sync=NULL \
  69. -include stdio.h"
  70. # # normal+reentrant tests
  71. # - name: test-default
  72. # run: make test SCRIPTFLAGS+="-nrk"
  73. # # NOR flash: read/prog = 1 block = 4KiB
  74. # - name: test-nor
  75. # run: make test SCRIPTFLAGS+="-nrk
  76. # -DLFS_READ_SIZE=1 -DLFS_BLOCK_SIZE=4096"
  77. # # SD/eMMC: read/prog = 512 block = 512
  78. # - name: test-emmc
  79. # run: make test SCRIPTFLAGS+="-nrk
  80. # -DLFS_READ_SIZE=512 -DLFS_BLOCK_SIZE=512"
  81. # # NAND flash: read/prog = 4KiB block = 32KiB
  82. # - name: test-nand
  83. # run: make test SCRIPTFLAGS+="-nrk
  84. # -DLFS_READ_SIZE=4096 -DLFS_BLOCK_SIZE=\(32*1024\)"
  85. # # other extreme geometries that are useful for various corner cases
  86. # - name: test-no-intrinsics
  87. # run: make test SCRIPTFLAGS+="-nrk
  88. # -DLFS_NO_INTRINSICS"
  89. # - name: test-byte-writes
  90. # run: make test SCRIPTFLAGS+="-nrk
  91. # -DLFS_READ_SIZE=1 -DLFS_CACHE_SIZE=1"
  92. # - name: test-block-cycles
  93. # run: make test SCRIPTFLAGS+="-nrk
  94. # -DLFS_BLOCK_CYCLES=1"
  95. # - name: test-odd-block-count
  96. # run: make test SCRIPTFLAGS+="-nrk
  97. # -DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD_SIZE=256"
  98. # - name: test-odd-block-size
  99. # run: make test SCRIPTFLAGS+="-nrk
  100. # -DLFS_READ_SIZE=11 -DLFS_BLOCK_SIZE=704"
  101. # update results
  102. - uses: actions/checkout@v2
  103. if: github.ref != 'refs/heads/master'
  104. continue-on-error: true
  105. with:
  106. ref: master
  107. path: master
  108. - name: results-code
  109. continue-on-error: true
  110. run: |
  111. export OBJ="$(ls lfs*.c | sed 's/\.c/\.o/' | tr '\n' ' ')"
  112. export CFLAGS+=" \
  113. -DLFS_NO_ASSERT \
  114. -DLFS_NO_DEBUG \
  115. -DLFS_NO_WARN \
  116. -DLFS_NO_ERROR"
  117. if [ -d master ]
  118. then
  119. make -C master clean code OBJ="$OBJ" \
  120. SCRIPTFLAGS+="-qo code.csv" \
  121. && export SCRIPTFLAGS+="-d master/code.csv"
  122. fi
  123. make clean code OBJ="$OBJ" \
  124. SCRIPTFLAGS+="-o code.csv"
  125. - name: results-code-readonly
  126. continue-on-error: true
  127. run: |
  128. export OBJ="$(ls lfs*.c | sed 's/\.c/\.o/' | tr '\n' ' ')"
  129. export CFLAGS+=" \
  130. -DLFS_NO_ASSERT \
  131. -DLFS_NO_DEBUG \
  132. -DLFS_NO_WARN \
  133. -DLFS_NO_ERROR \
  134. -DLFS_READONLY"
  135. if [ -d master ]
  136. then
  137. make -C master clean code OBJ="$OBJ" \
  138. SCRIPTFLAGS+="-qo code-readonly.csv" \
  139. && export SCRIPTFLAGS+="-d master/code-readonly.csv"
  140. fi
  141. # TODO remove this OBJ
  142. make clean code OBJ="$OBJ" \
  143. SCRIPTFLAGS+="-o code-readonly.csv"
  144. - name: results-code-threadsafe
  145. continue-on-error: true
  146. run: |
  147. export OBJ="$(ls lfs*.c | sed 's/\.c/\.o/' | tr '\n' ' ')"
  148. export CFLAGS+=" \
  149. -DLFS_NO_ASSERT \
  150. -DLFS_NO_DEBUG \
  151. -DLFS_NO_WARN \
  152. -DLFS_NO_ERROR \
  153. -DLFS_THREADSAFE"
  154. if [ -d master ]
  155. then
  156. make -C master clean code OBJ="$OBJ" \
  157. SCRIPTFLAGS+="-qo code-threadsafe.csv" \
  158. && export SCRIPTFLAGS+="-d master/code-threadsafe.csv"
  159. fi
  160. make clean code OBJ="$OBJ" \
  161. SCRIPTFLAGS+="-o code-threadsafe.csv"
  162. - name: results-code-migrate
  163. continue-on-error: true
  164. run: |
  165. export OBJ="$(ls lfs*.c | sed 's/\.c/\.o/' | tr '\n' ' ')"
  166. export CFLAGS+=" \
  167. -DLFS_NO_ASSERT \
  168. -DLFS_NO_DEBUG \
  169. -DLFS_NO_WARN \
  170. -DLFS_NO_ERROR \
  171. -DLFS_MIGRATE"
  172. if [ -d master ]
  173. then
  174. make -C master clean code OBJ="$OBJ" \
  175. SCRIPTFLAGS+="-qo code-migrate.csv" \
  176. && export SCRIPTFLAGS+="-d master/code-migrate.csv"
  177. fi
  178. make clean code OBJ="$OBJ" \
  179. SCRIPTFLAGS+="-o code-migrate.csv"
  180. # limit reporting to Thumb, otherwise there would be too many numbers
  181. # flying around for the results to be easily readable
  182. - name: collect-status
  183. continue-on-error: true
  184. if: matrix.arch == 'thumb'
  185. run: |
  186. mkdir -p status
  187. shopt -s nullglob
  188. for f in code*.csv
  189. do
  190. export STEP="results-code$(
  191. echo $f | sed -n 's/code-\(.*\).csv/-\1/p')"
  192. export CONTEXT="results / code$(
  193. echo $f | sed -n 's/code-\(.*\).csv/ (\1)/p')"
  194. export DESCRIPTION="Code size is $(
  195. ./scripts/code.py -i $f -S $(
  196. [ -e master/$f ] && echo "-d master/$f"))"
  197. jq -nc '{
  198. state: "success",
  199. context: env.CONTEXT,
  200. description: env.DESCRIPTION,
  201. target_job: "test (${{matrix.arch}})",
  202. target_step: env.STEP}' \
  203. > status/code$(echo $f | sed -n 's/code-\(.*\).csv/-\1/p').json
  204. done
  205. - name: upload-status
  206. continue-on-error: true
  207. if: matrix.arch == 'thumb'
  208. uses: actions/upload-artifact@v2
  209. with:
  210. name: status
  211. path: status
  212. retention-days: 1
  213. # run under Valgrind to check for memory errors
  214. valgrind:
  215. runs-on: ubuntu-latest
  216. steps:
  217. - uses: actions/checkout@v2
  218. - name: install
  219. run: |
  220. # need toml, also pip3 isn't installed by default?
  221. sudo apt-get update
  222. sudo apt-get install python3 python3-pip
  223. sudo pip3 install toml
  224. - name: install-valgrind
  225. run: |
  226. sudo apt-get update
  227. sudo apt-get install valgrind
  228. valgrind --version
  229. # # normal tests, we don't need to test all geometries
  230. # - name: test-valgrind
  231. # run: make test SCRIPTFLAGS+="-k --valgrind"