2
0

hostap-vm.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. name: hostap and wpa-supplicant Tests
  2. # START OF COMMON SECTION
  3. on:
  4. push:
  5. branches: [ 'master', 'main', 'release/**' ]
  6. pull_request:
  7. branches: [ '*' ]
  8. concurrency:
  9. group: ${{ github.workflow }}-${{ github.ref }}
  10. cancel-in-progress: true
  11. # END OF COMMON SECTION
  12. env:
  13. LINUX_REF: v6.6
  14. jobs:
  15. build_wolfssl:
  16. strategy:
  17. matrix:
  18. include:
  19. - build_id: hostap-vm-build1
  20. wolf_extra_config: --disable-tls13
  21. - build_id: hostap-vm-build2
  22. wolf_extra_config: >-
  23. --enable-wpas-dpp --enable-brainpool --with-eccminsz=192
  24. --enable-tlsv10 --enable-oldtls
  25. name: Build wolfSSL
  26. runs-on: ubuntu-latest
  27. # This should be a safe limit for the tests to run.
  28. timeout-minutes: 10
  29. steps:
  30. # No way to view the full strategy in the browser (really weird)
  31. - name: Print strategy
  32. run: |
  33. cat <<EOF
  34. ${{ toJSON(matrix) }}
  35. EOF
  36. - if: ${{ runner.debug }}
  37. name: Enable wolfSSL debug logging
  38. run: |
  39. echo "wolf_debug_flags=--enable-debug" >> $GITHUB_ENV
  40. - name: Build wolfSSL
  41. uses: wolfSSL/actions-build-autotools-project@v1
  42. with:
  43. path: wolfssl
  44. configure: >-
  45. --enable-wpas CPPFLAGS=-DWOLFSSL_STATIC_RSA
  46. ${{ env.wolf_debug_flags }} ${{ matrix.wolf_extra_config }}
  47. install: true
  48. - name: tar build-dir
  49. run: tar -zcf build-dir.tgz build-dir
  50. - name: Upload built lib
  51. uses: actions/upload-artifact@v4
  52. with:
  53. name: ${{ matrix.build_id }}
  54. path: build-dir.tgz
  55. retention-days: 5
  56. build_uml_linux:
  57. name: Build UML (UserMode Linux)
  58. runs-on: ubuntu-latest
  59. # This should be a safe limit for the tests to run.
  60. timeout-minutes: 10
  61. steps:
  62. - name: Checking if we have kernel in cache
  63. uses: actions/cache@v4
  64. id: cache
  65. with:
  66. path: linux/linux
  67. key: ${{ env.LINUX_REF }}
  68. lookup-only: true
  69. - name: Checkout hostap
  70. if: steps.cache.outputs.cache-hit != 'true'
  71. uses: actions/checkout@v4
  72. with:
  73. repository: julek-wolfssl/hostap-mirror
  74. path: hostap
  75. - name: Checkout linux
  76. if: steps.cache.outputs.cache-hit != 'true'
  77. uses: actions/checkout@v4
  78. with:
  79. repository: torvalds/linux
  80. path: linux
  81. - name: Compile linux
  82. if: steps.cache.outputs.cache-hit != 'true'
  83. run: |
  84. cp hostap/tests/hwsim/vm/kernel-config.uml linux/.config
  85. cd linux
  86. yes "" | ARCH=um make -j $(nproc)
  87. hostap_test:
  88. strategy:
  89. fail-fast: false
  90. matrix:
  91. # should hostapd be compiled with wolfssl
  92. hostapd: [true, false]
  93. # should wpa_supplicant be compiled with wolfssl
  94. wpa_supplicant: [true, false]
  95. # Fix the versions of hostap and osp to not break testing when a new
  96. # patch is added in to osp. Tests are read from the corresponding
  97. # configs/hostap_ref/tests file.
  98. config: [
  99. {
  100. hostap_ref: hostap_2_10,
  101. remove_teap: true,
  102. # TLS 1.3 does not work for this version
  103. build_id: hostap-vm-build1,
  104. },
  105. # Test the dpp patch
  106. {
  107. hostap_ref: b607d2723e927a3446d89aed813f1aa6068186bb,
  108. osp_ref: ad5b52a49b3cc2a5bfb47ccc1d6a5137132e9446,
  109. build_id: hostap-vm-build2
  110. },
  111. {
  112. hostap_ref: 07c9f183ea744ac04585fb6dd10220c75a5e2e74,
  113. osp_ref: e1876fbbf298ee442bc7ab8561331ebc7de17528,
  114. build_id: hostap-vm-build2
  115. },
  116. ]
  117. exclude:
  118. # don't test openssl on both sides
  119. - hostapd: false
  120. wpa_supplicant: false
  121. # no hostapd support for dpp yet
  122. - hostapd: true
  123. config: {
  124. hostap_ref: b607d2723e927a3446d89aed813f1aa6068186bb,
  125. osp_ref: ad5b52a49b3cc2a5bfb47ccc1d6a5137132e9446,
  126. build_id: hostap-vm-build2
  127. }
  128. name: hwsim test
  129. # For openssl 1.1
  130. runs-on: ubuntu-latest
  131. # This should be a safe limit for the tests to run.
  132. timeout-minutes: 45
  133. needs: [build_wolfssl, build_uml_linux]
  134. steps:
  135. - name: Checking if we have kernel in cache
  136. uses: actions/cache/restore@v4
  137. id: cache
  138. with:
  139. path: linux/linux
  140. key: ${{ env.LINUX_REF }}
  141. fail-on-cache-miss: true
  142. - name: show file structure
  143. run: tree
  144. # No way to view the full strategy in the browser (really weird)
  145. - name: Print strategy
  146. run: |
  147. cat <<EOF
  148. ${{ toJSON(matrix) }}
  149. EOF
  150. - name: Print computed job run ID
  151. run: |
  152. SHA_SUM=$(sha256sum << 'END_OF_HEREDOC' | cut -d " " -f 1
  153. ${{ toJSON(github) }}
  154. END_OF_HEREDOC
  155. )
  156. echo "our_job_run_id=$SHA_SUM" >> $GITHUB_ENV
  157. echo Our job run ID is $SHA_SUM
  158. - name: Checkout wolfSSL
  159. uses: actions/checkout@v4
  160. with:
  161. path: wolfssl
  162. - name: Download lib
  163. uses: actions/download-artifact@v4
  164. with:
  165. name: ${{ matrix.config.build_id }}
  166. - name: untar build-dir
  167. run: tar -xf build-dir.tgz
  168. - name: Install dependencies
  169. run: |
  170. # Don't prompt for anything
  171. export DEBIAN_FRONTEND=noninteractive
  172. sudo apt-get update
  173. # hostap dependencies
  174. sudo apt-get install -y libpcap0.8 libpcap-dev curl libcurl4-openssl-dev \
  175. libnl-3-dev binutils-dev libssl-dev libiberty-dev libnl-genl-3-dev \
  176. libnl-route-3-dev libdbus-1-dev bridge-utils tshark
  177. sudo pip3 install pycryptodome
  178. - name: Checkout hostap
  179. uses: actions/checkout@v4
  180. with:
  181. repository: julek-wolfssl/hostap-mirror
  182. path: hostap
  183. ref: ${{ matrix.config.hostap_ref }}
  184. - name: Update certs
  185. working-directory: hostap/tests/hwsim/auth_serv
  186. run: ./update.sh
  187. - if: ${{ matrix.config.osp_ref }}
  188. name: Checkout OSP
  189. uses: actions/checkout@v4
  190. with:
  191. repository: wolfssl/osp
  192. path: osp
  193. ref: ${{ matrix.config.osp_ref }}
  194. - if: ${{ matrix.config.osp_ref }}
  195. name: Apply patch files
  196. working-directory: hostap
  197. run: |
  198. for f in $GITHUB_WORKSPACE/osp/hostap-patches/pending/*
  199. do
  200. patch -p1 < $f
  201. done
  202. - name: Apply extra patches
  203. working-directory: hostap
  204. run: |
  205. FILE=$GITHUB_WORKSPACE/wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/extra.patch
  206. if [ -f "$FILE" ]; then
  207. patch -p1 < $FILE
  208. fi
  209. - if: ${{ matrix.hostapd }}
  210. name: Setup hostapd config file
  211. run: |
  212. cp wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/hostapd.config \
  213. hostap/hostapd/.config
  214. cat <<EOF >> hostap/hostapd/.config
  215. CFLAGS += -I$GITHUB_WORKSPACE/build-dir/include -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib
  216. LIBS += -L$GITHUB_WORKSPACE/build-dir/lib -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib
  217. EOF
  218. - if: ${{ matrix.wpa_supplicant }}
  219. name: Setup wpa_supplicant config file
  220. run: |
  221. cp wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/wpa_supplicant.config \
  222. hostap/wpa_supplicant/.config
  223. cat <<EOF >> hostap/wpa_supplicant/.config
  224. CFLAGS += -I$GITHUB_WORKSPACE/build-dir/include -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib
  225. LIBS += -L$GITHUB_WORKSPACE/build-dir/lib -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib
  226. EOF
  227. - name: Build hostap and wpa_supplicant
  228. working-directory: hostap/tests/hwsim/
  229. run: ./build.sh
  230. - if: ${{ matrix.hostapd }}
  231. name: Confirm hostapd linking with wolfSSL
  232. run: ldd hostap/hostapd/hostapd | grep wolfssl
  233. - if: ${{ matrix.wpa_supplicant }}
  234. name: Confirm wpa_supplicant linking with wolfSSL
  235. run: ldd hostap/wpa_supplicant/wpa_supplicant | grep wolfssl
  236. - if: ${{ matrix.config.remove_teap }}
  237. name: Remove EAP-TEAP from test configuration
  238. working-directory: hostap/tests/hwsim/auth_serv
  239. run: |
  240. sed -e 's/"erp-teap@example.com"\tTEAP//' -i eap_user.conf
  241. sed -e 's/"erp-teap@example.com"\tMSCHAPV2\t"password"\t\[2\]//' -i eap_user.conf
  242. sed -e 's/"TEAP"\t\tTEAP//' -i eap_user.conf
  243. sed -e 's/TEAP,//' -i eap_user.conf
  244. - if: ${{ runner.debug }}
  245. name: Enable hostap debug logging
  246. run: |
  247. echo "hostap_debug_flags=--debug" >> $GITHUB_ENV
  248. - name: Run tests
  249. id: testing
  250. working-directory: hostap/tests/hwsim/
  251. run: |
  252. cat <<EOF >> vm/vm-config
  253. KERNELDIR=$GITHUB_WORKSPACE/linux
  254. KVMARGS="-cpu host"
  255. EOF
  256. # Run tests in increments of 200 to not stall out the parallel-vm script
  257. while mapfile -t -n 200 ary && ((${#ary[@]})); do
  258. TESTS=$(printf '%s\n' "${ary[@]}" | tr '\n' ' ')
  259. HWSIM_RES=0 # Not set when command succeeds
  260. ./vm/parallel-vm.py ${{ env.hostap_debug_flags }} --nocurses $(nproc) $TESTS || HWSIM_RES=$?
  261. if [ "$HWSIM_RES" -ne "0" ]; then
  262. # Let's re-run the failing tests. We gather the failed tests from the log file.
  263. FAILED_TESTS=$(grep 'failed tests' /tmp/hwsim-test-logs/*-parallel.log | sed 's/failed tests: //' | tr ' ' '\n' | sort | uniq | tr '\n' ' ')
  264. printf 'failed tests: %s\n' "$FAILED_TESTS"
  265. ./vm/parallel-vm.py ${{ env.hostap_debug_flags }} --nocurses $(nproc) $FAILED_TESTS
  266. fi
  267. rm -r /tmp/hwsim-test-logs
  268. done < $GITHUB_WORKSPACE/wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/tests
  269. # The logs are quite big. It hasn't been useful so far so let's not waste
  270. # precious gh space.
  271. #- name: zip logs
  272. # if: ${{ failure() && steps.testing.outcome == 'failure' }}
  273. # working-directory: hostap/tests/hwsim/
  274. # run: |
  275. # rm /tmp/hwsim-test-logs/latest
  276. # zip -9 -r logs.zip /tmp/hwsim-test-logs
  277. #
  278. #- name: Upload failure logs
  279. # if: ${{ failure() && steps.testing.outcome == 'failure' }}
  280. # uses: actions/upload-artifact@v4
  281. # with:
  282. # name: hostap-logs-${{ env.our_job_run_id }}
  283. # path: hostap/tests/hwsim/logs.zip
  284. # retention-days: 5