hostap-vm.yml 11 KB

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