diff options
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" | ||
