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:
2026-07-20 09:01:14 +09:00
parent cf6f363da9
commit 6dab9b2953
22 changed files with 1104 additions and 647 deletions
+55 -27
View File
@@ -98,45 +98,73 @@ run_qemu_checks() {
exit 1
}
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
local boot_media boot_args
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 1
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 <<EOF
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 -object filter-dump,id=f1,netdev=net0,file=build/$arch/$config/network.pcap -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 "redbear-phase3-input-check; echo __EVTEST_DONE__\r"
expect "Injected synthetic key event: A"
send "redbear-info --json\r"
expect "\"virtio_net_present\": true"
expect "scheme firmware is registered"
expect "scheme udev is registered"
expect "\"name\": \"evdevd\""
expect "\"state\": \"active\""
expect "EV_KEY code="
expect "__EVTEST_DONE__"
send "shutdown\r"
expect eof
EOF
log="build/$arch/$config/phase3-check.log"
attempt=1
while true; do
rc=0
python3 local/scripts/qemu-login-expect.py \
--timeout 300 \
--log "$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-phase3-input-check; echo __EVTEST_DONE__" \
--step "expect:Injected synthetic key event: A" \
--step "send:redbear-info --json" \
--step "expect:\"virtio_net_present\": true" \
--step "expect:scheme firmware is registered" \
--step "expect:scheme udev is registered" \
--step "expect:\"name\": \"evdevd\"" \
--step "expect:\"state\": \"active\"" \
--step "expect:EV_KEY code=" \
--step "expect:__EVTEST_DONE__" \
--step "send:shutdown" \
--pass_marker "__EVTEST_DONE__" \
-- \
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 -object filter-dump,id=f1,netdev=net0,file="build/$arch/$config/network.pcap" -display none -vga none "${boot_args[@]}" -drive file="$extra",format=raw,if=none,id=drv1 -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
}
usage() {