Skip to content

Commit d740b19

Browse files
committed
Add multiarchitecture testing
Use Alpine to do: * x86 (32bit) * armv7 * armhf
1 parent 28d1b9c commit d740b19

File tree

3 files changed

+193
-1
lines changed

3 files changed

+193
-1
lines changed
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
name: wolfPKCS11 Alpine Architecture Tests
2+
3+
on:
4+
push:
5+
branches: [ 'master', 'main' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
9+
env:
10+
WOLFSSL_VERSION: v5.8.0-stable
11+
12+
jobs:
13+
alpine-architecture-tests:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
arch: [x86, armhf, armv7]
19+
tpm: [with-tpm, without-tpm]
20+
include:
21+
- arch: x86
22+
alpine_arch: x86
23+
- arch: armhf
24+
alpine_arch: armhf
25+
- arch: armv7
26+
alpine_arch: armv7
27+
28+
name: Alpine ${{ matrix.arch }} (${{ matrix.tpm }})
29+
30+
steps:
31+
- name: Checkout wolfPKCS11
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Alpine Linux ${{ matrix.alpine_arch }}
35+
uses: jirutka/setup-alpine@v1
36+
with:
37+
arch: ${{ matrix.alpine_arch }}
38+
branch: latest-stable
39+
packages: >
40+
build-base
41+
autoconf
42+
automake
43+
libtool
44+
git
45+
pkgconfig
46+
linux-headers
47+
musl-dev
48+
openssl-dev
49+
bash
50+
shell-name: alpine.sh
51+
52+
- name: Cache wolfSSL
53+
id: cache-wolfssl
54+
uses: actions/cache@v4
55+
with:
56+
path: wolfssl-${{ matrix.alpine_arch }}
57+
key: alpine-wolfssl-${{ env.WOLFSSL_VERSION }}-${{ matrix.alpine_arch }}
58+
59+
- name: Build wolfSSL
60+
if: steps.cache-wolfssl.outputs.cache-hit != 'true'
61+
run: |
62+
echo "=== Building wolfSSL for ${{ matrix.alpine_arch }} ==="
63+
git clone https://github.com/wolfSSL/wolfssl.git --branch ${{ env.WOLFSSL_VERSION }} --depth 1
64+
mv wolfssl wolfssl-${{ matrix.alpine_arch }}
65+
cd wolfssl-${{ matrix.alpine_arch }}
66+
./autogen.sh
67+
./configure --enable-cryptocb --enable-aescfb --enable-rsapss --enable-keygen --enable-pwdbased --enable-scrypt --enable-md5 --enable-sha224 --enable-sha3 \
68+
C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT"
69+
make
70+
shell: alpine.sh {0}
71+
72+
- name: Install wolfSSL
73+
run: |
74+
cd wolfssl-${{ matrix.alpine_arch }}
75+
echo "Starting wolfSSL installation..."
76+
LDCONFIG=: make install
77+
echo "wolfSSL installation completed successfully"
78+
ls -la /usr/local/lib/libwolfssl* || echo "No wolfSSL libraries found"
79+
echo "/usr/local/lib" > /etc/ld-musl-$(uname -m).path
80+
shell: alpine.sh --root {0}
81+
82+
- name: Cache TPM components
83+
if: matrix.tpm == 'with-tpm'
84+
id: cache-tpm
85+
uses: actions/cache@v4
86+
with:
87+
path: |
88+
ibmswtpm2-${{ matrix.alpine_arch }}
89+
wolftpm-${{ matrix.alpine_arch }}
90+
key: alpine-tpm-components-${{ matrix.alpine_arch }}-v1
91+
92+
- name: Setup IBM Software TPM
93+
if: matrix.tpm == 'with-tpm' && steps.cache-tpm.outputs.cache-hit != 'true'
94+
run: |
95+
echo "=== Building IBM Software TPM for ${{ matrix.alpine_arch }} ==="
96+
git clone https://github.com/kgoldman/ibmswtpm2.git ibmswtpm2-${{ matrix.alpine_arch }}
97+
cd ibmswtpm2-${{ matrix.alpine_arch }}/src
98+
make
99+
shell: alpine.sh {0}
100+
101+
- name: Build wolfTPM
102+
if: matrix.tpm == 'with-tpm' && steps.cache-tpm.outputs.cache-hit != 'true'
103+
run: |
104+
echo "=== Building wolfTPM for ${{ matrix.alpine_arch }} ==="
105+
git clone https://github.com/wolfSSL/wolftpm.git wolftpm-${{ matrix.alpine_arch }}
106+
cd wolftpm-${{ matrix.alpine_arch }}
107+
./autogen.sh
108+
./configure --enable-swtpm --enable-debug
109+
make
110+
shell: alpine.sh {0}
111+
112+
- name: Install wolfTPM
113+
if: matrix.tpm == 'with-tpm'
114+
run: |
115+
cd wolftpm-${{ matrix.alpine_arch }}
116+
echo "Starting wolfTPM installation..."
117+
LDCONFIG=: make install
118+
echo "wolfTPM installation completed successfully"
119+
ls -la /usr/local/lib/libwolftpm* || echo "No wolfTPM libraries found"
120+
echo "/usr/local/lib" > /etc/ld-musl-$(uname -m).path
121+
shell: alpine.sh --root {0}
122+
123+
- name: Start TPM Server
124+
if: matrix.tpm == 'with-tpm'
125+
run: |
126+
echo "=== Starting TPM server ==="
127+
cd ibmswtpm2-${{ matrix.alpine_arch }}/src
128+
./tpm_server &
129+
sleep 2
130+
echo "TPM server started"
131+
shell: alpine.sh {0}
132+
133+
- name: Build wolfPKCS11 (without TPM)
134+
if: matrix.tpm == 'without-tpm'
135+
run: |
136+
echo "=== Building wolfPKCS11 without TPM for ${{ matrix.arch }} ==="
137+
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
138+
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
139+
echo "Running autogen.sh..."
140+
./autogen.sh
141+
echo "Running configure..."
142+
./configure
143+
make
144+
shell: alpine.sh {0}
145+
146+
- name: Build wolfPKCS11 (with TPM)
147+
if: matrix.tpm == 'with-tpm'
148+
run: |
149+
echo "=== Building wolfPKCS11 with TPM for ${{ matrix.arch }} ==="
150+
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
151+
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
152+
echo "Running autogen.sh..."
153+
./autogen.sh
154+
echo "Running configure..."
155+
./configure --enable-singlethreaded --enable-wolftpm --disable-dh C_EXTRA_FLAGS="-DWOLFPKCS11_TPM_STORE"
156+
make
157+
shell: alpine.sh {0}
158+
159+
- name: Run tests (without TPM)
160+
if: matrix.tpm == 'without-tpm'
161+
run: |
162+
echo "=== Running tests without TPM on ${{ matrix.arch }} ==="
163+
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
164+
make test
165+
shell: alpine.sh {0}
166+
167+
- name: Run tests (with TPM)
168+
if: matrix.tpm == 'with-tpm'
169+
run: |
170+
echo "=== Running TPM tests on ${{ matrix.arch }} ==="
171+
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
172+
./tests/pkcs11str && ./tests/pkcs11test && ./tests/rsa_session_persistence_test
173+
shell: alpine.sh {0}
174+
175+
- name: Cleanup TPM server
176+
if: always() && matrix.tpm == 'with-tpm'
177+
run: |
178+
echo "=== Cleaning up TPM server ==="
179+
pkill -f tpm_server || echo "TPM server was not running"
180+
shell: alpine.sh {0}
181+
182+
- name: Upload failure logs
183+
if: failure() || cancelled()
184+
uses: actions/upload-artifact@v4
185+
with:
186+
name: alpine-${{ matrix.arch }}-${{ matrix.tpm }}-failure-logs
187+
path: |
188+
test-suite.log
189+
config.log
190+
retention-days: 5

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ AC_CONFIG_AUX_DIR([build-aux])
1919
CFLAGS="$CFLAGS $C_EXTRA_FLAGS $C_FLAGS"
2020

2121
# Test ar for the "U" option. Should be checked before the libtool macros.
22-
xxx_ar_flags=$((ar --help) 2>&1)
22+
xxx_ar_flags=$(ar --help 2>&1)
2323
AS_CASE([$xxx_ar_flags],[*'use actual timestamps and uids/gids'*],[: ${AR_FLAGS="Ucru"}])
2424

2525
AC_CANONICAL_HOST

tests/pkcs11test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13721,6 +13721,7 @@ static TEST_FUNC testFunc[] = {
1372113721
#ifndef NOSHA256
1372213722
PKCS11TEST_FUNC_SESS_DECL(test_digest),
1372313723
#endif
13724+
#ifdef WOLFSSL_SHA3
1372413725
#ifndef WOLFSSL_NOSHA3_224
1372513726
PKCS11TEST_FUNC_SESS_DECL(test_digest_sha3_224),
1372613727
#endif
@@ -13733,6 +13734,7 @@ static TEST_FUNC testFunc[] = {
1373313734
#ifndef WOLFSSL_NOSHA3_512
1373413735
PKCS11TEST_FUNC_SESS_DECL(test_digest_sha3_512),
1373513736
#endif
13737+
#endif
1373613738
#ifndef NO_HMAC
1373713739
#ifndef NO_MD5
1373813740
PKCS11TEST_FUNC_SESS_DECL(test_hmac_md5),

0 commit comments

Comments
 (0)