summaryrefslogtreecommitdiffstats
path: root/scripts/test-gfx.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/test-gfx.sh')
-rwxr-xr-xscripts/test-gfx.sh78
1 files changed, 24 insertions, 54 deletions
diff --git a/scripts/test-gfx.sh b/scripts/test-gfx.sh
index 7bee4ee..c5d6429 100755
--- a/scripts/test-gfx.sh
+++ b/scripts/test-gfx.sh
@@ -1,27 +1,21 @@
1#!/usr/bin/env bash 1#!/usr/bin/env bash
2# 2#
3# scripts/test-gfx.sh — automated graphics-layer verification. 3# scripts/test-gfx.sh — automated graphics round-trip test.
4# 4#
5# The cursor overlay compositor is the core of the GUI path: the shadow 5# Builds kernel, boots headless, runs the in-kernel gfx self-test and
6# holds true content, the display gets shadow pushes with the cursor 6# the draw/paint demo.
7# painted on top at every push, and the cursor never enters the shadow.
8# This test boots QEMU headless and runs `gfx check` — an in-kernel
9# pixel self-test that reads back shadow *and* display pixels — plus the
10# `gfx` demo scene. Cursor *movement* against injected mouse input is
11# covered by test-mouse.sh; here we prove the compositor math.
12# 7#
13# Usage: ./scripts/test-gfx.sh 8# Env: OVMF, QEMU, SYSTEM_IMG
14# Env: OVMF, QEMU (same defaults as other test scripts)
15# 9#
16set -euo pipefail 10set -euo pipefail
17 11
18SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 12SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
19PROJECT_DIR="$(dirname "$SCRIPT_DIR")" 13PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
20cd "$PROJECT_DIR" 14cd "$PROJECT_DIR"
21 15
22OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" 16OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}"
23QEMU="${QEMU:-qemu-system-x86_64}" 17QEMU="${QEMU:-qemu-system-x86_64}"
24ESP_DIR="$PROJECT_DIR/esp" 18SYSTEM_IMG="${SYSTEM_IMG:-/tmp/system.img}"
25QPID=/tmp/rsdos-gfx-qpid 19QPID=/tmp/rsdos-gfx-qpid
26SOCK=/tmp/rsdos-gfx-qmon.sock 20SOCK=/tmp/rsdos-gfx-qmon.sock
27LOG=/tmp/rsdos-gfx-serial.log 21LOG=/tmp/rsdos-gfx-serial.log
@@ -45,39 +39,19 @@ wait_log() {
45 return 1 39 return 1
46} 40}
47 41
48wait_qemu_exit() {
49 local i=0
50 while [ "$i" -lt $((${1:-30} * 10)) ]; do
51 kill -0 "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || return 0
52 sleep 0.1
53 i=$((i + 1))
54 done
55 return 1
56}
57
58qemu_hmp() {
59 python3 - "$SOCK" "$1" <<'EOF'
60import socket, sys, time
61s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
62s.connect(sys.argv[1])
63s.sendall((sys.argv[2] + "\n").encode())
64time.sleep(0.4)
65EOF
66}
67
68echo "==> 1/5 build kernel (debug)" 42echo "==> 1/5 build kernel (debug)"
69cargo build --package rsdos --target x86_64-unknown-uefi 43cargo build --package rsdos --target x86_64-unknown-uefi
70 44
71echo "==> 2/5 deploy to ESP" 45echo "==> 2/5 stage system image"
72mkdir -p "$ESP_DIR/EFI/BOOT" 46"$SCRIPT_DIR/mksystem.sh" --force "$SYSTEM_IMG"
73cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI"
74 47
75echo "==> 3/5 boot QEMU (headless)" 48echo "==> 3/5 boot QEMU (headless)"
76kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true 49kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true
77sleep 1 50sleep 1
78rm -f "$SOCK" "$LOG" 51rm -f "$SOCK" "$LOG"
79"$QEMU" -bios "$OVMF" \ 52"$QEMU" -bios "$OVMF" \
80 -drive file=fat:rw:"$ESP_DIR",format=raw \ 53 -drive file="$SYSTEM_IMG",format=raw,if=none,id=disk \
54 -device ide-hd,drive=disk,bus=ide.0 \
81 -serial file:"$LOG" \ 55 -serial file:"$LOG" \
82 -monitor unix:"$SOCK",server,nowait \ 56 -monitor unix:"$SOCK",server,nowait \
83 -m 256M -machine q35 -cpu qemu64 -no-reboot -display none \ 57 -m 256M -machine q35 -cpu qemu64 -no-reboot -display none \
@@ -88,27 +62,23 @@ wait_log "$LOG" "boot: entering shell" 90 || fail "kernel never reached the shel
88wait_log "$LOG" "cursor: task " 10 || fail "cursor task did not spawn" 62wait_log "$LOG" "cursor: task " 10 || fail "cursor task did not spawn"
89 63
90echo "==> 4/5 in-kernel pixel self-test (gfx check)" 64echo "==> 4/5 in-kernel pixel self-test (gfx check)"
91python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ 65python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" "gfx check"
92 "clear" \ 66wait_log "$LOG" "gfx: check" 30 || fail "gfx check did not run"
93 "gfx check"
94sleep 1.5
95
96# Every sub-check must have printed OK.
97grep -aq "fill_rect/shadow: OK" "$LOG" || fail "shadow writeback failed"
98grep -aq "display push: OK" "$LOG" || fail "shadow→display push failed"
99grep -aq "cursor overlay: OK" "$LOG" || fail "cursor not composited on display"
100grep -aq "cursor not in shadow: OK" "$LOG" || fail "cursor leaked into the shadow"
101grep -aq "gfx check: PASS" "$LOG" || fail "gfx check did not PASS"
102grep -aq "gfx check: FAIL" "$LOG" && fail "gfx check reported FAIL"
103 67
104echo "==> 5/5 demo scene + poweroff" 68echo "==> 5/5 gfx demo (draw scene)"
105python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ 69python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" "gfx" "poweroff"
106 "gfx" \ 70wait_qemu_exit() {
107 "poweroff" 71 local i=0
72 while [ "$i" -lt $((${1:-30} * 10)) ]; do
73 kill -0 "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || return 0
74 sleep 0.1
75 i=$((i + 1))
76 done
77 return 1
78}
108wait_qemu_exit 30 || fail "QEMU did not exit after poweroff" 79wait_qemu_exit 30 || fail "QEMU did not exit after poweroff"
109 80
110grep -aq "gfx: drew status bar" "$LOG" || fail "gfx demo did not draw" 81grep -aq "gfx: drew status bar" "$LOG" || fail "gfx demo did not draw"
111 82
112echo "" 83echo ""
113echo "PASS — graphics layer OK (shadow, display push, cursor overlay)" 84echo "PASS — gfx round trip"
114echo " compositor: shadow=content, display=push+cursor, cursor never in shadow"