11#! /bin/bash
2+ # check-workflow-result.sh
3+ #
4+ # Copyright (C) 2006-2024 wolfSSL Inc.
5+ #
6+ # This file is part of wolfProvider.
7+ #
8+ # wolfProvider is free software; you can redistribute it and/or modify
9+ # it under the terms of the GNU General Public License as published by
10+ # the Free Software Foundation; either version 3 of the License, or
11+ # (at your option) any later version.
12+ #
13+ # wolfProvider is distributed in the hope that it will be useful,
14+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+ # GNU General Public License for more details.
17+ #
18+ # You should have received a copy of the GNU General Public License
19+ # along with this program; if not, write to the Free Software
20+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
221
322set -e
423
@@ -11,14 +30,17 @@ TEST_RESULT="$1"
1130WOLFPROV_FORCE_FAIL=" ${2:- } "
1231TEST_SUITE=" ${3:- } "
1332
33+ # Ensure TEST_RESULT is treated as a number
34+ TEST_RESULT=$(( TEST_RESULT + 0 ))
35+
1436# If force fail is empty treat second arg as test suite
1537if [ -z " $WOLFPROV_FORCE_FAIL " ]; then
1638 TEST_SUITE=" ${2:- } "
1739fi
1840
1941if [ " $WOLFPROV_FORCE_FAIL " = " WOLFPROV_FORCE_FAIL=1" ]; then
42+ # ----- CURL -----
2043 if [ " $TEST_SUITE " = " curl" ]; then
21- # --- curl-specific logic ---
2244 if [ -f " tests/test.log" ]; then
2345 # Extract and clean the failed test list from the log
2446 ACTUAL_FAILS=$( grep -a ' ^TESTFAIL: These test cases failed:' tests/test.log | sed ' s/.*failed: //' )
@@ -74,13 +96,128 @@ if [ "$WOLFPROV_FORCE_FAIL" = "WOLFPROV_FORCE_FAIL=1" ]; then
7496 echo " FAIL: Actual failed tests do not match expected."
7597 exit 1
7698 fi
99+ # ----- OPENVPN -----
100+ elif [ " $TEST_SUITE " = " openvpn" ]; then
101+ if [ -f " openvpn-test.log" ]; then
102+ # Extract failed tests from the log
103+ ACTUAL_FAILS=$( grep -a ' ^FAIL: ' openvpn-test.log | sed ' s/^FAIL: //' | sort)
104+
105+ # Define expected failures
106+ EXPECTED_FAILS=" auth_token_testdriver crypto_testdriver pkt_testdriver tls_crypt_testdriver"
107+
108+ # Create temporary files for sorted lists
109+ TEMP_DIR=$( mktemp -d)
110+ ACTUAL_SORTED=" ${TEMP_DIR} /actual_sorted.txt"
111+ EXPECTED_SORTED=" ${TEMP_DIR} /expected_sorted.txt"
112+
113+ # Clean and sort both lists
114+ echo " $ACTUAL_FAILS " | tr ' ' ' \n' | grep -v ' ^$' | sort > " $ACTUAL_SORTED "
115+ echo " $EXPECTED_FAILS " | tr ' ' ' \n' | grep -v ' ^$' | sort > " $EXPECTED_SORTED "
116+
117+ echo " DEBUG: Actual failed tests: $( tr ' \n' ' ' < " $ACTUAL_SORTED " ) "
118+ echo " DEBUG: Expected failed tests: $( tr ' \n' ' ' < " $EXPECTED_SORTED " ) "
119+
120+ # Find missing in actual (in expected but not in actual)
121+ MISSING=$( comm -23 " $EXPECTED_SORTED " " $ACTUAL_SORTED " | tr ' \n' ' ' )
122+ # Find extra in actual (in actual but not in expected)
123+ EXTRA=$( comm -13 " $EXPECTED_SORTED " " $ACTUAL_SORTED " | tr ' \n' ' ' )
124+
125+ # Clean up temporary files
126+ rm -rf " $TEMP_DIR "
127+
128+ echo " Test(s) that should have failed: $MISSING "
129+ echo " Test(s) that shouldn't have failed: $EXTRA "
130+
131+ if [ -z " $MISSING " ] && [ -z " $EXTRA " ]; then
132+ echo " PASS: Actual failed tests match expected."
133+ exit 0
134+ else
135+ echo " FAIL: Actual failed tests do not match expected."
136+ exit 1
137+ fi
138+ else
139+ echo " Error: openvpn-test.log not found"
140+ exit 1
141+ fi
142+ # ----- SSSD -----
143+ elif [ " $TEST_SUITE " = " sssd" ]; then
144+ if [ -f " sssd-test.log" ]; then
145+ # Extract failed tests from the log
146+ ACTUAL_FAILS=$( grep -a ' ^FAIL: ' sssd-test.log | sed ' s/^FAIL: //' | sort)
147+
148+ # Define expected failures
149+ EXPECTED_FAILS=" src/tests/pysss-test.py3.sh pam-srv-tests ssh-srv-tests test_cert_utils sss_certmap_test sysdb-tests crypto-tests"
150+
151+ # Create temporary files for sorted lists
152+ TEMP_DIR=$( mktemp -d)
153+ ACTUAL_SORTED=" ${TEMP_DIR} /actual_sorted.txt"
154+ EXPECTED_SORTED=" ${TEMP_DIR} /expected_sorted.txt"
155+
156+ # Clean and sort both lists
157+ echo " $ACTUAL_FAILS " | tr ' ' ' \n' | grep -v ' ^$' | sort > " $ACTUAL_SORTED "
158+ echo " $EXPECTED_FAILS " | tr ' ' ' \n' | grep -v ' ^$' | sort > " $EXPECTED_SORTED "
159+
160+ echo " DEBUG: Actual failed tests: $( tr ' \n' ' ' < " $ACTUAL_SORTED " ) "
161+ echo " DEBUG: Expected failed tests: $( tr ' \n' ' ' < " $EXPECTED_SORTED " ) "
162+
163+ # Find missing in actual (in expected but not in actual)
164+ MISSING=$( comm -23 " $EXPECTED_SORTED " " $ACTUAL_SORTED " | tr ' \n' ' ' )
165+ # Find extra in actual (in actual but not in expected)
166+ EXTRA=$( comm -13 " $EXPECTED_SORTED " " $ACTUAL_SORTED " | tr ' \n' ' ' )
167+
168+ # Clean up temporary files
169+ rm -rf " $TEMP_DIR "
170+
171+ echo " Test(s) that should have failed: $MISSING "
172+ echo " Test(s) that shouldn't have failed: $EXTRA "
173+
174+ if [ -z " $MISSING " ] && [ -z " $EXTRA " ]; then
175+ echo " PASS: Actual failed tests match expected."
176+ exit 0
177+ else
178+ echo " FAIL: Actual failed tests do not match expected."
179+ exit 1
180+ fi
181+ else
182+ echo " Error: sssd-test.log not found"
183+ exit 1
184+ fi
185+ # ----- NGINX -----
186+ elif [ " $TEST_SUITE " = " nginx" ]; then
187+ if [ -f " nginx-test.log" ]; then
188+ # Check if the test result shows FAIL
189+ if grep -q " Result: FAIL" nginx-test.log; then
190+ echo " PASS: nginx tests failed as expected with force fail enabled"
191+ exit 0
192+ else
193+ echo " FAIL: nginx tests unexpectedly succeeded with force fail enabled"
194+ exit 1
195+ fi
196+ else
197+ echo " Error: nginx-test.log not found"
198+ exit 1
199+ fi
200+ # ----- STUNNEL -----
201+ elif [ " $TEST_SUITE " = " stunnel" ]; then
202+ if [ -f " $GITHUB_WORKSPACE /tests/stunnel-test.log" ]; then
203+ # Check for expected error patterns
204+ if grep -q " failed: 41" " $GITHUB_WORKSPACE /tests/stunnel-test.log" ; then
205+ echo " PASS: stunnel tests failed as expected with force fail enabled"
206+ exit 0
207+ else
208+ echo " FAIL: stunnel tests unexpectedly succeeded with force fail enabled"
209+ exit 1
210+ fi
211+ else
212+ echo " Error: stunnel-test.log not found"
213+ exit 1
214+ fi
77215 else
78- # --- generic force-fail logic for other suites ---
79216 if [ $TEST_RESULT -eq 0 ]; then
80- echo " Test unexpectedly succeeded with force fail enabled"
217+ echo " $TEST_SUITE tests unexpectedly succeeded with force fail enabled"
81218 exit 1 # failure was not seen when expected
82219 else
83- echo " Test failed as expected with force fail enabled"
220+ echo " $TEST_SUITE tests failed as expected with force fail enabled"
84221 exit 0 # expected failure occurred
85222 fi
86223 fi
0 commit comments