summaryrefslogtreecommitdiffstats
path: root/scripts/test-gfx.sh
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-08-01 19:52:05 +0200
committersalmonik <salmonik@tuta.io>2026-08-01 19:52:05 +0200
commit819778f292ee4e1294603b98662e083e49e23463 (patch)
tree8df31b678432d2a89cac8e0d50f271a75a3882b5 /scripts/test-gfx.sh
parentrsnix v0.4.0: GUI input foundation — PS/2 mouse + scheduler message queues (diff)
downloadrs-dos-819778f292ee4e1294603b98662e083e49e23463.tar.gz
rs-dos-819778f292ee4e1294603b98662e083e49e23463.zip
rsnix v0.5.0: graphics layer + cursor compositor
The first visible GUI surface: real rect primitives, a single shadow→display push path, and an on-screen mouse cursor that can never race the text surface. gop: - fill_rect + push_rect(x,y,w,h): every raster op rasterises into the RAM shadow, then push_rect copies the rect to the display (write-only, still never read) and composites the cursor on top. blit_glyph and scroll shifts now route through it. - cursor overlay: 12x16 pointer (const-fn built from column lists) drawn white with a black offset outline; position in one AtomicU64 (x:high 32, y:low 32) — unpack masks the low word (a bare 'as usize' cast is a no-op on 64-bit). The cursor never enters the shadow, so erasing is just a shadow push of the old rect. - cursor_redraw after scroll shifts and once at spawn (the vt diff never re-blits idle cells). cursor task (task 2, spawned at boot when a mouse is present): - owns the PS/2 ring; polls every 10 ms, moves the cursor (clamped), tracks buttons, and forwards every event to a task's queue when 'mouse <id>' armed it (the window-manager input path). - /dev/mouse is now a position device (x/y/buttons snapshot); 'mouse' watches the cursor live (prints on change); 'cursor' prints one-shot state; 'gfx' draws a status-bar demo; 'gfx check' is an in-kernel pixel self-test (shadow readback, display readback, cursor overlay purity) — PASS/FAIL per stage. Tests (headless QEMU + monitor injection): - make test-gfx (new): all four compositor checks PASS. - make test-mouse (rewritten): cursor tracks mouse_move deltas, buttons ride along, /dev/mouse snapshot, live watch, real-event queue routing. - make test-msg: task numbering shifted (cursor is task 2; msgrecv is task 3) — updated, still PASS. - make test-disk regression re-passes. 0 build warnings.
Diffstat (limited to '')
-rwxr-xr-xscripts/test-gfx.sh114
1 files changed, 114 insertions, 0 deletions
diff --git a/scripts/test-gfx.sh b/scripts/test-gfx.sh
new file mode 100755
index 0000000..a6e4016
--- /dev/null
+++ b/scripts/test-gfx.sh
@@ -0,0 +1,114 @@
1#!/usr/bin/env bash
2#
3# scripts/test-gfx.sh — automated graphics-layer verification.
4#
5# The cursor overlay compositor is the core of the GUI path: the shadow
6# holds true content, the display gets shadow pushes with the cursor
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#
13# Usage: ./scripts/test-gfx.sh
14# Env: OVMF, QEMU (same defaults as other test scripts)
15#
16set -euo pipefail
17
18SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
19PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
20cd "$PROJECT_DIR"
21
22OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}"
23QEMU="${QEMU:-qemu-system-x86_64}"
24ESP_DIR="$PROJECT_DIR/esp"
25QPID=/tmp/rsdos-gfx-qpid
26SOCK=/tmp/rsdos-gfx-qmon.sock
27LOG=/tmp/rsdos-gfx-serial.log
28QLOG=/tmp/rsdos-gfx-qemu.log
29
30trap 'kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true' EXIT
31
32fail() {
33 echo "FAIL: $1"
34 [ -f "$LOG" ] && tail -40 "$LOG"
35 exit 1
36}
37
38wait_log() {
39 local i=0
40 while [ "$i" -lt $((${3:-60} * 10)) ]; do
41 grep -q "$2" "$1" 2>/dev/null && return 0
42 sleep 0.1
43 i=$((i + 1))
44 done
45 return 1
46}
47
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)"
69cargo build --package rsdos --target x86_64-unknown-uefi
70
71echo "==> 2/5 deploy to ESP"
72mkdir -p "$ESP_DIR/EFI/BOOT"
73cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI"
74
75echo "==> 3/5 boot QEMU (headless)"
76kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true
77sleep 1
78rm -f "$SOCK" "$LOG"
79"$QEMU" -bios "$OVMF" \
80 -drive file=fat:rw:"$ESP_DIR",format=raw \
81 -serial file:"$LOG" \
82 -monitor unix:"$SOCK",server,nowait \
83 -m 256M -machine q35 -cpu qemu64 -no-reboot -display none \
84 >"$QLOG" 2>&1 &
85echo $! >"$QPID"
86
87wait_log "$LOG" "boot: entering shell" 90 || fail "kernel never reached the shell"
88grep -aq "cursor: task " "$LOG" || fail "cursor task did not spawn"
89
90echo "==> 4/5 in-kernel pixel self-test (gfx check)"
91python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \
92 "clear" \
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
104echo "==> 5/5 demo scene + poweroff"
105python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \
106 "gfx" \
107 "poweroff"
108wait_qemu_exit 30 || fail "QEMU did not exit after poweroff"
109
110grep -aq "gfx: drew status bar" "$LOG" || fail "gfx demo did not draw"
111
112echo ""
113echo "PASS — graphics layer OK (shadow, display push, cursor overlay)"
114echo " compositor: shadow=content, display=push+cursor, cursor never in shadow"