Skip to content

Commit 992a56c

Browse files
committed
Improve CI tests and code cleanups
1 parent 0609ee8 commit 992a56c

File tree

9 files changed

+302
-566
lines changed

9 files changed

+302
-566
lines changed

.github/workflows/fwtpm-test.yml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,7 @@ jobs:
138138
build_only: true
139139
make_cflags: "-Wall -Wextra -Wpedantic -Werror -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wformat=2"
140140

141-
# AddressSanitizer: fwTPM server + examples
142-
- name: fwtpm-asan
143-
wolftpm_config: --enable-fwtpm --enable-swtpm --enable-debug
144-
wolfssl_config: --enable-wolftpm --enable-pkcallbacks --enable-keygen
145-
build_only: false
146-
extra_cflags: "-fsanitize=address -fno-omit-frame-pointer -g -O1"
147-
extra_ldflags: "-fsanitize=address"
148-
sanitizer: asan
149-
150-
# UndefinedBehaviorSanitizer: fwTPM server + examples
151-
- name: fwtpm-ubsan
152-
wolftpm_config: --enable-fwtpm --enable-swtpm --enable-debug
153-
wolfssl_config: --enable-wolftpm --enable-pkcallbacks --enable-keygen
154-
build_only: false
155-
extra_cflags: "-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer -g"
156-
extra_ldflags: "-fsanitize=undefined"
157-
sanitizer: ubsan
141+
# Note: ASan / UBSan / LeakSan coverage moved to sanitizer.yml
158142

159143
steps:
160144
- name: Checkout wolfTPM
@@ -172,10 +156,6 @@ jobs:
172156
sudo apt-get update
173157
sudo apt-get install -y tpm2-tools libtss2-tcti-mssim0
174158
175-
- name: ASLR workaround (sanitizers)
176-
if: ${{ matrix.sanitizer }}
177-
run: sudo sysctl vm.mmap_rnd_bits=28
178-
179159
- name: Build wolfSSL
180160
working-directory: ./wolfssl
181161
run: |
@@ -220,8 +200,6 @@ jobs:
220200
if: ${{ !matrix.build_only }}
221201
env:
222202
WOLFSSL_PATH: ./wolfssl
223-
ASAN_OPTIONS: ${{ matrix.sanitizer == 'asan' && 'detect_leaks=0' || '' }}
224-
UBSAN_OPTIONS: ${{ matrix.sanitizer == 'ubsan' && 'halt_on_error=1:print_stacktrace=1' || '' }}
225203
run: make check
226204

227205
- name: Upload failure logs

.github/workflows/sanitizer.yml

Lines changed: 34 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,22 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
build_wolfssl:
15-
name: Build wolfSSL
16-
runs-on: ubuntu-latest
17-
timeout-minutes: 5
18-
steps:
19-
- name: Checkout wolfSSL
20-
uses: actions/checkout@v4
21-
with:
22-
repository: wolfssl/wolfssl
23-
path: wolfssl
24-
25-
- name: Build wolfSSL
26-
working-directory: ./wolfssl
27-
run: |
28-
./autogen.sh
29-
./configure --enable-wolftpm --enable-pkcallbacks --enable-keygen \
30-
CFLAGS="-DWC_RSA_NO_PADDING"
31-
make -j$(nproc)
32-
sudo make install
33-
sudo ldconfig
34-
35-
- name: tar build-dir
36-
run: tar -zcf wolfssl-install.tgz /usr/local/lib/libwolfssl* /usr/local/include/wolfssl
37-
38-
- name: Upload built lib
39-
uses: actions/upload-artifact@v4
40-
with:
41-
name: wolfssl-install
42-
path: wolfssl-install.tgz
43-
retention-days: 5
44-
4514
sanitizer_test:
4615
name: ${{ matrix.name }}
4716
runs-on: ubuntu-latest
48-
timeout-minutes: 10
49-
needs: build_wolfssl
17+
timeout-minutes: 30
5018
strategy:
5119
fail-fast: false
5220
matrix:
5321
include:
5422
- name: "ASan"
5523
cflags: "-fsanitize=address -fno-omit-frame-pointer -g -O1"
5624
ldflags: "-fsanitize=address"
25+
asan_options: "detect_leaks=0"
5726
- name: "UBSan"
5827
cflags: "-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer -g"
5928
ldflags: "-fsanitize=undefined"
29+
ubsan_options: "halt_on_error=1:print_stacktrace=1"
6030
- name: "LeakSan"
6131
cflags: "-fsanitize=leak -fno-omit-frame-pointer -g"
6232
ldflags: "-fsanitize=leak"
@@ -68,37 +38,43 @@ jobs:
6838
- name: Checkout wolfTPM
6939
uses: actions/checkout@v4
7040

