tests: replace expect with stdlib python helper for QEMU login proofs
Drop the host expect dependency from the PS/2, timer, IOMMU, and USB storage (BOT) runtime proofs. local/scripts/qemu-login-expect.py drives the guest over serial-on-stdio with ordered expect/send steps, per-step timeouts (matching expect's per-pattern semantics), and pass/fail markers. It distinguishes premature QEMU death (exit 3) from genuine check failure (exit 1) so the scripts retry external interruptions without retrying real failures. Scripts use headless -display none -vga none (fbcond serial mirror), a 3600s per-step timeout, and a retry loop (max 5 attempts).
This commit is contained in:
@@ -93,23 +93,37 @@ pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
if [[ "$check_mode" -eq 1 ]]; then
|
||||
expect <<EOF
|
||||
log_user 1
|
||||
set timeout 240
|
||||
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 ${boot_args[*]} -drive file=$extra,format=raw,if=none,id=drv1,snapshot=on -device nvme,drive=drv1,serial=NVME_EXTRA -enable-kvm -cpu host $extra_qemu_args
|
||||
expect "login:"
|
||||
send "root\r"
|
||||
expect "assword:"
|
||||
send "password\r"
|
||||
expect "Type 'help' for available commands."
|
||||
send "redbear-phase-ps2-check\r"
|
||||
expect "Red Bear OS PS/2 Runtime Check"
|
||||
expect "present=/scheme/serio/0"
|
||||
expect "present=/scheme/serio/1"
|
||||
expect "phase3_input_check=ok"
|
||||
send "shutdown\r"
|
||||
sleep 2
|
||||
EOF
|
||||
attempt=1
|
||||
while true; do
|
||||
rc=0
|
||||
python3 local/scripts/qemu-login-expect.py \
|
||||
--timeout 3600 \
|
||||
--log "build/$arch/$config/ps2-check.log" \
|
||||
--step "expect:login:" \
|
||||
--step "send:root" \
|
||||
--step "expect:assword:" \
|
||||
--step "send:password" \
|
||||
--step "expect:Type 'help' for available commands." \
|
||||
--step "send:redbear-phase-ps2-check" \
|
||||
--step "expect:Red Bear OS PS/2 Runtime Check" \
|
||||
--step "expect:present=/scheme/serio/0" \
|
||||
--step "expect:present=/scheme/serio/1" \
|
||||
--step "expect:phase3_input_check=ok" \
|
||||
--step "send:shutdown" \
|
||||
--pass_marker "phase3_input_check=ok" \
|
||||
-- \
|
||||
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,snapshot=on -device nvme,drive=drv1,serial=NVME_EXTRA -enable-kvm -cpu host $extra_qemu_args || 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/3)"
|
||||
sleep 2
|
||||
continue
|
||||
fi
|
||||
exit "$rc"
|
||||
done
|
||||
pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true
|
||||
echo "PS/2 serio runtime validation completed via guest runtime check"
|
||||
exit 0
|
||||
@@ -129,9 +143,8 @@ exec qemu-system-x86_64 \
|
||||
-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,snapshot=on \
|
||||
-device nvme,drive=drv0,serial=NVME_SERIAL \
|
||||
-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 \
|
||||
|
||||
Reference in New Issue
Block a user