|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +if [ $# -lt 2 ]; then |
| 6 | + echo "Usage: $0 <test_result> [WOLFPROV_FORCE_FAIL] [TEST_SUITE]" |
| 7 | + exit 1 |
| 8 | +fi |
| 9 | + |
| 10 | +TEST_RESULT="$1" |
| 11 | +WOLFPROV_FORCE_FAIL="${2:-}" |
| 12 | +TEST_SUITE="${3:-}" |
| 13 | + |
| 14 | +if [ "$WOLFPROV_FORCE_FAIL" = "1" ]; then |
| 15 | + if [ "$TEST_SUITE" = "curl" ]; then |
| 16 | + # --- curl-specific logic --- |
| 17 | + if [ -f "tests/test.log" ]; then |
| 18 | + # Extract and clean the failed test list from the log |
| 19 | + ACTUAL_FAILS=$(grep -a '^TESTFAIL: These test cases failed:' tests/test.log | sed 's/.*failed: //') |
| 20 | + else |
| 21 | + echo "Error: tests/test.log not found" |
| 22 | + exit 1 |
| 23 | + fi |
| 24 | + |
| 25 | + # Get curl version from the workflow ref |
| 26 | + CURL_VERSION="${CURL_REF:-}" |
| 27 | + |
| 28 | + # Define expected failures based on curl version |
| 29 | + case "$CURL_VERSION" in |
| 30 | + "curl-8_4_0") |
| 31 | + EXPECTED_FAILS="9 31 39 41 44 46 61 64 65 70 71 72 73 88 153 154 158 163 166 167 168 169 170 171 173 186 206 245 246 258 259 273 277 327 335 388 420 444 540 551 552 554 565 579 584 643 645 646 647 648 649 650 651 652 653 654 666 667 668 669 670 671 672 673 977 1001 1002 1030 1053 1060 1061 1071 1072 1079 1095 1105 1133 1136 1151 1155 1158 1160 1161 1186 1187 1189 1190 1191 1192 1193 1194 1195 1196 1198 1199 1229 1284 1285 1286 1293 1315 1404 1412 1415 1418 1437 1568 1903 1905 1916 1917 1964 2024 2026 2027 2028 2030 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2073 2076 2200 2201 2202 2203 2204 3017 3018" |
| 32 | + ;; |
| 33 | + "master") |
| 34 | + EXPECTED_FAILS="9 31 39 41 44 46 61 64 65 70 71 72 73 88 153 154 158 163 166 167 168 169 170 171 173 186 206 245 246 258 259 273 277 327 335 388 420 444 483 540 551 552 554 565 579 584 643 645 646 647 648 649 650 651 652 653 654 666 667 668 669 670 671 672 673 695 977 1001 1002 1030 1053 1060 1061 1071 1072 1079 1095 1105 1133 1136 1151 1155 1158 1160 1161 1186 1187 1189 1190 1191 1192 1193 1194 1195 1196 1198 1199 1229 1284 1285 1286 1293 1315 1404 1412 1415 1418 1437 1476 1568 1608 1610 1615 1654 1660 1903 1905 1916 1917 1964 2024 2026 2027 2028 2030 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2073 2076 2200 2201 2202 2203 2204 3017 3018" |
| 35 | + ;; |
| 36 | + *) |
| 37 | + echo "Error: Unknown curl version: $CURL_VERSION" |
| 38 | + exit 1 |
| 39 | + ;; |
| 40 | + esac |
| 41 | + |
| 42 | + # Create temporary files for sorted lists |
| 43 | + TEMP_DIR=$(mktemp -d) |
| 44 | + ACTUAL_SORTED="${TEMP_DIR}/actual_sorted.txt" |
| 45 | + EXPECTED_SORTED="${TEMP_DIR}/expected_sorted.txt" |
| 46 | + |
| 47 | + # Clean and sort both lists and remove empty lines |
| 48 | + echo "$ACTUAL_FAILS" | tr ' ' '\n' | grep -v '^$' | sort -n > "$ACTUAL_SORTED" |
| 49 | + echo "$EXPECTED_FAILS" | tr ' ' '\n' | grep -v '^$' | sort -n > "$EXPECTED_SORTED" |
| 50 | + |
| 51 | + echo "DEBUG: Sorted actual fails: $(tr '\n' ' ' < "$ACTUAL_SORTED")" |
| 52 | + echo "DEBUG: Sorted expected fails: $(tr '\n' ' ' < "$EXPECTED_SORTED")" |
| 53 | + |
| 54 | + # Find missing in actual (in expected but not in actual) |
| 55 | + MISSING=$(comm -23 "$EXPECTED_SORTED" "$ACTUAL_SORTED" | tr '\n' ' ') |
| 56 | + # Find extra in actual (in actual but not in expected) |
| 57 | + EXTRA=$(comm -13 "$EXPECTED_SORTED" "$ACTUAL_SORTED" | tr '\n' ' ') |
| 58 | + |
| 59 | + # Clean up temporary files |
| 60 | + rm -rf "$TEMP_DIR" |
| 61 | + |
| 62 | + echo "Test(s) that should have failed: $MISSING" |
| 63 | + echo "Test(s) that shouldn't have failed: $EXTRA" |
| 64 | + |
| 65 | + if [ -z "$MISSING" ] && [ -z "$EXTRA" ]; then |
| 66 | + echo "PASS: Actual failed tests match expected." |
| 67 | + exit 0 |
| 68 | + else |
| 69 | + echo "FAIL: Actual failed tests do not match expected." |
| 70 | + exit 1 |
| 71 | + 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 |
| 87 | + else |
| 88 | + # --- generic force-fail logic for other suites --- |
| 89 | + if [ $TEST_RESULT -eq 0 ]; then |
| 90 | + echo "Test unexpectedly succeeded with force fail enabled" |
| 91 | + exit 1 # failure was not seen when expected |
| 92 | + else |
| 93 | + echo "Test failed as expected with force fail enabled" |
| 94 | + exit 0 # expected failure occurred |
| 95 | + fi |
| 96 | + fi |
| 97 | +elif [ $TEST_RESULT -ne 0 ]; then |
| 98 | + echo "Tests failed unexpectedly" |
| 99 | + exit 1 |
| 100 | +else |
| 101 | + echo "Tests passed successfully" |
| 102 | + exit 0 |
| 103 | +fi |
0 commit comments