71-
- name: Download wolfSSL
72-
uses: actions/download-artifact@v4
73-
with:
74-
name: wolfssl-install
75-
76-
- name: Install wolfSSL
77-
run: |
78-
sudo tar -xzf wolfssl-install.tgz -C /
79-
sudo ldconfig
80-
81-
- name: Setup ibmswtpm2
41+
- name: Checkout wolfSSL
8242
uses: actions/checkout@v4
8343
with:
84-
repository: kgoldman/ibmswtpm2
85-
path: ibmswtpm2
44+
repository: wolfssl/wolfssl
45+
path: wolfssl
8646

87-
- name: Build and start TPM simulator
88-
working-directory: ./ibmswtpm2/src
47+
- name: Install tpm2-tools
8948
run: |
90-
make -j$(nproc)
91-
./tpm_server &
92-
sleep 2
49+
sudo apt-get update
50+
sudo apt-get install -y tpm2-tools libtss2-tcti-mssim0
9351
94-
- name: Build wolfTPM with ${{ matrix.name }}
52+
- name: Build and install wolfSSL with ${{ matrix.name }}
53+
working-directory: ./wolfssl
9554
run: |
9655
./autogen.sh
97-
./configure --enable-swtpm --disable-fwtpm \
98-
CFLAGS="${{ matrix.cflags }}" LDFLAGS="${{ matrix.ldflags }}"
99-
make -j$(nproc)
56+
./configure --enable-wolftpm --enable-pkcallbacks --enable-keygen \
57+
--prefix=/tmp/wolfssl-install \
58+
CFLAGS="-DWC_RSA_NO_PADDING ${{ matrix.cflags }}" \
59+
LDFLAGS="${{ matrix.ldflags }}"
60+
make
61+
make install
10062
101-
- name: Run tests
63+
- name: Build wolfTPM with fwTPM + ${{ matrix.name }}
64+
run: |
65+
./autogen.sh
66+
./configure --enable-fwtpm --enable-swtpm --enable-debug \
67+
--with-wolfcrypt=/tmp/wolfssl-install \
68+
CFLAGS="${{ matrix.cflags }}" \
69+
LDFLAGS="${{ matrix.ldflags }}"
70+
make
71+
72+
- name: Run tests (make check)
73+
env:
74+
WOLFSSL_PATH: /tmp/wolfssl-install
75+
LD_LIBRARY_PATH: /tmp/wolfssl-install/lib
76+
ASAN_OPTIONS: ${{ matrix.asan_options }}
77+
UBSAN_OPTIONS: ${{ matrix.ubsan_options }}
10278
run: make check
10379

