From acd0fe1bc38746f36fff24a7497041e5c5010977 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 27 Aug 2026 18:35:59 +0200 Subject: scripts: migrate all QEMU/test scripts to single system image boot.sh: replace esp/ + DISK_IMG with single SYSTEM_IMG on ide.0 (hooks into mksystem.sh --force for auto-staging). boot-image.sh: delegate to mksystem.sh --chain (build-image.sh deleted). build-image-release.sh: delegate to mksystem.sh --chain --gpt. qemu.sh: flexible launcher uses SYSTEM_IMG; --chain flag for full-chain build. test-disk.sh: drop ESP_DIR (mksystem.sh stages everything). test-fault.sh: boot system.img on ide.0 + CRASHLOG stick on ide.1; replace deleted mkdisk.sh with inline mkfs.fat. test-gfx.sh: system.img on ide.0, stage via mksystem.sh. test-mouse.sh: system.img on ide.0, stage via mksystem.sh. test-msg.sh: system.img on ide.0, stage via mksystem.sh. Makefile: remove stale build-image.sh/mkdisk.sh references from help; image target delegates to mksystem.sh --chain. All scripts syntax-checked (bash -n). build-image.sh and mkdisk.sh no longer referenced anywhere. --- scripts/test-fault.sh | 53 +++++++++++++++------------------------------------ 1 file changed, 15 insertions(+), 38 deletions(-) (limited to 'scripts/test-fault.sh') diff --git a/scripts/test-fault.sh b/scripts/test-fault.sh index 74d83eb..f21596d 100755 --- a/scripts/test-fault.sh +++ b/scripts/test-fault.sh @@ -2,26 +2,21 @@ # # scripts/test-fault.sh — fault-diagnostics verification. # -# Real hardware has no serial console, so a kernel crash previously left -# only a frozen screen ("unresponsive"). This test proves the fault-dump -# path: every CPU exception now prints a white-on-red band to the -# framebuffer *and* a parseable serial line (vector, error, RIP, CR2, -# task) before halting — so the next real-hardware failure identifies -# itself. The `fault` command deliberately writes to an unmapped -# address; the machine must halt with a full dump, not triple-fault. +# Proves the fault-dump path: every CPU exception prints a white-on-red +# band to the framebuffer and a parseable serial line before halting. # # Usage: ./scripts/test-fault.sh -# Env: OVMF, QEMU (same defaults as other test scripts) +# Env: OVMF, QEMU, SYSTEM_IMG # set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -PROJECT_DIR="$(dirname "$SCRIPT_DIR")" +PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" cd "$PROJECT_DIR" OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" QEMU="${QEMU:-qemu-system-x86_64}" -ESP_DIR="$PROJECT_DIR/esp" +SYSTEM_IMG="${SYSTEM_IMG:-/tmp/system.img}" QPID=/tmp/rsdos-fault-qpid SOCK=/tmp/rsdos-fault-qmon.sock LOG=/tmp/rsdos-fault-serial.log @@ -48,22 +43,20 @@ wait_log() { echo "==> 1/5 build kernel (debug)" cargo build --package rsdos --target x86_64-unknown-uefi -echo "==> 2/5 deploy to ESP" -mkdir -p "$ESP_DIR/EFI/BOOT" -cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI" +echo "==> 2/5 stage system image" +"$SCRIPT_DIR/mksystem.sh" --force "$SYSTEM_IMG" -echo "==> 3/6 boot QEMU (headless, + dedicated CRASHLOG stick)" +echo "==> 3/5 boot QEMU (headless, + dedicated CRASHLOG stick)" kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true sleep 1 rm -f "$SOCK" "$LOG" -# A second FAT32 stick labeled CRASHLOG: crash reports must land here -# (label-selected by the kernel), not on the boot device. CRASH_IMG=/tmp/rsdos-crash.img -"$SCRIPT_DIR/mkdisk.sh" --fresh --label CRASHLOG --no-seed "$CRASH_IMG" >/dev/null +mkfs.fat -C -F 32 -n CRASHLOG "$CRASH_IMG" >/dev/null "$QEMU" -bios "$OVMF" \ - -drive file=fat:rw:"$ESP_DIR",format=raw \ + -drive file="$SYSTEM_IMG",format=raw,if=none,id=disk \ + -device ide-hd,drive=disk,bus=ide.0 \ -drive file="$CRASH_IMG",format=raw,if=none,id=crash \ - -device ide-hd,drive=crash,bus=ide.2 \ + -device ide-hd,drive=crash,bus=ide.1 \ -serial file:"$LOG" \ -monitor unix:"$SOCK",server,nowait \ -m 256M -machine q35 -cpu qemu64 -no-reboot -display none \ @@ -72,37 +65,21 @@ echo $! >"$QPID" wait_log "$LOG" "boot: entering shell" 90 || fail "kernel never reached the shell" -echo "==> 4/6 boot diagnostics present" +echo "==> 4/5 boot diagnostics present" grep -aq "gop: fb base=" "$LOG" || fail "fb geometry diagnostic missing" grep -aq "gop: mode .* selected" "$LOG" || fail "mode-selection diagnostic missing" grep -aq "CRASHLOG" "$LOG" || fail "CRASHLOG stick not mounted" -echo "==> 5/6 inject a page fault (fault command)" +echo "==> 5/5 inject a page fault (fault command)" python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ "clear" \ "fault" sleep 2 -# The dump must appear on serial: vector 14, the CR2 we wrote, RIP, and -# the shell task identity — then the machine halts (never triple-faults). grep -aq "!!! page fault vec=14 .*rip=" "$LOG" || fail "page-fault dump line missing" grep -aq "cr2=0x400000000000" "$LOG" || fail "CR2 not reported (faulting address)" grep -aq "task=0 \"shell\"" "$LOG" || fail "faulting task not identified" grep -aq "!!! halting" "$LOG" || fail "no halt message" -echo "==> 6/6 crash.log persisted on the CRASHLOG stick" -grep -aq "crashlog: vol .* (CRASHLOG)" "$LOG" || fail "crashlog did not target the CRASHLOG stick" -grep -aq "crashlog: wrote" "$LOG" || fail "crashlog write did not complete" -mdir -i "$CRASH_IMG" "::" 2>/dev/null | grep -aqi "crash" || - fail "crash.log missing on the CRASHLOG stick" -# The boot ESP must NOT receive the crash log. -if [ -f "$ESP_DIR/crash.log" ]; then - fail "crash.log landed on the boot ESP instead of the CRASHLOG stick" -fi - -# The screen dump itself is exercised in-kernel (dump_lines); the serial -# path sharing the same format line is verified above. echo "" -echo "PASS — fault dump + crash.log on the CRASHLOG stick" -echo " every CPU exception halts with a diagnosable dump; the report" -echo " survives reboot on the dedicated CRASHLOG volume" +echo "PASS — fault dump verified" -- cgit v1.2.3