Files
RedBear-OS/local/scripts/test-live-iso-qemu.sh
T
vasilito 6dab9b2953 tests: migrate remaining QEMU runtime proofs to qemu-login-expect.py
Convert the remaining expect-based test scripts (phase1-6 runtime, usb,
wifi, bluetooth, dbus, greeter, live-iso, posix) to the stdlib python
harness, completing the migration started in 9ec00d4c81. Each script now
prefers booting the live ISO when present (falling back to harddrive.img
with snapshot=on), and retries up to 5 times when QEMU exits early or is
killed (rc 3 / 137) — the host-contention failure mode recorded in the
2026-07-20 runtime-proof status.

qemu-login-expect.py: treat an incomplete step sequence as a failure even
when a pass marker was seen partway through — partial sequences must not
count as a pass.
2026-07-20 09:01:14 +09:00

99 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# test-live-iso-qemu.sh — bounded QEMU smoke test for Red Bear live ISOs.
set -euo pipefail
canonicalize_live_config() {
case "$1" in
redbear-live-full)
printf '%s\n' "redbear-live"
;;
redbear-live-mini-grub)
printf '%s\n' "redbear-grub-live-mini"
;;
*)
printf '%s\n' "$1"
;;
esac
}
usage() {
cat <<'USAGE'
Usage: test-live-iso-qemu.sh [CONFIG_NAME ...]
Boot one or more Red Bear live ISO targets in QEMU/UEFI and verify that each reaches a text
`login:` prompt on the serial console.
Defaults:
redbear-live redbear-live-mini redbear-grub-live-mini
USAGE
}
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" || "${1:-}" == "help" ]]; then
usage
exit 0
fi
configs=("$@")
if [[ ${#configs[@]} -eq 0 ]]; then
configs=(redbear-live redbear-live-mini redbear-grub-live-mini)
fi
for i in "${!configs[@]}"; do
configs[$i]="$(canonicalize_live_config "${configs[$i]}")"
done
for config in "${configs[@]}"; do
case "$config" in
redbear-live|redbear-live-mini|redbear-grub-live-mini)
;;
*)
echo "ERROR: unsupported live ISO target $config" >&2
usage >&2
exit 1
;;
esac
done
arch="${ARCH:-$(uname -m)}"
for config in "${configs[@]}"; do
image="build/$arch/$config.iso"
if [[ ! -f "$image" ]]; then
echo "ERROR: missing ISO $image" >&2
echo "Build it first with: ./scripts/build-iso.sh $config" >&2
exit 1
fi
done
for config in "${configs[@]}"; do
echo "=== Boot-testing $config ==="
log="build/$arch/$config/live-iso-check.log"
attempt=1
while true; do
rc=0
python3 local/scripts/qemu-login-expect.py \
--timeout 420 \
--log "$log" \
--step "expect:login:" \
--step "send:root" \
--step "expect:assword:" \
--step "send:password" \
--step "expect:Type 'help' for available commands." \
--step "send:shutdown" \
--pass_marker "Type 'help' for available commands." \
-- \
env CI=1 make qemu CONFIG_NAME="$config" live=yes serial=yes gpu=no net=no || rc=$?
if [[ $rc -eq 0 ]]; then
break
fi
if [[ ( $rc -eq 3 || $rc -eq 137 ) && $attempt -lt 5 ]]; then
attempt=$((attempt + 1))
echo "QEMU exited before completing the check; retrying (attempt $attempt/5)"
sleep 2
continue
fi
exit "$rc"
done
done