10480
- name: Upload failure logs
@@ -107,7 +83,8 @@ jobs:
10783
with:
10884
name: wolftpm-${{ matrix.name }}-logs
10985
path: |
110-
run.out
86+
/tmp/fwtpm_check_*.log
11187
test-suite.log
88+
tests/*.log
11289
config.log
11390
retention-days: 5

.github/workflows/seal-test.yml

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- 'examples/nvram/seal_nv.c'
99
- 'examples/nvram/nvram.h'
1010
- 'src/tpm2_wrap.c'
11+
- 'src/fwtpm/**'
1112
- 'wolftpm/tpm2_wrap.h'
1213
pull_request:
1314
branches: [ '*' ]
@@ -16,6 +17,7 @@ on:
1617
- 'examples/nvram/seal_nv.c'
1718
- 'examples/nvram/nvram.h'
1819
- 'src/tpm2_wrap.c'
20+
- 'src/fwtpm/**'
1921
- 'wolftpm/tpm2_wrap.h'
2022

2123
jobs:
@@ -36,36 +38,51 @@ jobs:
3638
working-directory: ./wolfssl
3739
run: |
3840
./autogen.sh
39-
./configure --enable-wolftpm --enable-pkcallbacks
40-
make -j
41+
./configure --enable-wolftpm --enable-pkcallbacks --enable-keygen \
42+
CFLAGS="-DWC_RSA_NO_PADDING"
43+
make
4144
sudo make install
4245
sudo ldconfig
4346
44-
- name: Checkout ibmswtpm2
45-
uses: actions/checkout@v4
46-
with:
47-
repository: kgoldman/ibmswtpm2
48-
path: ibmswtpm2
49-
50-
- name: Build and start SWTPM
51-
working-directory: ./ibmswtpm2/src
47+
- name: Build wolfTPM with fwTPM
5248
run: |
49+
./autogen.sh
50+
./configure --enable-fwtpm --enable-swtpm --enable-debug
5351
make
54-
./tpm_server &
5552
56-
- name: Build wolfTPM
53+
- name: Start fwtpm_server
5754
run: |
58-
./autogen.sh
59-
./configure --enable-swtpm --enable-debug --disable-fwtpm
60-
make -j
55+
rm -f fwtpm_nv.bin
56+
./src/fwtpm/fwtpm_server > /tmp/seal_fwtpm.log 2>&1 &
57+
echo $! > /tmp/seal_fwtpm.pid
58+
for i in $(seq 1 500); do
59+
ss -tln 2>/dev/null | grep -q ':2321 ' && break
60+
sleep 0.01
61+
done
62+
if ! ss -tln 2>/dev/null | grep -q ':2321 '; then
63+
echo "fwtpm_server failed to start"
64+
cat /tmp/seal_fwtpm.log
65+
exit 1
66+
fi
6167
6268
- name: Run seal tests
6369
run: bash examples/seal/seal_test.sh
6470

71+
- name: Stop fwtpm_server
72+
if: always()
73+
run: |
74+
if [ -f /tmp/seal_fwtpm.pid ]; then
75+
kill "$(cat /tmp/seal_fwtpm.pid)" 2>/dev/null || true
76+
rm -f /tmp/seal_fwtpm.pid
77+
fi
78+
rm -f fwtpm_nv.bin
79+
6580
- name: Upload failure logs
6681
if: failure()
6782
uses: actions/upload-artifact@v4
6883
with:
6984
name: seal-test-logs
70-
path: seal_test.log
85+
path: |
86+
seal_test.log
87+
/tmp/seal_fwtpm.log
7188
retention-days: 5

docs/FWTPM.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,13 +596,12 @@ See [src/fwtpm/README.md](../src/fwtpm/README.md) for the full CI test matrix
596596
and test script usage. Quick reference:
597597

598598
```sh
599-
scripts/fwtpm_build_test.sh --quick # Build + examples
600-
scripts/fwtpm_build_test.sh --all # Build + examples + make check + tpm2-tools
601-
scripts/tpm2_tools_test.sh # tpm2-tools only (311 tests)
599+
make check # Build + unit.test + run_examples.sh + tpm2-tools
600+
scripts/tpm2_tools_test.sh # tpm2-tools only (311 tests)
602601
```
603602

604-
Test scripts manage server lifecycle automatically -- do not start
605-
`fwtpm_server` manually before running them.
603+
`make check` runs `tests/fwtpm_check.sh`, which starts and stops
604+
`fwtpm_server` automatically -- do not start it manually.
606605

607606

608607
## API Reference

0 commit comments

Comments
 (0)