4141 steps :
4242 - uses : actions/checkout@v4
4343 with :
44+ clean : true
4445 submodules : true
4546
4647 - name : make clean
@@ -54,28 +55,89 @@ jobs:
5455 HASH : ${{ matrix.hash }}
5556 MATH : ${{ matrix.math }}
5657 run : |
58+ # Test various library parameters
59+
60+ export MAKE_SIGN="${ASYM^^}"
61+ export MAKE_HASH="${HASH^^}"
62+ export MAKE_MATH='${{ matrix.math }}' # e.g., "SPMATH=1 WOLFBOOT_SMALL_STACK=1"
63+ export PRIVATE_KEY="wolfboot_signing_private_key.der"
64+
65+ echo "This MAKE_SIGN=$MAKE_SIGN"
66+ echo "This MAKE_HASH=$MAKE_HASH"
67+ echo "This MAKE_MATH=$MAKE_MATH"
68+
5769 # Sample build
5870 build_once() {
5971 # Convert asym and hash to upper case, optionally add additional param
60- make -j test-lib SIGN=${ASYM^^} HASH=${HASH^^} ${MATH} "$@"
72+ echo "Build test-lib..."
73+ echo "make -j1 test-lib SIGN=${MAKE_SIGN} HASH=${MAKE_HASH} ${MATH} \"$@\""
74+ make -j1 test-lib SIGN=${MAKE_SIGN} HASH=${MAKE_HASH} ${MATH} "$@"
6175 }
6276
6377 set -euo pipefail
6478
6579 # Get the reference config
6680 cp config/examples/library.config .config
6781
82+ # peek
83+ echo "Existing files?"
84+ if [ -f "src/keystore.c" ]; then
85+ echo "WARNING: Found unexpected src/keystore.c"
86+ fi
87+ if [ -f "include/target.h" ]; then
88+ echo "WARNING: Found unexpected include/target.h"
89+ fi
90+ if [ -f "keystore.der" ]; then
91+ echo "WARNING: Found unexpected keystore.der"
92+ fi
93+ if [ -f "wolfboot_signing_private_key.der" ]; then
94+ echo "WARNING: Found unexpected wolfboot_signing_private_key.der"
95+ fi
96+ if [ -f "./tools/keytools/keystore.der" ]; then
97+ echo "WARNING: Found unexpected ./tools/keytools/keystore.der"
98+ fi
99+ if [ -f "./tools/keytools/wolfboot_signing_private_key.der" ]; then
100+ echo "WARNING: Found unexpected ./tools/keytools/wolfboot_signing_private_key.der"
101+ fi
102+
68103 # Keytools
69- make keytools
70- ./tools/keytools/keygen --${ASYM} -g wolfboot_signing_private_key.der
104+ echo ""
105+ echo "make -j1 keytools SIGN=\"${MAKE_SIGN}\" HASH=\"${MAKE_HASH}\" $MATH"
106+ make -j1 keytools SIGN="${MAKE_SIGN}" HASH="${MAKE_HASH}" $MATH
107+
108+ # Generate keys
109+ echo ""
110+ echo "./tools/keytools/keygen --${ASYM} -g wolfboot_signing_private_key.der"
111+ ./tools/keytools/keygen --${ASYM} -g wolfboot_signing_private_key.der
112+
113+ # Force fresh files
114+ # peek
115+ echo "Existing files?"
116+ if [ -f "src/keystore.c" ]; then
117+ echo "Found unexpected src/keystore.c"
118+ fi
119+ if [ -f "include/target.h" ]; then
120+ echo "Found unexpected include/target.h"
121+ fi
122+ if [ -f "keystore.der" ]; then
123+ echo "Found unexpected keystore.der"
124+ fi
125+ if [ -f "wolfboot_signing_private_key.der" ]; then
126+ echo "Found unexpected wolfboot_signing_private_key.der"
127+ fi
71128
72129 # Sign
130+ echo ""
73131 echo "Test" > test.bin
74- ./tools/keytools/sign --${ASYM} --${HASH} test.bin wolfboot_signing_private_key.der 1
132+ echo "Sign test.bin"
133+ echo "./tools/keytools/sign --${ASYM} --${HASH} test.bin wolfboot_signing_private_key.der 1"
134+ ./tools/keytools/sign --${ASYM} --${HASH} test.bin wolfboot_signing_private_key.der 1
75135
76136 # First attempt
77137 if build_once >build.out 2>build.err; then
78138 echo "Success on first attempt, WOLFBOOT_HUGE_STACK not applied."
139+ cat build.out
140+ cat build.err
79141 exit 0
80142 fi
81143
@@ -90,12 +152,16 @@ jobs:
90152 build_once WOLFBOOT_HUGE_STACK=1
91153 else
92154 echo "Build failed for another reason:"
155+ cat build.out
93156 cat build.err
94157 exit 1
95158 fi
96159
97160 - name : Run test-lib
98161 run : |
162+ # Check test_v1_signed.bin
163+
164+ echo "./test-lib test_v1_signed.bin"
99165 ./test-lib test_v1_signed.bin
100166 ./test-lib test_v1_signed.bin 2>&1 | grep "Firmware Valid"
101167
@@ -104,5 +170,25 @@ jobs:
104170 # Corrupt signed binary
105171 truncate -s -1 test_v1_signed.bin
106172 echo "A" >> test_v1_signed.bin
107- ./test-lib test_v1_signed.bin
108- ./test-lib test_v1_signed.bin 2>&1 | grep "Failure"
173+
174+ # Run once, capture output and status
175+ set +e
176+ output=$(./test-lib test_v1_signed.bin 2>&1)
177+ status=$?
178+ set -e
179+
180+ echo "$output"
181+
182+ # Must have failed (non-zero exit)
183+ if [ $status -eq 0 ]; then
184+ echo "Expected failure, but exit code was 0"
185+ exit 1
186+ fi
187+
188+ # Must include the expected Failure message
189+ echo "$output" | grep -F "Failure" >/dev/null || {
190+ echo "Expected 'Failure' not found in output"
191+ exit 1
192+ }
193+
194+ echo "Got expected non-zero exit and 'Failure' message."
0 commit comments