|
1 | 1 | #!/usr/bin/env bash |
2 | | -# Loop running the "open close" test until a Broken pipe is observed. |
| 2 | +# Loop running the "open close" test until a Broken pipe or test failure is observed. |
3 | 3 | # Writes each iteration's full output to test-logs/open-close-loop-<n>.log |
4 | 4 | # Environment you can tweak: |
5 | 5 | # MAX_ITER : maximum iterations before giving up (default: unlimited) |
|
8 | 8 | # LOG_STDERR : set to 1 to enable verbose stderr logging (HLS_TEST_LOG_STDERR & HLS_TEST_HARNESS_STDERR) (default: 1) |
9 | 9 | # |
10 | 10 | # Exit codes: |
11 | | -# 0 on success (broken pipe reproduced) |
| 11 | +# 0 on success (broken pipe or test failure reproduced) |
12 | 12 | # 1 on reaching MAX_ITER without reproduction |
13 | 13 | # 2 on other setup error |
14 | 14 |
|
|
30 | 30 | start_ts=$(date -Iseconds) |
31 | 31 | echo "[loop] Starting at ${start_ts}" >&2 |
32 | 32 |
|
33 | | -# Pattern string to detect (keep simple & literal for robustness) |
| 33 | +# Pattern strings to detect issues (keep simple & literal for robustness) |
34 | 34 | BROKEN_PIPE_RE='Broken pipe' |
| 35 | +TEST_FAILED_RE='tests failed' |
35 | 36 | DEBUG_DETECT="${DEBUG_DETECT:-0}" |
36 | 37 |
|
37 | 38 | if [[ -z "${NO_BUILD_ONCE:-}" ]]; then |
@@ -79,19 +80,24 @@ while true; do |
79 | 80 | echo "[loop] Broken pipe reproduced in iteration ${iter}. Stopping." | tee -a "${log}" >&2 |
80 | 81 | echo "[loop] --- Tail (last 60 lines) ---" >&2 |
81 | 82 | tail -n 60 "${log}" >&2 |
82 | | - exit 1 |
| 83 | + exit 0 |
| 84 | + elif grep -aFq -- "${TEST_FAILED_RE}" "${log}"; then |
| 85 | + echo "[loop] Test failure detected in iteration ${iter}. Stopping." | tee -a "${log}" >&2 |
| 86 | + echo "[loop] --- Tail (last 60 lines) ---" >&2 |
| 87 | + tail -n 60 "${log}" >&2 |
| 88 | + exit 0 |
83 | 89 | else |
84 | 90 | if [[ ${DEBUG_DETECT} -eq 1 ]]; then |
85 | | - echo "[loop][debug] No match for '${BROKEN_PIPE_RE}' in iteration ${iter}." | tee -a "${log}" >&2 |
| 91 | + echo "[loop][debug] No match for '${BROKEN_PIPE_RE}' or '${TEST_FAILED_RE}' in iteration ${iter}." | tee -a "${log}" >&2 |
86 | 92 | fi |
87 | 93 | fi |
88 | 94 |
|
89 | 95 | if [[ -n "${MAX_ITER}" && ${iter} -ge ${MAX_ITER} ]]; then |
90 | | - echo "[loop] Reached MAX_ITER=${MAX_ITER} without reproducing Broken pipe." >&2 |
91 | | - exit 0 |
| 96 | + echo "[loop] Reached MAX_ITER=${MAX_ITER} without reproducing issues." >&2 |
| 97 | + exit 1 |
92 | 98 | fi |
93 | 99 |
|
94 | | - echo "[loop] Iteration ${iter} complete (exit code ${ec}). No Broken pipe yet." | tee -a "${log}" >&2 |
| 100 | + echo "[loop] Iteration ${iter} complete (exit code ${ec}). No issues detected yet." | tee -a "${log}" >&2 |
95 | 101 | if [[ ${SLEEP_SECS} -gt 0 ]]; then |
96 | 102 | echo "[loop] Sleeping ${SLEEP_SECS}s" | tee -a "${log}" >&2 |
97 | 103 | sleep "${SLEEP_SECS}" |
|
0 commit comments