2020 fail-fast : false
2121
2222 # Limit concurrent jobs for scheduling problem on GitHub's hosted runner pool.
23- max-parallel : 12
23+ max-parallel : 10
2424
2525 matrix :
2626 math :
3131 - " SPMATH=0 SPMATHALL=0 WOLFBOOT_SMALL_STACK=0"
3232 - " SPMATH=0 SPMATHALL=0 WOLFBOOT_SMALL_STACK=1"
3333 asym : [ed25519, ecc256, ecc384, ecc521, rsa2048, rsa3072, rsa4096, ed448]
34- hash : [sha256, sha384, sha3]
34+ hash : [sha256, sha384, sha3] # --sha256 for commandline, SHA256 for make
3535
3636 # See https://github.com/wolfSSL/wolfBoot/issues/614 regarding exclusions:
3737 exclude :
@@ -41,41 +41,104 @@ jobs:
4141 steps :
4242 - uses : actions/checkout@v4
4343 with :
44+ clean : true
4445 submodules : true
4546
46- - name : make clean
47+ - name : dist clean
4748 run : |
48- make keysclean && make -C tools/keytools clean && rm -f include/target.h
49+ # Ensure parallel build did not leave behind any debris
50+ make distclean
4951
5052 - name : Build test-lib
5153 env :
5254 shell : bash
53- ASYM : ${{ matrix.asym }}
55+ ASYM : ${{ matrix.asym }} # MAKE_SIGN in upper case
5456 HASH : ${{ matrix.hash }}
5557 MATH : ${{ matrix.math }}
5658 run : |
59+ # Test various library parameters
60+
61+ export MAKE_SIGN="${ASYM^^}"
62+ export MAKE_HASH="${HASH^^}"
63+ export MAKE_MATH='${{ matrix.math }}' # e.g., "SPMATH=1 WOLFBOOT_SMALL_STACK=1"
64+ export PRIVATE_KEY="wolfboot_signing_private_key.der"
65+
66+ echo "This MAKE_SIGN=$MAKE_SIGN"
67+ echo "This MAKE_HASH=$MAKE_HASH"
68+ echo "This MAKE_MATH=$MAKE_MATH"
69+
5770 # Sample build
5871 build_once() {
5972 # Convert asym and hash to upper case, optionally add additional param
60- make -j test-lib SIGN=${ASYM^^} HASH=${HASH^^} ${MATH} "$@"
73+ echo "Build test-lib..."
74+ echo "make -j1 test-lib SIGN=${MAKE_SIGN} HASH=${MAKE_HASH} ${MATH} \"$@\""
75+ make -j1 test-lib SIGN=${MAKE_SIGN} HASH=${MAKE_HASH} ${MATH} "$@"
6176 }
6277
6378 set -euo pipefail
6479
6580 # Get the reference config
6681 cp config/examples/library.config .config
6782
83+ # peek
84+ echo "Existing files?"
85+ if [ -f "src/keystore.c" ]; then
86+ echo "WARNING: Found unexpected src/keystore.c"
87+ fi
88+ if [ -f "include/target.h" ]; then
89+ echo "WARNING: Found unexpected include/target.h"
90+ fi
91+ if [ -f "keystore.der" ]; then
92+ echo "WARNING: Found unexpected keystore.der"
93+ fi
94+ if [ -f "wolfboot_signing_private_key.der" ]; then
95+ echo "WARNING: Found unexpected wolfboot_signing_private_key.der"
96+ fi
97+ if [ -f "./tools/keytools/keystore.der" ]; then
98+ echo "WARNING: Found unexpected ./tools/keytools/keystore.der"
99+ fi
100+ if [ -f "./tools/keytools/wolfboot_signing_private_key.der" ]; then
101+ echo "WARNING: Found unexpected ./tools/keytools/wolfboot_signing_private_key.der"
102+ fi
103+
68104 # Keytools
69- make keytools
70- ./tools/keytools/keygen --${ASYM} -g wolfboot_signing_private_key.der
105+ echo ""
106+ echo "make -j1 keytools SIGN=\"${MAKE_SIGN}\" HASH=\"${MAKE_HASH}\" $MATH"
107+ make -j1 keytools SIGN="${MAKE_SIGN}" HASH="${MAKE_HASH}" $MATH
108+
109+ # Generate keys
110+ echo ""
111+ echo "./tools/keytools/keygen --${ASYM} -g wolfboot_signing_private_key.der"
112+ ./tools/keytools/keygen --${ASYM} -g wolfboot_signing_private_key.der
113+
114+ # Force fresh files
115+ # peek
116+ echo "Existing files?"
117+ if [ -f "src/keystore.c" ]; then
118+ echo "Found unexpected src/keystore.c"
119+ fi
120+ if [ -f "include/target.h" ]; then
121+ echo "Found unexpected include/target.h"
122+ fi
123+ if [ -f "keystore.der" ]; then
124+ echo "Found unexpected keystore.der"
125+ fi
126+ if [ -f "wolfboot_signing_private_key.der" ]; then
127+ echo "Found unexpected wolfboot_signing_private_key.der"
128+ fi
71129
72130 # Sign
131+ echo ""
73132 echo "Test" > test.bin
74- ./tools/keytools/sign --${ASYM} --${HASH} test.bin wolfboot_signing_private_key.der 1
133+ echo "Sign test.bin"
134+ echo "./tools/keytools/sign --${ASYM} --${HASH} test.bin wolfboot_signing_private_key.der 1"
135+ ./tools/keytools/sign --${ASYM} --${HASH} test.bin wolfboot_signing_private_key.der 1
75136
76137 # First attempt
77138 if build_once >build.out 2>build.err; then
78139 echo "Success on first attempt, WOLFBOOT_HUGE_STACK not applied."
140+ cat build.out
141+ cat build.err
79142 exit 0
80143 fi
81144
@@ -90,12 +153,16 @@ jobs:
90153 build_once WOLFBOOT_HUGE_STACK=1
91154 else
92155 echo "Build failed for another reason:"
156+ cat build.out
93157 cat build.err
94158 exit 1
95159 fi
96160
97161 - name : Run test-lib
98162 run : |
163+ # Check test_v1_signed.bin
164+
165+ echo "./test-lib test_v1_signed.bin"
99166 ./test-lib test_v1_signed.bin
100167 ./test-lib test_v1_signed.bin 2>&1 | grep "Firmware Valid"
101168
@@ -104,5 +171,25 @@ jobs:
104171 # Corrupt signed binary
105172 truncate -s -1 test_v1_signed.bin
106173 echo "A" >> test_v1_signed.bin
107- ./test-lib test_v1_signed.bin
108- ./test-lib test_v1_signed.bin 2>&1 | grep "Failure"
174+
175+ # Run once, capture output and status
176+ set +e
177+ output=$(./test-lib test_v1_signed.bin 2>&1)
178+ status=$?
179+ set -e
180+
181+ echo "$output"
182+
183+ # Must have failed (non-zero exit)
184+ if [ $status -eq 0 ]; then
185+ echo "Expected failure, but exit code was 0"
186+ exit 1
187+ fi
188+
189+ # Must include the expected Failure message
190+ echo "$output" | grep -F "Failure" >/dev/null || {
191+ echo "Expected 'Failure' not found in output"
192+ exit 1
193+ }
194+
195+ echo "Got expected non-zero exit and 'Failure' message."
0 commit comments