hostap.yml 10.0 KB

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