diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-01 19:52:05 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-01 19:52:05 +0200 |
| commit | 819778f292ee4e1294603b98662e083e49e23463 (patch) | |
| tree | 8df31b678432d2a89cac8e0d50f271a75a3882b5 /scripts/test-gfx.sh | |
| parent | rsnix v0.4.0: GUI input foundation — PS/2 mouse + scheduler message queues (diff) | |
| download | rs-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-x | scripts/test-gfx.sh | 114 |
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 | # | ||
| 16 | set -euo pipefail | ||
| 17 | |||
| 18 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| 19 | PROJECT_DIR="$(dirname "$SCRIPT_DIR")" | ||
| 20 | cd "$PROJECT_DIR" | ||
| 21 | |||
| 22 | OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" | ||
| 23 | QEMU="${QEMU:-qemu-system-x86_64}" | ||
| 24 | ESP_DIR="$PROJECT_DIR/esp" | ||
| 25 | QPID=/tmp/rsdos-gfx-qpid | ||
| 26 | SOCK=/tmp/rsdos-gfx-qmon.sock | ||
| 27 | LOG=/tmp/rsdos-gfx-serial.log | ||
| 28 | QLOG=/tmp/rsdos-gfx-qemu.log | ||
| 29 | |||
| 30 | trap 'kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true' EXIT | ||
| 31 | |||
| 32 | fail() { | ||
| 33 | echo "FAIL: $1" | ||
| 34 | [ -f "$LOG" ] && tail -40 "$LOG" | ||
| 35 | exit 1 | ||
| 36 | } | ||
| 37 | |||
| 38 | wait_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 | |||
| 48 | wait_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 | |||
| 58 | qemu_hmp() { | ||
| 59 | python3 - "$SOCK" "$1" <<'EOF' | ||
| 60 | import socket, sys, time | ||
| 61 | s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
| 62 | s.connect(sys.argv[1]) | ||
| 63 | s.sendall((sys.argv[2] + "\n").encode()) | ||
| 64 | time.sleep(0.4) | ||
| 65 | EOF | ||
| 66 | } | ||
| 67 | |||
| 68 | echo "==> 1/5 build kernel (debug)" | ||
| 69 | cargo build --package rsdos --target x86_64-unknown-uefi | ||
| 70 | |||
| 71 | echo "==> 2/5 deploy to ESP" | ||
| 72 | mkdir -p "$ESP_DIR/EFI/BOOT" | ||
| 73 | cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI" | ||
| 74 | |||
| 75 | echo "==> 3/5 boot QEMU (headless)" | ||
| 76 | kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true | ||
| 77 | sleep 1 | ||
| 78 | rm -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 & | ||
| 85 | echo $! >"$QPID" | ||
| 86 | |||
| 87 | wait_log "$LOG" "boot: entering shell" 90 || fail "kernel never reached the shell" | ||
| 88 | grep -aq "cursor: task " "$LOG" || fail "cursor task did not spawn" | ||
| 89 | |||
| 90 | echo "==> 4/5 in-kernel pixel self-test (gfx check)" | ||
| 91 | python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ | ||
| 92 | "clear" \ | ||
| 93 | "gfx check" | ||
| 94 | sleep 1.5 | ||
| 95 | |||
| 96 | # Every sub-check must have printed OK. | ||
| 97 | grep -aq "fill_rect/shadow: OK" "$LOG" || fail "shadow writeback failed" | ||
| 98 | grep -aq "display push: OK" "$LOG" || fail "shadow→display push failed" | ||
| 99 | grep -aq "cursor overlay: OK" "$LOG" || fail "cursor not composited on display" | ||
| 100 | grep -aq "cursor not in shadow: OK" "$LOG" || fail "cursor leaked into the shadow" | ||
| 101 | grep -aq "gfx check: PASS" "$LOG" || fail "gfx check did not PASS" | ||
| 102 | grep -aq "gfx check: FAIL" "$LOG" && fail "gfx check reported FAIL" | ||
| 103 | |||
| 104 | echo "==> 5/5 demo scene + poweroff" | ||
| 105 | python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ | ||
| 106 | "gfx" \ | ||
| 107 | "poweroff" | ||
| 108 | wait_qemu_exit 30 || fail "QEMU did not exit after poweroff" | ||
| 109 | |||
| 110 | grep -aq "gfx: drew status bar" "$LOG" || fail "gfx demo did not draw" | ||
| 111 | |||
| 112 | echo "" | ||
| 113 | echo "PASS — graphics layer OK (shadow, display push, cursor overlay)" | ||
| 114 | echo " compositor: shadow=content, display=push+cursor, cursor never in shadow" | ||
