test.yml 8.7 KB

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