From 569f05debcba4045bac634a131abea37bf38716a Mon Sep 17 00:00:00 2001 From: vasilito Date: Mon, 20 Jul 2026 00:14:30 +0900 Subject: [PATCH] tests: boot low-level + storage proofs from live ISO, not stale harddrive.img MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All six validation scripts (xhci-irq, msix, ps2, timer, iommu, usb-storage) booted build///harddrive.img, which is only produced by older make-all flows and goes stale (the Jul-17 image). Running them against it measured the wrong tree — the same trap that produced the false '+rb0.3.0' bootloader reading and the first hub-test failure. Each now prefers build//.iso via -cdrom and only falls back to harddrive.img when no ISO exists. extra.img and usb-storage.img remain as data drives in both modes. --- local/scripts/test-iommu-qemu.sh | 20 +++++++++++++++---- local/scripts/test-msix-qemu.sh | 21 +++++++++++++++----- local/scripts/test-ps2-qemu.sh | 20 +++++++++++++++---- local/scripts/test-timer-qemu.sh | 20 +++++++++++++++---- local/scripts/test-usb-storage-qemu.sh | 26 +++++++++++++++++++++---- local/scripts/test-xhci-irq-qemu.sh | 27 +++++++++++++++++++------- 6 files changed, 106 insertions(+), 28 deletions(-) diff --git a/local/scripts/test-iommu-qemu.sh b/local/scripts/test-iommu-qemu.sh index cc663f944f..aea5e6a464 100755 --- a/local/scripts/test-iommu-qemu.sh +++ b/local/scripts/test-iommu-qemu.sh @@ -79,12 +79,18 @@ firmware="$(find_uefi_firmware)" || { } arch="${ARCH:-$(uname -m)}" +iso="build/$arch/$config.iso" image="build/$arch/$config/harddrive.img" extra="build/$arch/$config/extra.img" extra_qemu_args="${filtered_args[*]:-}" -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 1 fi @@ -93,14 +99,20 @@ if [[ ! -f "$extra" ]]; then truncate -s 1g "$extra" fi -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +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 + +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 if [[ "$check_mode" -eq 1 ]]; then expect <&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 1 fi @@ -64,7 +70,13 @@ if [[ ! -f "$extra" ]]; then truncate -s 1g "$extra" fi -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +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 + +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 rm -f "$log_file" @@ -84,8 +96,7 @@ timeout 90s qemu-system-x86_64 \ -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 \ + "${boot_args[@]}" \ -drive file="$extra",format=raw,if=none,id=drv1,snapshot=on \ -device nvme,drive=drv1,serial=NVME_EXTRA \ -enable-kvm -cpu host \ diff --git a/local/scripts/test-ps2-qemu.sh b/local/scripts/test-ps2-qemu.sh index 2ed18a89fd..10910008ab 100755 --- a/local/scripts/test-ps2-qemu.sh +++ b/local/scripts/test-ps2-qemu.sh @@ -63,12 +63,18 @@ firmware="$(find_uefi_firmware)" || { } arch="${ARCH:-$(uname -m)}" +iso="build/$arch/$config.iso" image="build/$arch/$config/harddrive.img" extra="build/$arch/$config/extra.img" extra_qemu_args="${filtered_args[*]:-}" -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 1 fi @@ -77,14 +83,20 @@ if [[ ! -f "$extra" ]]; then truncate -s 1g "$extra" fi -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +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 + +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 if [[ "$check_mode" -eq 1 ]]; then expect <&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 1 fi @@ -77,14 +83,20 @@ if [[ ! -f "$extra" ]]; then truncate -s 1g "$extra" fi -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +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 + +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 if [[ "$check_mode" -eq 1 ]]; then expect <&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 1 fi @@ -85,9 +95,17 @@ if [[ ! -f "$usb_img" ]]; then truncate -s 64M "$usb_img" fi +# Boot-disk args: ISO via -cdrom, or legacy harddrive via nvme. Data drives +# (extra, usb-storage) are always attached the same way. +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 + expected_sector_b64="$(seed_usb_image "$usb_img")" -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 rm -f "$log_file" @@ -95,7 +113,7 @@ expect <&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 1 fi @@ -72,7 +81,13 @@ if [[ ! -f "$extra" ]]; then truncate -s 1g "$extra" fi -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +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 + +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 if [[ "$check_mode" -eq 1 ]]; then @@ -96,8 +111,7 @@ if [[ "$check_mode" -eq 1 ]]; then -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 \ + "${boot_args[@]}" \ -drive file="$extra",format=raw,if=none,id=drv1,snapshot=on \ -device nvme,drive=drv1,serial=NVME_EXTRA \ -enable-kvm -cpu host \ @@ -175,8 +189,7 @@ exec qemu-system-x86_64 \ -netdev user,id=net0 \ -object filter-dump,id=f1,netdev=net0,file="build/$arch/$config/network.pcap" \ -vga std \ - -drive file="$image",format=raw,if=none,id=drv0,snapshot=on \ - -device nvme,drive=drv0,serial=NVME_SERIAL \ + "${boot_args[@]}" \ -drive file="$extra",format=raw,if=none,id=drv1,snapshot=on \ -device nvme,drive=drv1,serial=NVME_EXTRA \ -enable-kvm -cpu host