hostap.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. name: hostap and wpa-supplicant Tests
  2. on:
  3. workflow_call:
  4. jobs:
  5. build_wolfssl:
  6. strategy:
  7. matrix:
  8. include:
  9. - build_id: hostap-build1
  10. wolf_extra_config: --disable-tls13
  11. - build_id: hostap-build2
  12. wolf_extra_config: --enable-brainpool --enable-wpas-dpp
  13. name: Build wolfSSL
  14. # Just to keep it the same as the testing target
  15. runs-on: ubuntu-20.04
  16. # This should be a safe limit for the tests to run.
  17. timeout-minutes: 4
  18. steps:
  19. # No way to view the full strategy in the browser (really weird)
  20. - name: Print strategy
  21. run: |
  22. cat <<EOF
  23. ${{ toJSON(matrix) }}
  24. EOF
  25. - if: ${{ runner.debug }}
  26. name: Enable wolfSSL debug logging
  27. run: |
  28. echo "wolf_debug_flags=--enable-debug" >> $GITHUB_ENV
  29. - name: Build wolfSSL
  30. uses: wolfSSL/actions-build-autotools-project@v1
  31. with:
  32. path: wolfssl
  33. configure: >-
  34. --enable-wpas CFLAGS=-DWOLFSSL_STATIC_RSA
  35. ${{ env.wolf_debug_flags }} ${{ matrix.wolf_extra_config }}
  36. install: true
  37. - name: Upload built lib
  38. uses: actions/upload-artifact@v4
  39. with:
  40. name: ${{ matrix.build_id }}
  41. path: build-dir
  42. retention-days: 5
  43. # Build wpa_supplicant with wolfSSL and hostapd with OpenSSL and interop.
  44. hostap_test:
  45. strategy:
  46. fail-fast: false
  47. matrix:
  48. # should hostapd be compiled with wolfssl
  49. hostapd: [true, false]
  50. # should wpa_supplicant be compiled with wolfssl
  51. wpa_supplicant: [true, false]
  52. # Fix the versions of hostap and osp to not break testing when a new
  53. # patch is added in to osp. hostap_cherry_pick is used to apply the
  54. # commit that updates the certificates used for testing. Tests are read
  55. # from the corresponding configs/hostap_ref/tests file.
  56. config: [
  57. {
  58. hostap_ref: hostap_2_10,
  59. hostap_cherry_pick: 36fcbb1a4ee4aa604f15079eae2ffa4fe7f44680,
  60. remove_teap: true,
  61. # TLS 1.3 does not work for this version
  62. build_id: hostap-build1,
  63. },
  64. # Test the dpp patch
  65. {
  66. hostap_ref: b607d2723e927a3446d89aed813f1aa6068186bb,
  67. hostap_cherry_pick: 36fcbb1a4ee4aa604f15079eae2ffa4fe7f44680,
  68. osp_ref: ad5b52a49b3cc2a5bfb47ccc1d6a5137132e9446,
  69. build_id: hostap-build2
  70. },
  71. ]
  72. # parallelize the tests to be able to run all tests within 10 minutes
  73. # Update the <total server> in the ./run-tests.py step when changing.
  74. server: [1, 2, 3, 4, 5]
  75. exclude:
  76. # don't test openssl on both sides
  77. - hostapd: false
  78. wpa_supplicant: false
  79. # no hostapd support for dpp yet
  80. - hostapd: true
  81. config: {
  82. hostap_ref: b607d2723e927a3446d89aed813f1aa6068186bb,
  83. osp_ref: ad5b52a49b3cc2a5bfb47ccc1d6a5137132e9446,
  84. build_id: hostap-build2
  85. }
  86. name: hwsim test
  87. # For openssl 1.1
  88. runs-on: ubuntu-20.04
  89. # This should be a safe limit for the tests to run.
  90. timeout-minutes: 12
  91. needs: build_wolfssl
  92. steps:
  93. # No way to view the full strategy in the browser (really weird)
  94. - name: Print strategy
  95. run: |
  96. cat <<EOF
  97. ${{ toJSON(matrix) }}
  98. EOF
  99. - name: Print computed job run ID
  100. run: |
  101. SHA_SUM=$(sha256sum << 'END_OF_HEREDOC' | cut -d " " -f 1
  102. ${{ toJSON(github) }}
  103. END_OF_HEREDOC
  104. )
  105. echo "our_job_run_id=$SHA_SUM" >> $GITHUB_ENV
  106. echo Our job run ID is $SHA_SUM
  107. - name: Checkout wolfSSL
  108. uses: actions/checkout@v4
  109. with:
  110. path: wolfssl
  111. - name: Install dependencies
  112. run: |
  113. # Don't prompt for anything
  114. export DEBIAN_FRONTEND=noninteractive
  115. sudo apt-get update
  116. # hostap dependencies
  117. sudo apt-get install -y libpcap0.8 libpcap-dev curl libcurl4-openssl-dev \
  118. libnl-3-dev binutils-dev libssl-dev libiberty-dev libnl-genl-3-dev \
  119. libnl-route-3-dev libdbus-1-dev linux-modules-extra-`uname -r` \
  120. bridge-utils
  121. sudo pip3 install pycryptodome
  122. - name: Enable mac80211
  123. run: |
  124. sudo modprobe mac80211
  125. lsmod | grep mac80211
  126. - if: ${{ runner.debug }}
  127. name: Enable hostap debug logging
  128. run: |
  129. echo "hostap_debug_flags=-d" >> $GITHUB_ENV
  130. - name: Download lib
  131. uses: actions/download-artifact@v4
  132. with:
  133. name: ${{ matrix.config.build_id }}
  134. path: build-dir
  135. - name: Setup d-bus
  136. working-directory: wolfssl/.github/workflows/hostap-files
  137. run: |
  138. sudo cp dbus-wpa_supplicant.conf /usr/share/dbus-1/system.d/wpa_supplicant.conf
  139. sudo service dbus reload
  140. # This is super hack-ish :P
  141. # If you are trying to reproduce this on a more generic system, you can
  142. # just run `sudo apt install linux-modules-extra-$(uname -r)` and
  143. # this should have the module in the package. No need to compile it.
  144. - name: Compile and install mac80211_hwsim
  145. working-directory: wolfssl/.github/workflows/hostap-files
  146. run: |
  147. # The tag will be the first two numbers of from uname -r
  148. LINUX_TAG=$(uname -r | grep -oP '^\d+\.\d+')
  149. # Download the correct version of the driver
  150. wget https://raw.githubusercontent.com/torvalds/linux/v$LINUX_TAG/drivers/net/wireless/mac80211_hwsim.c
  151. wget https://raw.githubusercontent.com/torvalds/linux/v$LINUX_TAG/drivers/net/wireless/mac80211_hwsim.h
  152. make
  153. sudo make install
  154. sudo modprobe mac80211_hwsim
  155. lsmod | grep mac80211_hwsim
  156. sudo rmmod mac80211_hwsim
  157. - name: Checkout hostap
  158. uses: actions/checkout@v4
  159. with:
  160. repository: julek-wolfssl/hostap-mirror
  161. path: hostap
  162. ref: ${{ matrix.config.hostap_ref }}
  163. # necessary for cherry pick step
  164. fetch-depth: 0
  165. - if: ${{ matrix.config.hostap_cherry_pick }}
  166. name: Cherry pick certificate update
  167. working-directory: hostap
  168. run: git cherry-pick -n -X theirs ${{ matrix.config.hostap_cherry_pick }}
  169. - if: ${{ matrix.config.osp_ref }}
  170. name: Checkout OSP
  171. uses: actions/checkout@v4
  172. with:
  173. repository: wolfssl/osp
  174. path: osp
  175. ref: ${{ matrix.config.osp_ref }}
  176. - if: ${{ matrix.config.osp_ref }}
  177. name: Apply patch files
  178. working-directory: hostap
  179. run: |
  180. for f in $GITHUB_WORKSPACE/osp/hostap-patches/pending/*
  181. do
  182. patch -p1 < $f
  183. done
  184. - if: ${{ matrix.hostapd }}
  185. name: Setup hostapd config file
  186. run: |
  187. cp wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/hostapd.config \
  188. hostap/hostapd/.config
  189. cat <<EOF >> hostap/hostapd/.config
  190. CFLAGS += -I$GITHUB_WORKSPACE/build-dir/include -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib
  191. LIBS += -L$GITHUB_WORKSPACE/build-dir/lib -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib
  192. EOF
  193. - if: ${{ matrix.wpa_supplicant }}
  194. name: Setup wpa_supplicant config file
  195. run: |
  196. cp wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/wpa_supplicant.config \
  197. hostap/wpa_supplicant/.config
  198. cat <<EOF >> hostap/wpa_supplicant/.config
  199. CFLAGS += -I$GITHUB_WORKSPACE/build-dir/include -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib
  200. LIBS += -L$GITHUB_WORKSPACE/build-dir/lib -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib
  201. EOF
  202. - name: Build hostap
  203. working-directory: hostap/tests/hwsim/
  204. run: ./build.sh
  205. - if: ${{ matrix.hostapd }}
  206. name: Confirm hostapd linking with wolfSSL
  207. run: ldd hostap/hostapd/hostapd | grep wolfssl
  208. - if: ${{ matrix.wpa_supplicant }}
  209. name: Confirm wpa_supplicant linking with wolfSSL
  210. run: ldd hostap/wpa_supplicant/wpa_supplicant | grep wolfssl
  211. - if: ${{ matrix.config.remove_teap }}
  212. name: Remove EAP-TEAP from test configuration
  213. working-directory: hostap/tests/hwsim/auth_serv
  214. run: |
  215. sed -e 's/"erp-teap@example.com"\tTEAP//' -i eap_user.conf
  216. sed -e 's/"erp-teap@example.com"\tMSCHAPV2\t"password"\t\[2\]//' -i eap_user.conf
  217. sed -e 's/"TEAP"\t\tTEAP//' -i eap_user.conf
  218. sed -e 's/TEAP,//' -i eap_user.conf
  219. - name: Run tests
  220. id: testing
  221. working-directory: hostap/tests/hwsim/
  222. run: |
  223. # Run tests in increments of 50 to cut down on the uploaded log size.
  224. while mapfile -t -n 50 ary && ((${#ary[@]})); do
  225. TESTS=$(printf '%s\n' "${ary[@]}" | tr '\n' ' ')
  226. # Retry up to three times
  227. for i in {1..3}; do
  228. HWSIM_RES=0 # Not set when command succeeds
  229. # Logs can grow quickly especially in debug mode
  230. sudo rm -rf logs
  231. sudo ./start.sh
  232. sudo ./run-tests.py ${{ env.hostap_debug_flags }} --split ${{ matrix.server }}/5 $TESTS || HWSIM_RES=$?
  233. sudo ./stop.sh
  234. if [ "$HWSIM_RES" -eq "0" ]; then
  235. break
  236. fi
  237. done
  238. echo "test ran $i times"
  239. if [ "$HWSIM_RES" -ne "0" ]; then
  240. exit $HWSIM_RES
  241. fi
  242. done < $GITHUB_WORKSPACE/wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/tests
  243. - name: Change failure log permissions
  244. if: ${{ failure() && steps.testing.outcome == 'failure' }}
  245. working-directory: hostap/tests/hwsim/
  246. run: |
  247. sudo chown -R $USER:$USER logs
  248. zip -9 -r logs.zip logs/current
  249. - name: Upload failure logs
  250. if: ${{ failure() && steps.testing.outcome == 'failure' }}
  251. uses: actions/upload-artifact@v4
  252. with:
  253. name: hostap-logs-${{ env.our_job_run_id }}
  254. path: hostap/tests/hwsim/logs.zip
  255. retention-days: 5