Skip to content

Commit b896f5b

Browse files
authored
Merge pull request #121 from aidangarske/simple-WPFF-workflow
Inject `WOLFPROV_FORCE_FAIL=1` after we build provider
2 parents 6f8b5bc + 4410c1e commit b896f5b

File tree

8 files changed

+263
-84
lines changed

8 files changed

+263
-84
lines changed

.github/scripts/check-workflow-result.sh

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
if [ $# -lt 2 ]; then
5+
if [ $# -lt 1 ]; then
66
echo "Usage: $0 <test_result> [WOLFPROV_FORCE_FAIL] [TEST_SUITE]"
77
exit 1
88
fi
@@ -11,7 +11,12 @@ TEST_RESULT="$1"
1111
WOLFPROV_FORCE_FAIL="${2:-}"
1212
TEST_SUITE="${3:-}"
1313

14-
if [ "$WOLFPROV_FORCE_FAIL" = "1" ]; then
14+
# If force fail is empty treat second arg as test suite
15+
if [ -z "$WOLFPROV_FORCE_FAIL" ]; then
16+
TEST_SUITE="${2:-}"
17+
fi
18+
19+
if [ "$WOLFPROV_FORCE_FAIL" = "WOLFPROV_FORCE_FAIL=1" ]; then
1520
if [ "$TEST_SUITE" = "curl" ]; then
1621
# --- curl-specific logic ---
1722
if [ -f "tests/test.log" ]; then
@@ -69,21 +74,6 @@ if [ "$WOLFPROV_FORCE_FAIL" = "1" ]; then
6974
echo "FAIL: Actual failed tests do not match expected."
7075
exit 1
7176
fi
72-
elif [ "$TEST_SUITE" = "simple" ]; then
73-
# --- simple test suite specific logic ---
74-
if [ -f "test-suite.log" ]; then
75-
# For simple tests, we expect all tests to fail when force fail is enabled
76-
if [ $TEST_RESULT -eq 0 ]; then
77-
echo "Simple tests unexpectedly succeeded with force fail enabled"
78-
exit 1
79-
else
80-
echo "Simple tests failed as expected with force fail enabled"
81-
exit 0
82-
fi
83-
else
84-
echo "Error: test-suite.log not found"
85-
exit 1
86-
fi
8777
else
8878
# --- generic force-fail logic for other suites ---
8979
if [ $TEST_RESULT -eq 0 ]; then

.github/workflows/curl.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
matrix:
7474
curl_ref: [ 'master', 'curl-8_4_0' ]
7575
wolfssl_ref: [ 'master', 'v5.7.4-stable' ]
76-
force_fail: [ 1, 0 ] # ['WOLFPROV_FORCE_FAIL=1', '']
76+
force_fail: ['WOLFPROV_FORCE_FAIL=1', '']
7777
steps:
7878
- name: Checkout wolfProvider
7979
uses: actions/checkout@v4
@@ -118,7 +118,7 @@ jobs:
118118

119119
- name: Generate certificates for curl master force-fail tests
120120
run: |
121-
if [ "${{ matrix.force_fail }}" = "1" ] &&
121+
if [ "${{ matrix.force_fail }}" = "WOLFPROV_FORCE_FAIL=1" ] &&
122122
[ "${{ matrix.curl_ref }}" = "master" ]; then
123123
cd curl/tests/certs
124124
make test-ca.cacert
@@ -132,7 +132,7 @@ jobs:
132132
export OPENSSL_CONF=$GITHUB_WORKSPACE/provider.conf
133133
export OPENSSL_MODULES=$GITHUB_WORKSPACE/wolfprov-install/lib
134134
export PKG_CONFIG_PATH=$GITHUB_WORKSPACE/openssl-install/lib64/pkgconfig
135-
export WOLFPROV_FORCE_FAIL=${{ matrix.force_fail }}
135+
export ${{ matrix.force_fail }}
136136
export CURL_REF=${{ matrix.curl_ref }}
137137
138138
# Run tests and save output to test.log

.github/workflows/simple.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- 'OPENSSL_TAG=master'
2525
- 'WOLFSSL_TAG=master'
2626
- 'OPENSSL_TAG=master WOLFSSL_TAG=master'
27-
force_fail: [ 1, 0 ] # ['WOLFPROV_FORCE_FAIL=1', '']
27+
force_fail: ['WOLFPROV_FORCE_FAIL=1', '']
2828

2929
steps:
3030
- name: Checkout wolfProvider
@@ -61,13 +61,11 @@ jobs:
6161
- name: Build wolfProvider
6262
if: steps.wolfprov-${{ matrix.build_ref }}-cache.hit != 'true'
6363
run: |
64-
${{ matrix.build_ref.openssl }} ${{ matrix.build_ref.wolfssl }} WOLFPROV_FORCE_FAIL=${{ matrix.force_fail }} ./scripts/build-wolfprovider.sh || BUILD_RESULT=$?
65-
$GITHUB_WORKSPACE/.github/scripts/check-workflow-result.sh $BUILD_RESULT ${{ matrix.force_fail }} simple
64+
${{ matrix.build_ref.openssl }} ${{ matrix.build_ref.wolfssl }} ./scripts/build-wolfprovider.sh
6665
6766
- name: Run simple tests
6867
run: |
69-
WOLFPROV_FORCE_FAIL=${{ matrix.force_fail }} ./scripts/cmd_test/do-cmd-tests.sh || TEST_RESULT=$?
70-
$GITHUB_WORKSPACE/.github/scripts/check-workflow-result.sh $TEST_RESULT ${{ matrix.force_fail }} simple
68+
./scripts/cmd_test/do-cmd-tests.sh ${{ matrix.force_fail }}
7169
7270
- name: Print test logs
7371
if: always()

scripts/cmd_test/aes-cmd-test.sh

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
#!/bin/bash
2+
# aes-cmd-test.sh
3+
# AES encryption test for wolfProvider
4+
#
5+
# Copyright (C) 2006-2024 wolfSSL Inc.
6+
#
7+
# This file is part of wolfProvider.
8+
#
9+
# wolfProvider is free software; you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License as published by
11+
# the Free Software Foundation; either version 3 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# wolfProvider is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program; if not, write to the Free Software
21+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
222

323
# Set up environment
424
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
@@ -16,8 +36,17 @@ source "${UTILS_DIR}/utils-wolfprovider.sh"
1636
# Initialize the environment
1737
init_wolfprov
1838

19-
# Fail flag
39+
# Fail flags
2040
FAIL=0
41+
FORCE_FAIL=0
42+
FORCE_FAIL_PASSED=0
43+
44+
# Check for force fail parameter
45+
if [ "$1" = "WOLFPROV_FORCE_FAIL=1" ]; then
46+
export WOLFPROV_FORCE_FAIL=1
47+
FORCE_FAIL=1
48+
echo -e "\nForce fail mode enabled for AES tests"
49+
fi
2150

2251
# Verify wolfProvider is properly loaded
2352
echo -e "\nVerifying wolfProvider configuration:"
@@ -27,7 +56,7 @@ if ! $OPENSSL_BIN list -providers | grep -q "wolf"; then
2756
$OPENSSL_BIN list -providers
2857
FAIL=1
2958
else
30-
echo "[PASS] wolfProvider is properly configured"
59+
echo "wolfProvider is properly configured"
3160
fi
3261

3362
# Print environment for verification
@@ -40,6 +69,14 @@ echo "OPENSSL_BIN: ${OPENSSL_BIN}"
4069
mkdir -p aes_outputs
4170
echo "This is test data for AES encryption testing." > test.txt
4271

72+
# Helper function to handle force fail checks
73+
check_force_fail() {
74+
if [ $FORCE_FAIL -eq 1 ]; then
75+
echo "[PASS] Test passed when force fail was enabled"
76+
FORCE_FAIL_PASSED=1
77+
fi
78+
}
79+
4380
# Arrays for test configurations
4481
KEY_SIZES=("128" "192" "256")
4582
# Only include modes supported by wolfProvider
@@ -83,6 +120,7 @@ for key_size in "${KEY_SIZES[@]}"; do
83120
if [ $FAIL -eq 0 ]; then
84121
if cmp -s "test.txt" "$dec_file"; then
85122
echo "[PASS] Interop AES-${key_size}-${mode}: OpenSSL encrypt, wolfProvider decrypt"
123+
check_force_fail
86124
else
87125
echo "[FAIL] Interop AES-${key_size}-${mode}: OpenSSL encrypt, wolfProvider decrypt"
88126
FAIL=1
@@ -111,6 +149,7 @@ for key_size in "${KEY_SIZES[@]}"; do
111149
if [ $FAIL -eq 0 ]; then
112150
if cmp -s "test.txt" "$dec_file"; then
113151
echo "[PASS] Interop AES-${key_size}-${mode}: wolfProvider encrypt, OpenSSL decrypt"
152+
check_force_fail
114153
else
115154
echo "[FAIL] Interop AES-${key_size}-${mode}: wolfProvider encrypt, OpenSSL decrypt"
116155
FAIL=1
@@ -121,11 +160,22 @@ for key_size in "${KEY_SIZES[@]}"; do
121160
done
122161
done
123162

124-
# Change end of script to check FAIL flag
125-
if [ $FAIL -eq 0 ]; then
126-
echo -e "\n=== All AES tests completed successfully ==="
127-
exit 0
163+
if [ $FORCE_FAIL -eq 1 ]; then
164+
if [ $FORCE_FAIL_PASSED -eq 1 ]; then
165+
echo -e "\n=== AES Tests Failed With Force Fail Enabled ==="
166+
echo "ERROR: Some tests passed when they should have failed"
167+
exit 1
168+
else
169+
echo -e "\n=== AES Tests Passed With Force Fail Enabled ==="
170+
echo "SUCCESS: All tests failed as expected"
171+
exit 0
172+
fi
128173
else
129-
echo -e "\n=== AES tests completed with failures ==="
130-
exit 1
174+
if [ $FAIL -eq 0 ]; then
175+
echo -e "\n=== All AES tests completed successfully ==="
176+
exit 0
177+
else
178+
echo -e "\n=== AES tests completed with failures ==="
179+
exit 1
180+
fi
131181
fi

scripts/cmd_test/do-cmd-tests.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
# along with this program; if not, write to the Free Software
2121
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2222

23+
# Get the force fail parameter
24+
FORCE_FAIL=0
25+
if [ "$1" = "WOLFPROV_FORCE_FAIL=1" ]; then
26+
FORCE_FAIL=1
27+
fi
28+
2329
# Get the directory where this script is located
2430
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
2531
REPO_ROOT="$( cd "${SCRIPT_DIR}/../.." &> /dev/null && pwd )"
@@ -51,30 +57,30 @@ echo "Using wolfSSL version: ${WOLFSSL_TAG}"
5157

5258
# Run the hash comparison test
5359
echo -e "\n=== Running Hash Comparison Test ==="
54-
"${REPO_ROOT}/scripts/cmd_test/hash-cmd-test.sh"
60+
"${REPO_ROOT}/scripts/cmd_test/hash-cmd-test.sh" "$1"
5561
HASH_RESULT=$?
5662

5763
# Run the AES comparison test
5864
echo -e "\n=== Running AES Comparison Test ==="
59-
"${REPO_ROOT}/scripts/cmd_test/aes-cmd-test.sh"
65+
"${REPO_ROOT}/scripts/cmd_test/aes-cmd-test.sh" "$1"
6066
AES_RESULT=$?
6167

6268
# Run the RSA key generation test
6369
echo -e "\n=== Running RSA Key Generation Test ==="
64-
"${REPO_ROOT}/scripts/cmd_test/rsa-cmd-test.sh"
70+
"${REPO_ROOT}/scripts/cmd_test/rsa-cmd-test.sh" "$1"
6571
RSA_RESULT=$?
6672

6773
# Run the ECC key generation test
6874
echo -e "\n=== Running ECC Key Generation Test ==="
69-
"${REPO_ROOT}/scripts/cmd_test/ecc-cmd-test.sh"
75+
"${REPO_ROOT}/scripts/cmd_test/ecc-cmd-test.sh" "$1"
7076
ECC_RESULT=$?
7177

7278
# Check results
7379
if [ $HASH_RESULT -eq 0 ] && [ $AES_RESULT -eq 0 ] && [ $RSA_RESULT -eq 0 ] && [ $ECC_RESULT -eq 0 ]; then
74-
echo -e "\n=== All Command-Line Tests Passed ==="
80+
echo -e "\n=== All Command-Line Tests Passed $1 ==="
7581
exit 0
7682
else
77-
echo -e "\n=== Command-Line Tests Failed ==="
83+
echo -e "\n=== Command-Line Tests Failed $1 ==="
7884
echo "Hash Test Result: $HASH_RESULT (0=success)"
7985
echo "AES Test Result: $AES_RESULT (0=success)"
8086
echo "RSA Test Result: $RSA_RESULT (0=success)"

0 commit comments

Comments
 (0)