#!/usr/bin/env bash # # scripts/tests/test-fault.sh — fault-diagnostics verification. # # Proves the fault-dump path: every CPU exception prints a white-on-red # band to the framebuffer and a parseable serial line before halting. # Boots with a dedicated CRASHLOG FAT stick on ide.1 so the crash band # has somewhere to write. # # Usage: ./scripts/tests/test-fault.sh # Env: SYSTEM_IMG, OVMF, QEMU (see scripts/lib.sh) # set -euo pipefail TNAME="fault" # shellcheck source=../lib.sh source "$(dirname "$0")/../lib.sh" echo "==> 1/5 build (kernel + bins)" build_all echo "==> 2/5 stage system image" stage_image --force echo "==> 3/5 boot QEMU (headless, + dedicated CRASHLOG stick)" CRASH_IMG=/tmp/rsdos-crash.img rm -f "$CRASH_IMG" mkfs.fat -C -F 32 -n CRASHLOG "$CRASH_IMG" 65536 >/dev/null test_boot \ -drive "file=$CRASH_IMG,format=raw,if=none,id=crash" \ -device ide-hd,drive=crash,bus=ide.1 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/5 inject a page fault (fault command)" sendkeys "clear" "fault" sleep 2 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 "" echo "PASS — fault dump verified"