summaryrefslogtreecommitdiffstats
path: root/scripts/tests/test-fault.sh
blob: 0c39cde8c2f52d2ad7a786eae1aea3965fa5dcf6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/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"