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:
@@ -77,54 +77,74 @@ run_qemu_checks() {
|
||||
exit 2
|
||||
}
|
||||
|
||||
local arch image extra
|
||||
local arch image iso extra
|
||||
arch="${ARCH:-$(uname -m)}"
|
||||
image="build/$arch/$config/harddrive.img"
|
||||
iso="build/$arch/$config.iso"
|
||||
extra="build/$arch/$config/extra.img"
|
||||
|
||||
if [[ ! -f "$image" ]]; then
|
||||
echo "ERROR: missing image $image" >&2
|
||||
boot_media=""
|
||||
if [[ -f "$iso" ]]; then
|
||||
boot_media="iso"
|
||||
elif [[ -f "$image" ]]; then
|
||||
boot_media="harddrive"
|
||||
else
|
||||
echo "ERROR: no bootable image found ($iso or $image)" >&2
|
||||
echo "Build it first with: ./local/scripts/build-redbear.sh $config" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ "$boot_media" == "iso" ]]; then
|
||||
boot_args=(-cdrom "$iso")
|
||||
else
|
||||
boot_args=(-drive file="$image",format=raw,if=none,id=drv0,snapshot=on -device nvme,drive=drv0,serial=NVME_SERIAL)
|
||||
fi
|
||||
|
||||
if [[ ! -f "$extra" ]]; then
|
||||
truncate -s 1g "$extra"
|
||||
fi
|
||||
|
||||
expect <<EXPECT_SCRIPT
|
||||
log_user 1
|
||||
set timeout 300
|
||||
spawn qemu-system-x86_64 -name {Red Bear OS x86_64} -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 ich9-intel-hda -device hda-output -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 -drive file=$extra,format=raw,if=none,id=drv1 -device nvme,drive=drv1,serial=NVME_EXTRA -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 "command -v redbear-phase3-kwin-check >/dev/null 2>&1 && echo __PHASE3_BIN_OK__ || echo __PHASE3_BIN_FAIL__\r"
|
||||
expect {
|
||||
"__PHASE3_BIN_OK__" { }
|
||||
"__PHASE3_BIN_FAIL__" { puts "FAIL: redbear-phase3-kwin-check is missing"; exit 1 }
|
||||
timeout { puts "FAIL: timed out while checking for redbear-phase3-kwin-check"; exit 1 }
|
||||
eof { puts "FAIL: guest exited before Phase 3 binary check completed"; exit 1 }
|
||||
}
|
||||
|
||||
send "redbear-phase3-kwin-check --json >/dev/null 2>&1 && echo __PHASE3_OK__ || echo __PHASE3_FAIL__\r"
|
||||
expect {
|
||||
"__PHASE3_OK__" { }
|
||||
"__PHASE3_FAIL__" { puts "FAIL: redbear-phase3-kwin-check reported failures"; exit 1 }
|
||||
timeout { puts "FAIL: timed out while running redbear-phase3-kwin-check"; exit 1 }
|
||||
eof { puts "FAIL: guest exited before Phase 3 check completed"; exit 1 }
|
||||
}
|
||||
|
||||
send "echo __PHASE3_RUNTIME_DONE__\r"
|
||||
expect "__PHASE3_RUNTIME_DONE__"
|
||||
send "shutdown\r"
|
||||
expect eof
|
||||
EXPECT_SCRIPT
|
||||
attempt=1
|
||||
while true; do
|
||||
rc=0
|
||||
python3 local/scripts/qemu-login-expect.py \
|
||||
--timeout 300 \
|
||||
--log "build/$arch/$config/phase3-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:command -v redbear-phase3-kwin-check >/dev/null 2>&1 && echo __PHASE3_BIN_OK__ || echo __PHASE3_BIN_FAIL__" \
|
||||
--step "expect:__PHASE3_BIN_OK__" \
|
||||
--step "send:redbear-phase3-kwin-check --json >/dev/null 2>&1 && echo __PHASE3_OK__ || echo __PHASE3_FAIL__" \
|
||||
--step "expect:__PHASE3_OK__" \
|
||||
--step "send:echo __PHASE3_RUNTIME_DONE__" \
|
||||
--step "expect:__PHASE3_RUNTIME_DONE__" \
|
||||
--step "send:shutdown" \
|
||||
--pass_marker "__PHASE3_BIN_OK__" \
|
||||
--pass_marker "__PHASE3_OK__" \
|
||||
--pass_marker "__PHASE3_RUNTIME_DONE__" \
|
||||
--fail_marker "__PHASE3_BIN_FAIL__" \
|
||||
--fail_marker "__PHASE3_FAIL__" \
|
||||
-- \
|
||||
qemu-system-x86_64 -name "Red Bear OS x86_64" -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 ich9-intel-hda -device hda-output -device virtio-net,netdev=net0 -netdev user,id=net0 -display none -vga none "${boot_args[@]}" -drive file="$extra",format=raw,if=none,id=drv1,snapshot=on -device nvme,drive=drv1,serial=NVME_EXTRA -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
|
||||
pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true
|
||||
echo "Phase 3 desktop session preflight completed via guest runtime check"
|
||||
exit 0
|
||||
}
|
||||
|
||||
usage() {
|
||||
|
||||
Reference in New Issue
Block a user