hostap-vm.yml 10 KB

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