aboutsummaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorArne Schwabe2023-02-09 17:37:05 +0100
committerGert Doering2023-02-14 14:13:14 +0100
commit9719393b7cf94d37f3706ca32c02433e8578599b (patch)
tree5c88b22c69263721d08df29faf410605ab87c392 /.github
parent6731314a82d1a3c76b5497749985ee20c0c7d8eb (diff)
downloadopenvpn-9719393b7cf94d37f3706ca32c02433e8578599b.zip
openvpn-9719393b7cf94d37f3706ca32c02433e8578599b.tar.gz
Add building unit tests with mingw to github actions
This runs each test in its own action since order of stderr and stdout is seemingly random in github action Windows output and this way at least tests outputs are grouped by test Patch v2: use -static-libgcc to avoid comping gcc runtime libraries. Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Selva Nair <selva.nair@gmail.com> Message-Id: <20230209163705.466173-1-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26204.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/build.yaml110
1 files changed, 108 insertions, 2 deletions
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 5888e91..699964f 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -55,9 +55,10 @@ jobs:
PKCS11_HELPER_VERSION: "1.29.0"
OPENSSL_VERSION: "${{ matrix.osslver }}"
TAP_WINDOWS_VERSION: "9.23.3"
+ CMOCKA_VERSION: "1.1.5"
steps:
- name: Install dependencies
- run: sudo apt update && sudo apt install -y mingw-w64 libtool automake autoconf man2html unzip
+ run: sudo apt update && sudo apt install -y mingw-w64 libtool automake autoconf man2html unzip cmake ninja-build build-essential wget
- name: Checkout OpenVPN
uses: actions/checkout@v3
with:
@@ -72,7 +73,7 @@ jobs:
uses: actions/cache@v3
with:
path: '~/mingw/'
- key: ${{ matrix.target }}-mingw-${{ matrix.osslver }}-${{ env.LZO_VERSION }}-${{ env.PKCS11_HELPER_VERSION }}-${{ env.TAP_WINDOWS_VERSION }}
+ key: ${{ matrix.target }}-mingw-${{ matrix.osslver }}-${{ env.LZO_VERSION }}-${{ env.PKCS11_HELPER_VERSION }}-${{ env.TAP_WINDOWS_VERSION }}--${{ env.CMOCKA_VERSION }}
# Repeating if: steps.cache.outputs.cache-hit != 'true'
# on every step for building dependencies is ugly but
@@ -84,12 +85,33 @@ jobs:
wget -c -P download-cache/ "https://build.openvpn.net/downloads/releases/tap-windows-${TAP_WINDOWS_VERSION}.zip"
wget -c -P download-cache/ "https://www.oberhumer.com/opensource/lzo/download/lzo-${LZO_VERSION}.tar.gz"
wget -c -P download-cache/ "https://github.com/OpenSC/pkcs11-helper/releases/download/pkcs11-helper-${PKCS11_HELPER_VERSION}/pkcs11-helper-${PKCS11_HELPER_VERSION}.tar.bz2"
+ wget -c -P download-cache/ "https://github.com/coreboot/cmocka/archive/refs/tags/cmocka-${CMOCKA_VERSION}.tar.gz"
tar jxf "download-cache/pkcs11-helper-${PKCS11_HELPER_VERSION}.tar.bz2"
wget -c -P download-cache/ "https://www.openssl.org/source/old/1.1.1/openssl-${OPENSSL_VERSION}.tar.gz" || wget -c -P download-cache/ "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz"
tar zxf "download-cache/openssl-${OPENSSL_VERSION}.tar.gz"
tar zxf "download-cache/lzo-${LZO_VERSION}.tar.gz"
+ tar zxf "download-cache/cmocka-${CMOCKA_VERSION}.tar.gz"
unzip download-cache/tap-windows-${TAP_WINDOWS_VERSION}.zip
+ - name: create cmocka build directory
+ if: steps.cache.outputs.cache-hit != 'true'
+ run: mkdir cmocka-build
+
+ - name: configure cmocka
+ if: steps.cache.outputs.cache-hit != 'true'
+ working-directory: "./cmocka-build"
+ run: cmake -GNinja -DCMAKE_C_COMPILER=${{ matrix.chost }}-gcc -DCMAKE_CXX_COMPILER=${{ matrix.chost }}-g++ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SHARED_LINKER_FLAGS=-static-libgcc -DCMAKE_PREFIX_PATH=${HOME}/mingw/opt/lib/pkgconfig/ -DCMAKE_INCLUDE_PATH=${HOME}/mingw/opt/lib/include -DCMAKE_LIBRARY_PATH=${HOME}/mingw/opt/lib -DCMAKE_INSTALL_PREFIX=${HOME}/mingw/opt/ ../cmocka-cmocka-${{ env.CMOCKA_VERSION }}
+
+ - name: build cmocka
+ if: steps.cache.outputs.cache-hit != 'true'
+ working-directory: "./cmocka-build"
+ run: ninja
+
+ - name: install cmocka
+ if: steps.cache.outputs.cache-hit != 'true'
+ working-directory: "./cmocka-build"
+ run: ninja install
+
- name: Configure OpenSSL
if: steps.cache.outputs.cache-hit != 'true'
run: ./Configure --cross-compile-prefix=${{ matrix.chost }}- shared ${{ matrix.target }} no-capieng --prefix="${HOME}/mingw/opt" --openssldir="${HOME}/mingw/opt" -static-libgcc
@@ -154,6 +176,90 @@ jobs:
- name: build OpenVPN
run: make -j3
working-directory: openvpn
+ - name: build OpenVPN unittests
+ run: make -j3 check
+ working-directory: openvpn
+
+ # We use multiple upload-artifact here, so it becomes a flat folder
+ # structure since we need the dlls on the same level as the binaries
+ - name: Archive cmocka/openssl/lzo dlls
+ uses: actions/upload-artifact@v3
+ with:
+ retention-days: 1
+ name: mingw-unittest-${{matrix.target}}-ossl${{ matrix.osslver }}-dlls
+ path: '~/mingw/opt/bin/*.dll'
+
+ # libtool puts some wrapper binaries in openvpn/tests/unit_tests/openvpn/
+ # and the real binaries in openvpn/tests/unit_tests/openvpn/.libs/
+ - name: Archive unittest artifacts
+ uses: actions/upload-artifact@v3
+ with:
+ retention-days: 1
+ name: mingw-unittest-${{matrix.target}}-ossl${{ matrix.osslver }}-tests
+ path: openvpn/tests/unit_tests/openvpn/.libs/*.exe
+
+ # Currently not used by the unit test but might in the future and also
+ # helpful if manually downloading and running openvpn.exe from a mingw
+ # build
+ - name: Archive openvpn binary
+ uses: actions/upload-artifact@v3
+ with:
+ retention-days: 1
+ name: mingw-unittest-${{matrix.target}}-ossl${{ matrix.osslver }}-tests
+ path: openvpn/src/openvpn/.libs/*.exe
+
+ mingw-unittest:
+ needs: [ mingw ]
+ strategy:
+ fail-fast: false
+ matrix:
+ osslver: [ 1.1.1q, 3.0.5 ]
+ target: [ mingw64, mingw ]
+
+ runs-on: windows-latest
+ name: "mingw unittests - ${{matrix.target}} - OSSL ${{ matrix.osslver }}"
+ steps:
+ - name: Retrieve mingw unittest dlls
+ uses: actions/download-artifact@v3
+ with:
+ name: mingw-unittest-${{matrix.target}}-ossl${{ matrix.osslver }}-dlls
+ path: unittests
+
+ - name: Retrieve mingw unittest
+ uses: actions/download-artifact@v3
+ with:
+ name: mingw-unittest-${{matrix.target}}-ossl${{ matrix.osslver }}-tests
+ path: unittests
+
+ - name: List unittests directory
+ run: "dir unittests"
+
+ - name: Run argvunit test
+ run: ./unittests/argv_testdriver.exe
+
+ - name: Run auth_tokenunit test
+ run: ./unittests/auth_token_testdriver.exe
+
+ - name: Run bufferunit test
+ run: ./unittests/buffer_testdriver.exe
+
+ - name: Run cryptounit test
+ run: ./unittests/crypto_testdriver.exe
+
+ - name: Run miscunit test
+ run: ./unittests/misc_testdriver.exe
+
+ - name: Run ncpunit test
+ run: ./unittests/ncp_testdriver.exe
+
+ - name: Run packet idunit test
+ run: ./unittests/packet_id_testdriver.exe
+
+ - name: Run pktunit test
+ run: ./unittests/pkt_testdriver.exe
+
+ - name: Run providerunit test
+ run: ./unittests/provider_testdriver.exe
ubuntu:
strategy: