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.
This commit is contained in:
@@ -56,22 +56,53 @@ run_guest_checks() {
|
||||
|
||||
run_qemu_checks() {
|
||||
local arch="${ARCH:-x86_64}"
|
||||
local iso="build/${arch}/${CONFIG}.iso"
|
||||
local image="build/${arch}/${CONFIG}/harddrive.img"
|
||||
local firmware="${FIRMWARE_PATH:-/usr/share/ovmf/x64/OVMF.fd}"
|
||||
if [[ ! -f "$image" ]]; then echo "$PROG: image not found: $image (build with: make all CONFIG_NAME=$CONFIG)"; exit 1; fi
|
||||
|
||||
local boot_args=()
|
||||
if [[ -f "$iso" ]]; then
|
||||
boot_args=(-cdrom "$iso")
|
||||
elif [[ -f "$image" ]]; then
|
||||
boot_args=(-drive file="$image",format=raw,if=none,id=drv0,snapshot=on -device nvme,drive=drv0,serial=NVME_SERIAL)
|
||||
else
|
||||
echo "$PROG: no bootable image found ($iso or $image)"
|
||||
echo "$PROG: build with: make all CONFIG_NAME=$CONFIG"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "$firmware" ]]; then echo "$PROG: firmware not found: $firmware"; exit 1; fi
|
||||
expect <<EXPECT_SCRIPT
|
||||
log_user 1; set timeout 300
|
||||
spawn qemu-system-x86_64 -name {Red Bear OS} -device qemu-xhci -smp 4 -m 2048 -bios $firmware -chardev stdio,id=debug,signal=off,mux=on -serial chardev:debug -mon chardev:debug -machine q35 -device virtio-net,netdev=net0 -netdev user,id=net0 -nographic -vga none -drive file=$image,format=raw,if=none,id=drv0 -device nvme,drive=drv0,serial=NVME_SERIAL -enable-kvm -cpu host
|
||||
expect "login:"; send "root\r"
|
||||
expect "assword:"; send "password\r"
|
||||
expect "Type 'help' for available commands."
|
||||
send "echo __READY__\r"; expect "__READY__"
|
||||
send "redbear-phase5-gpu-check --json >/dev/null 2>&1 && echo __P5_OK__ || echo __P5_FAIL__\r"
|
||||
expect { "__P5_OK__" { } "__P5_FAIL__" { puts "FAIL: Phase 5"; exit 1 } timeout { puts "FAIL: timeout"; exit 1 } eof { puts "FAIL: eof"; exit 1 } }
|
||||
puts "ALL PHASE 5 CHECKS PASSED"
|
||||
EXPECT_SCRIPT
|
||||
exit $?
|
||||
|
||||
attempt=1
|
||||
while true; do
|
||||
rc=0
|
||||
python3 local/scripts/qemu-login-expect.py \
|
||||
--timeout 300 \
|
||||
--log "build/${arch}/${CONFIG}/phase5-gpu-check.log" \
|
||||
--step "expect:login:" \
|
||||
--step "send:root" \
|
||||
--step "expect:assword:" \
|
||||
--step "send:password" \
|
||||
--step "expect:Type 'help' for available commands." \
|
||||
--step "send:echo __READY__" \
|
||||
--step "expect:__READY__" \
|
||||
--step "send:redbear-phase5-gpu-check --json >/dev/null 2>&1 && echo __P5_OK__ || echo __P5_FAIL__" \
|
||||
--pass_marker "__P5_OK__" \
|
||||
--fail_marker "__P5_FAIL__" \
|
||||
-- \
|
||||
qemu-system-x86_64 -name "Red Bear OS" -device qemu-xhci -smp 4 -m 2048 -bios "$firmware" -chardev stdio,id=debug,signal=off,mux=on -serial chardev:debug -mon chardev:debug -machine q35 -device virtio-net,netdev=net0 -netdev user,id=net0 -nographic -vga none "${boot_args[@]}" -enable-kvm -cpu host || 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
|
||||
echo "ALL PHASE 5 CHECKS PASSED"
|
||||
exit 0
|
||||
}
|
||||
|
||||
case "$MODE" in
|
||||
|
||||
Reference in New Issue
Block a user