summaryrefslogtreecommitdiffstats
path: root/scripts/tests/test-mouse.sh
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-01 15:53:29 +0100
committersalmonik <salmonik@tuta.io>2026-11-01 15:53:29 +0100
commit7958276c9f0d230053520ba20f2a00f5ecda18e4 (patch)
tree596f5f71ad597ed951bae98de818cb37f171a18d /scripts/tests/test-mouse.sh
parentfs: /bin alias for the system volume (diff)
downloadrs-dos-7958276c9f0d230053520ba20f2a00f5ecda18e4.tar.gz
rs-dos-7958276c9f0d230053520ba20f2a00f5ecda18e4.zip
scripts: rebuild the dev loop around build.sh/run.sh
`make` did not parse at all (missing separator at line 139), so every make target was dead. The folder also carried three overlapping launchers (boot.sh, qemu.sh, boot-image.sh) plus a fourth partial one in the Makefile, `cargo build --package rsdos` copy-pasted eight times, the QEMU invocation copy-pasted per script, and the test helpers (fail/wait_log/wait_qemu_exit/qemu_hmp) duplicated in five tests. New layout: - scripts/lib.sh: single config (image, OVMF, mem/smp), the one cargo invocation (build_all), the one QEMU shape (qemu_args), and the test harness (test_boot, wait_log, wait_qemu_exit, qemu_hmp, sendkeys) - scripts/build.sh: kernel + every bins/* in one pass - scripts/mksystem.sh: freshness-aware image build that now stages every bins/*.efi into /bin/cli|gui (they were never copied before) - scripts/run.sh: build + stage + boot in one command; --headless, --debug (GDB stub), --monitor (HMP socket), --fresh, --mem/--smp/ --bios/--image; on Wayland it auto-selects XWayland plus grab-on-hover so the mouse can be captured (Ctrl+Alt+G toggles) - scripts/tests/: the five automated tests on the shared harness - deleted: boot.sh, qemu.sh, boot-image.sh, lib-boot-args.sh, build-image-release.sh, build-bootloader.sh (rsboot chain dropped) The Makefile is now a thin wrapper: make run, make test, make system, make inspect, make help. Two-command flow: ./scripts/build.sh then ./scripts/run.sh (run.sh alone also works). Stale test assumptions fixed so the suite is green again: test-gfx waited for "gfx: check" while the shell prints "gfx check: PASS"; test-mouse/test-msg hardcoded msgrecv = task 3 (wm-input took slot 3 — ids are parsed from the log now); the queue-full probe targeted task 0, whose exec pump drains its own queue as completion codes (moved to the cursor task, which never recvs). Verified in QEMU: make test -> test-disk, test-gfx, test-mouse, test-msg, test-fault all PASS.
Diffstat (limited to 'scripts/tests/test-mouse.sh')
-rwxr-xr-xscripts/tests/test-mouse.sh83
1 files changed, 83 insertions, 0 deletions
diff --git a/scripts/tests/test-mouse.sh b/scripts/tests/test-mouse.sh
new file mode 100755
index 0000000..bb835be
--- /dev/null
+++ b/scripts/tests/test-mouse.sh
@@ -0,0 +1,83 @@
1#!/usr/bin/env bash
2#
3# scripts/tests/test-mouse.sh — automated PS/2 mouse round-trip test.
4#
5# Boots QEMU headless, injects mouse movement via the QEMU monitor,
6# verifies the on-screen cursor tracks it, and tests the mouse stream
7# routing command.
8#
9# Usage: ./scripts/tests/test-mouse.sh
10# Env: SYSTEM_IMG, OVMF, QEMU (see scripts/lib.sh)
11#
12set -euo pipefail
13TNAME="mouse"
14# shellcheck source=../lib.sh
15source "$(dirname "$0")/../lib.sh"
16
17# cursor_state — one-shot `cursor` command, parsed to "x y buttons".
18cursor_state() {
19 sendkeys "cursor"
20 sleep 0.5
21 sed -n 's/.*cursor: x=\([0-9]*\) y=\([0-9]*\) buttons=\([A-Za-z-]*\).*/\1 \2 \3/p' "$LOG" | tail -1
22}
23
24echo "==> 1/6 build (kernel + bins)"
25build_all
26
27echo "==> 2/6 stage system image"
28stage_image --force
29
30echo "==> 3/6 boot QEMU (headless)"
31test_boot
32grep -aq "ps2: mouse ready" "$LOG" || fail "mouse driver did not come up at boot"
33wait_log "$LOG" "cursor: task " 10 || fail "cursor task did not spawn"
34
35echo "==> 4/6 cursor position tracks injected movement"
36INIT=$(cursor_state)
37[ -n "$INIT" ] || fail "no initial cursor position"
38IX=$(echo "$INIT" | awk '{print $1}')
39IY=$(echo "$INIT" | awk '{print $2}')
40IB=$(echo "$INIT" | awk '{print $3}')
41echo " initial: x=$IX y=$IY buttons=$IB"
42[ "$IB" = "---" ] || fail "expected no buttons at boot, got $IB"
43
44qemu_hmp "mouse_move 20 7"
45S1=$(cursor_state)
46X1=$(echo "$S1" | awk '{print $1}')
47Y1=$(echo "$S1" | awk '{print $2}')
48[ "$X1" -eq $((IX + 20)) ] || fail "x did not move +20 (was $IX, now $X1)"
49[ "$Y1" -eq $((IY + 7)) ] || fail "y did not move +7 (was $IY, now $Y1)"
50echo " moved: x=$X1 y=$Y1 (delta +20,+7)"
51
52echo "==> 5/6 left button edge detection"
53qemu_hmp "mouse_button 1"
54S2=$(cursor_state)
55IB2=$(echo "$S2" | awk '{print $3}')
56[ "$IB2" = "L--" ] || fail "expected L--, got $IB2"
57
58qemu_hmp "mouse_button 0"
59S3=$(cursor_state)
60IB3=$(echo "$S3" | awk '{print $3}')
61[ "$IB3" = "---" ] || fail "expected --- after release, got $IB3"
62echo " button: $IB2 → $IB3"
63
64echo "==> 6/6 mouse stream routing to msgrecv's task"
65# The spawned task id shifts with the task table (wm-input took slot 3) —
66# parse it rather than hardcoding.
67sendkeys "msgrecv"
68sleep 1
69MID="$(sed -n 's/.*msgrecv: task \([0-9][0-9]*\) listening.*/\1/p' "$LOG" | tail -1)"
70[ -n "$MID" ] || fail "msgrecv did not spawn"
71echo " msgrecv task id: $MID"
72sendkeys "mouse $MID"
73qemu_hmp "mouse_move 20 7"
74qemu_hmp "mouse_button 1"
75sleep 0.5
76qemu_hmp "mouse_button 0"
77sleep 0.5
78sendkeys "ctrl-c"
79sleep 0.5
80grep -aq "Mouse(+20,+7" "$LOG" || fail "routed mouse move not logged"
81
82echo ""
83echo "PASS — mouse round trip"