diff options
Diffstat (limited to 'scripts/testing/lib/run-common.sh')
| -rw-r--r-- | scripts/testing/lib/run-common.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/scripts/testing/lib/run-common.sh b/scripts/testing/lib/run-common.sh new file mode 100644 index 0000000..b5696db --- /dev/null +++ b/scripts/testing/lib/run-common.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Transport-independent polling and reporting for archsetup test runners. + +archsetup_process_running() { # <transport-function> + local transport="$1" + "$transport" "pgrep -f '[b]ash archsetup' > /dev/null" 2>/dev/null +} + +wait_for_archsetup() { # <transport> <max-polls> <seconds> <progress-every> [callback] + local transport="$1" max_polls="$2" poll_seconds="$3" + local progress_every="$4" progress_callback="${5:-}" + ARCHSETUP_POLL_COUNT=0 + + while [ "$ARCHSETUP_POLL_COUNT" -lt "$max_polls" ]; do + archsetup_process_running "$transport" || return 0 + sleep "$poll_seconds" + ARCHSETUP_POLL_COUNT=$((ARCHSETUP_POLL_COUNT + 1)) + if [ "$progress_every" -gt 0 ] \ + && [ $((ARCHSETUP_POLL_COUNT % progress_every)) -eq 0 ] \ + && [ -n "$progress_callback" ]; then + "$progress_callback" "$ARCHSETUP_POLL_COUNT" + fi + done + return 124 +} + +write_archsetup_test_report() { + local file="$1" title="$2" test_id="$3" method="$4" context="$5" + local completed="$6" passed="$7" count_passed="$8" count_failed="$9" + shift 9 + local count_warnings="$1" artifacts="$2" validation="FAILED" + [ "$passed" = "true" ] && validation="PASSED" + + { + echo "========================================" + echo "$title" + echo "========================================" + echo + echo "Test ID: $test_id" + echo "Date: $(date +'%Y-%m-%d %H:%M:%S')" + echo "Test Method: $method" + if [ -n "$context" ]; then + echo + printf '%s\n' "$context" + fi + echo + echo "Results:" + echo " ArchSetup Completed: $completed (completion marker, not the installer's exit code)" + echo " Validation: $validation" + echo + echo "Validation Summary:" + echo " Passed: $count_passed" + echo " Failed: $count_failed" + echo " Warnings: $count_warnings" + if [ -n "$artifacts" ]; then + echo + printf '%s\n' "$artifacts" + fi + echo + } > "$file" +} |
