diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-01 15:53:29 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-01 15:53:29 +0100 |
| commit | 7958276c9f0d230053520ba20f2a00f5ecda18e4 (patch) | |
| tree | 596f5f71ad597ed951bae98de818cb37f171a18d /scripts/tests/test-mouse.sh | |
| parent | fs: /bin alias for the system volume (diff) | |
| download | rs-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-x | scripts/tests/test-mouse.sh | 83 |
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 | # | ||
| 12 | set -euo pipefail | ||
| 13 | TNAME="mouse" | ||
| 14 | # shellcheck source=../lib.sh | ||
| 15 | source "$(dirname "$0")/../lib.sh" | ||
| 16 | |||
| 17 | # cursor_state — one-shot `cursor` command, parsed to "x y buttons". | ||
| 18 | cursor_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 | |||
| 24 | echo "==> 1/6 build (kernel + bins)" | ||
| 25 | build_all | ||
| 26 | |||
| 27 | echo "==> 2/6 stage system image" | ||
| 28 | stage_image --force | ||
| 29 | |||
| 30 | echo "==> 3/6 boot QEMU (headless)" | ||
| 31 | test_boot | ||
| 32 | grep -aq "ps2: mouse ready" "$LOG" || fail "mouse driver did not come up at boot" | ||
| 33 | wait_log "$LOG" "cursor: task " 10 || fail "cursor task did not spawn" | ||
| 34 | |||
| 35 | echo "==> 4/6 cursor position tracks injected movement" | ||
| 36 | INIT=$(cursor_state) | ||
| 37 | [ -n "$INIT" ] || fail "no initial cursor position" | ||
| 38 | IX=$(echo "$INIT" | awk '{print $1}') | ||
| 39 | IY=$(echo "$INIT" | awk '{print $2}') | ||
| 40 | IB=$(echo "$INIT" | awk '{print $3}') | ||
| 41 | echo " initial: x=$IX y=$IY buttons=$IB" | ||
| 42 | [ "$IB" = "---" ] || fail "expected no buttons at boot, got $IB" | ||
| 43 | |||
| 44 | qemu_hmp "mouse_move 20 7" | ||
| 45 | S1=$(cursor_state) | ||
| 46 | X1=$(echo "$S1" | awk '{print $1}') | ||
| 47 | Y1=$(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)" | ||
| 50 | echo " moved: x=$X1 y=$Y1 (delta +20,+7)" | ||
| 51 | |||
| 52 | echo "==> 5/6 left button edge detection" | ||
| 53 | qemu_hmp "mouse_button 1" | ||
| 54 | S2=$(cursor_state) | ||
| 55 | IB2=$(echo "$S2" | awk '{print $3}') | ||
| 56 | [ "$IB2" = "L--" ] || fail "expected L--, got $IB2" | ||
| 57 | |||
| 58 | qemu_hmp "mouse_button 0" | ||
| 59 | S3=$(cursor_state) | ||
| 60 | IB3=$(echo "$S3" | awk '{print $3}') | ||
| 61 | [ "$IB3" = "---" ] || fail "expected --- after release, got $IB3" | ||
| 62 | echo " button: $IB2 → $IB3" | ||
| 63 | |||
| 64 | echo "==> 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. | ||
| 67 | sendkeys "msgrecv" | ||
| 68 | sleep 1 | ||
| 69 | MID="$(sed -n 's/.*msgrecv: task \([0-9][0-9]*\) listening.*/\1/p' "$LOG" | tail -1)" | ||
| 70 | [ -n "$MID" ] || fail "msgrecv did not spawn" | ||
| 71 | echo " msgrecv task id: $MID" | ||
| 72 | sendkeys "mouse $MID" | ||
| 73 | qemu_hmp "mouse_move 20 7" | ||
| 74 | qemu_hmp "mouse_button 1" | ||
| 75 | sleep 0.5 | ||
| 76 | qemu_hmp "mouse_button 0" | ||
| 77 | sleep 0.5 | ||
| 78 | sendkeys "ctrl-c" | ||
| 79 | sleep 0.5 | ||
| 80 | grep -aq "Mouse(+20,+7" "$LOG" || fail "routed mouse move not logged" | ||
| 81 | |||
| 82 | echo "" | ||
| 83 | echo "PASS — mouse round trip" | ||
