Skip to content

Commit b48ab33

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

3 files changed

Lines changed: 196 additions & 1 deletion

File tree

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
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: /tmp/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+
cd /tmp
64+
git clone https://github.com/wolfSSL/wolfssl.git --branch ${{ env.WOLFSSL_VERSION }} --depth 1
65+
mv wolfssl wolfssl-${{ matrix.alpine_arch }}
66+
cd wolfssl-${{ matrix.alpine_arch }}
67+
./autogen.sh
68+
./configure --enable-cryptocb --enable-aescfb --enable-rsapss --enable-keygen --enable-pwdbased --enable-scrypt --enable-md5 --enable-sha224 --enable-sha3 \
69+
C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT"
70+
make
71+
shell: alpine.sh {0}
72+
73+
- name: Install wolfSSL
74+
run: |
75+
cd /tmp/wolfssl-${{ matrix.alpine_arch }}
76+
echo "Starting wolfSSL installation..."
77+
LDCONFIG=: make install
78+
echo "wolfSSL installation completed successfully"
79+
ls -la /usr/local/lib/libwolfssl* || echo "No wolfSSL libraries found"
80+
echo "/usr/local/lib" > /etc/ld-musl-$(uname -m).path
81+
shell: alpine.sh --root {0}
82+
83+
- name: Cache TPM components
84+
if: matrix.tpm == 'with-tpm'
85+
id: cache-tpm
86+
uses: actions/cache@v4
87+
with:
88+
path: |
89+
/tmp/ibmswtpm2-${{ matrix.alpine_arch }}
90+
/tmp/wolftpm-${{ matrix.alpine_arch }}
91+
key: alpine-tpm-components-${{ matrix.alpine_arch }}-v1
92+
93+
- name: Setup IBM Software TPM
94+
if: matrix.tpm == 'with-tpm' && steps.cache-tpm.outputs.cache-hit != 'true'
95+
run: |
96+
echo "=== Building IBM Software TPM for ${{ matrix.alpine_arch }} ==="
97+
cd /tmp
98+
git clone https://github.com/kgoldman/ibmswtpm2.git ibmswtpm2-${{ matrix.alpine_arch }}
99+
cd ibmswtpm2-${{ matrix.alpine_arch }}/src
100+
make
101+
shell: alpine.sh {0}
102+
103+
- name: Build wolfTPM
104+
if: matrix.tpm == 'with-tpm' && steps.cache-tpm.outputs.cache-hit != 'true'
105+
run: |
106+
echo "=== Building wolfTPM for ${{ matrix.alpine_arch }} ==="
107+
cd /tmp
108+
git clone https://github.com/wolfSSL/wolftpm.git wolftpm-${{ matrix.alpine_arch }}
109+
cd wolftpm-${{ matrix.alpine_arch }}
110+
./autogen.sh
111+
./configure --enable-swtpm --enable-debug
112+
make
113+
shell: alpine.sh {0}
114+
115+
- name: Install wolfTPM
116+
if: matrix.tpm == 'with-tpm'
117+
run: |
118+
cd /tmp/wolftpm-${{ matrix.alpine_arch }}
119+
echo "Starting wolfTPM installation..."
120+
LDCONFIG=: make install
121+
echo "wolfTPM installation completed successfully"
122+
ls -la /usr/local/lib/libwolftpm* || echo "No wolfTPM libraries found"
123+
echo "/usr/local/lib" > /etc/ld-musl-$(uname -m).path
124+
shell: alpine.sh --root {0}
125+
126+
- name: Start TPM Server
127+
if: matrix.tpm == 'with-tpm'
128+
run: |
129+
echo "=== Starting TPM server ==="
130+
cd /tmp/ibmswtpm2-${{ matrix.alpine_arch }}/src
131+
./tpm_server &
132+
sleep 2
133+
echo "TPM server started"
134+
shell: alpine.sh {0}
135+
136+
- name: Build wolfPKCS11 (without TPM)
137+
if: matrix.tpm == 'without-tpm'
138+
run: |
139+
echo "=== Building wolfPKCS11 without TPM for ${{ matrix.arch }} ==="
140+
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
141+
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
142+
echo "Running autogen.sh..."
143+
./autogen.sh
144+
echo "Running configure..."
145+
./configure
146+
make
147+
shell: alpine.sh {0}
148+
149+
- name: Build wolfPKCS11 (with TPM)
150+
if: matrix.tpm == 'with-tpm'
151+
run: |
152+
echo "=== Building wolfPKCS11 with TPM for ${{ matrix.arch }} ==="
153+
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
154+
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
155+
echo "Running autogen.sh..."
156+
./autogen.sh
157+
echo "Running configure..."
158+
./configure --enable-singlethreaded --enable-wolftpm --disable-dh C_EXTRA_FLAGS="-DWOLFPKCS11_TPM_STORE"
159+
make
160+
shell: alpine.sh {0}
161+
162+
- name: Run tests (without TPM)
163+
if: matrix.tpm == 'without-tpm'
164+
run: |
165+
echo "=== Running tests without TPM on ${{ matrix.arch }} ==="
166+
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
167+
make test
168+
shell: alpine.sh {0}
169+
170+
- name: Run tests (with TPM)
171+
if: matrix.tpm == 'with-tpm'
172+
run: |
173+
echo "=== Running TPM tests on ${{ matrix.arch }} ==="
174+
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
175+
./tests/pkcs11str && ./tests/pkcs11test && ./tests/rsa_session_persistence_test
176+
shell: alpine.sh {0}
177+
178+
- name: Cleanup TPM server
179+
if: always() && matrix.tpm == 'with-tpm'
180+
run: |
181+
echo "=== Cleaning up TPM server ==="
182+
pkill -f tpm_server || echo "TPM server was not running"
183+
shell: alpine.sh {0}
184+
185+
- name: Upload failure logs
186+
if: failure() || cancelled()
187+
uses: actions/upload-artifact@v4
188+
with:
189+
name: alpine-${{ matrix.arch }}-${{ matrix.tpm }}-failure-logs
190+
path: |
191+
test-suite.log
192+
config.log
193+
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
@@ -13708,6 +13708,7 @@ static TEST_FUNC testFunc[] = {
1370813708
#ifndef NOSHA256
1370913709
PKCS11TEST_FUNC_SESS_DECL(test_digest),
1371013710
#endif
13711+
#ifdef WOLFSSL_SHA3
1371113712
#ifndef WOLFSSL_NOSHA3_224
1371213713
PKCS11TEST_FUNC_SESS_DECL(test_digest_sha3_224),
1371313714
#endif
@@ -13720,6 +13721,7 @@ static TEST_FUNC testFunc[] = {
1372013721
#ifndef WOLFSSL_NOSHA3_512
1372113722
PKCS11TEST_FUNC_SESS_DECL(test_digest_sha3_512),
1372213723
#endif
13724+
#endif
1372313725
#ifndef NO_HMAC
1372413726
#ifndef NO_MD5
1372513727
PKCS11TEST_FUNC_SESS_DECL(test_hmac_md5),

0 commit comments

Comments
 (0)