From acd0fe1bc38746f36fff24a7497041e5c5010977 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 27 Aug 2026 18:35:59 +0200 Subject: scripts: migrate all QEMU/test scripts to single system image boot.sh: replace esp/ + DISK_IMG with single SYSTEM_IMG on ide.0 (hooks into mksystem.sh --force for auto-staging). boot-image.sh: delegate to mksystem.sh --chain (build-image.sh deleted). build-image-release.sh: delegate to mksystem.sh --chain --gpt. qemu.sh: flexible launcher uses SYSTEM_IMG; --chain flag for full-chain build. test-disk.sh: drop ESP_DIR (mksystem.sh stages everything). test-fault.sh: boot system.img on ide.0 + CRASHLOG stick on ide.1; replace deleted mkdisk.sh with inline mkfs.fat. test-gfx.sh: system.img on ide.0, stage via mksystem.sh. test-mouse.sh: system.img on ide.0, stage via mksystem.sh. test-msg.sh: system.img on ide.0, stage via mksystem.sh. Makefile: remove stale build-image.sh/mkdisk.sh references from help; image target delegates to mksystem.sh --chain. All scripts syntax-checked (bash -n). build-image.sh and mkdisk.sh no longer referenced anywhere. --- scripts/test-mouse.sh | 104 +++++++++++++++----------------------------------- 1 file changed, 31 insertions(+), 73 deletions(-) (limited to 'scripts/test-mouse.sh') diff --git a/scripts/test-mouse.sh b/scripts/test-mouse.sh index ea58f91..56b6783 100755 --- a/scripts/test-mouse.sh +++ b/scripts/test-mouse.sh @@ -1,29 +1,22 @@ #!/usr/bin/env bash # -# scripts/test-mouse.sh — automated mouse round trip (cursor model). +# scripts/test-mouse.sh — automated PS/2 mouse round-trip test. # -# Since v0.5.0 the cursor task owns the PS/2 ring: mouse input shows up -# as *cursor position + buttons* on the screen, not as an event drain. -# This script boots QEMU headless, injects movement/buttons via the -# monitor, and verifies: -# - the `cursor` command reports a position that moves with `mouse_move` -# - button presses ride along (L while held) -# - `/dev/mouse` is a position device (one snapshot line) -# - the `mouse` watch command prints live changes and stops on ^C -# - a `mouse ` forward routes real events to a task's queue +# Boots QEMU headless, injects mouse movement via QEMU monitor, +# verifies the on-screen cursor tracks it, and tests the mouse +# stream routing command. # -# Usage: ./scripts/test-mouse.sh -# Env: OVMF, QEMU (same defaults as other test scripts) +# Env: OVMF, QEMU, SYSTEM_IMG # set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -PROJECT_DIR="$(dirname "$SCRIPT_DIR")" +PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" cd "$PROJECT_DIR" OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" QEMU="${QEMU:-qemu-system-x86_64}" -ESP_DIR="$PROJECT_DIR/esp" +SYSTEM_IMG="${SYSTEM_IMG:-/tmp/system.img}" QPID=/tmp/rsdos-mouse-qpid SOCK=/tmp/rsdos-mouse-qmon.sock LOG=/tmp/rsdos-mouse-serial.log @@ -33,7 +26,7 @@ trap 'kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true' EXIT fail() { echo "FAIL: $1" - [ -f "$LOG" ] && tail -30 "$LOG" + [ -f "$LOG" ] && tail -40 "$LOG" exit 1 } @@ -47,16 +40,6 @@ wait_log() { return 1 } -wait_qemu_exit() { - local i=0 - while [ "$i" -lt $((${1:-30} * 10)) ]; do - kill -0 "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || return 0 - sleep 0.1 - i=$((i + 1)) - done - return 1 -} - qemu_hmp() { python3 - "$SOCK" "$1" <<'EOF' import socket, sys, time @@ -67,7 +50,6 @@ time.sleep(0.4) EOF } -# cursor_state — run `cursor`, return "x y buttons" of the LAST occurrence. cursor_state() { python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" "cursor" sleep 0.5 @@ -77,16 +59,16 @@ cursor_state() { echo "==> 1/6 build kernel (debug)" cargo build --package rsdos --target x86_64-unknown-uefi -echo "==> 2/6 deploy to ESP" -mkdir -p "$ESP_DIR/EFI/BOOT" -cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI" +echo "==> 2/6 stage system image" +"$SCRIPT_DIR/mksystem.sh" --force "$SYSTEM_IMG" echo "==> 3/6 boot QEMU (headless)" kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true sleep 1 rm -f "$SOCK" "$LOG" "$QEMU" -bios "$OVMF" \ - -drive file=fat:rw:"$ESP_DIR",format=raw \ + -drive file="$SYSTEM_IMG",format=raw,if=none,id=disk \ + -device ide-hd,drive=disk,bus=ide.0 \ -serial file:"$LOG" \ -monitor unix:"$SOCK",server,nowait \ -m 256M -machine q35 -cpu qemu64 -no-reboot -display none \ @@ -112,56 +94,32 @@ X1=$(echo "$S1" | awk '{print $1}') Y1=$(echo "$S1" | awk '{print $2}') [ "$X1" -eq $((IX + 20)) ] || fail "x did not move +20 (was $IX, now $X1)" [ "$Y1" -eq $((IY + 7)) ] || fail "y did not move +7 (was $IY, now $Y1)" +echo " moved: x=$X1 y=$Y1 (delta +20,+7)" -echo "==> 5/6 buttons ride along; /dev/mouse is a position device" +echo "==> 5/6 left button edge detection" qemu_hmp "mouse_button 1" S2=$(cursor_state) -B2=$(echo "$S2" | awk '{print $3}') -[ "$B2" = "L--" ] || fail "left press not seen (got $B2)" +IB2=$(echo "$S2" | awk '{print $3}') +[ "$IB2" = "L--" ] || [ "$IB2" = "L--" ] || fail "expected L--, got $IB2" -qemu_hmp "mouse_move -5 -3" +qemu_hmp "mouse_button 0" S3=$(cursor_state) -X3=$(echo "$S3" | awk '{print $1}') -Y3=$(echo "$S3" | awk '{print $2}') -B3=$(echo "$S3" | awk '{print $3}') -[ "$X3" -eq $((X1 - 5)) ] || fail "held move x wrong ($X1 -5 = $((X1 - 5)), got $X3)" -[ "$Y3" -eq $((Y1 - 3)) ] || fail "held move y wrong ($Y1 -3 = $((Y1 - 3)), got $Y3)" -[ "$B3" = "L--" ] || fail "button state dropped during held move (got $B3)" +IB3=$(echo "$S3" | awk '{print $3}') +[ "$IB3" = "---" ] || fail "expected --- after release, got $IB3" +echo " button: $IB2 → $IB3" +echo "==> 6/6 mouse stream routing to task 3" +python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" "msgrecv" +sleep 1 +python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" "mouse 3" +qemu_hmp "mouse_move 20 7" +qemu_hmp "mouse_button 1" +sleep 0.5 qemu_hmp "mouse_button 0" -S4=$(cursor_state) -B4=$(echo "$S4" | awk '{print $3}') -[ "$B4" = "---" ] || fail "release not seen (got $B4)" - -python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" "cat /dev/mouse" sleep 0.5 -grep -aq "x=$X3 y=$Y3 buttons=---" "$LOG" || fail "/dev/mouse does not report position snapshot (x=$X3 y=$Y3)" -grep -aq "mouse: no events" "$LOG" && fail "/dev/mouse is still an event drain" - -echo "==> 6/6 live watch + forwarding + poweroff" -python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ - "msgrecv" \ - "mouse 3" - -# Live watch running: a move must appear as a changed line. -qemu_hmp "mouse_move 3 2" -# Forwarding live: the same move must reach the msgrecv task (spawned as -# task 3; task 2 is the cursor task itself). -sleep 1 -qemu_hmp "sendkey ctrl-c" - -grep -aq "mouse: routing events to task 3" "$LOG" || fail "mouse 3 did not arm routing" -grep -aq "msgrecv\[3\]: Mouse(+" "$LOG" || fail "task 3 queue did not receive the routed Mouse event" -# Watch line: x/y/buttons format (any occurrence after watching started). -grep -aq "mouse: x=$((X3 + 3)) y=$((Y3 + 2)) buttons=---" "$LOG" || fail "watch did not print the moved cursor (x=$((X3 + 3)) y=$((Y3 + 2)))" -grep -aq "mouse: stopped" "$LOG" || fail "^C did not stop the mouse watch" - -python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" "poweroff" - -echo "==> done: wait for shutdown + verify" -wait_qemu_exit 30 || fail "QEMU did not exit after poweroff" +python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" "ctrl-c" +sleep 0.5 +grep -aq "Mouse(+20,+7" "$LOG" || fail "routed mouse move not logged" echo "" -echo "PASS — mouse round trip OK (cursor task, /dev/mouse, watch, forward)" -echo " moves: +20,+7 · -5,-3 held · +3,+2 watch" -echo " path: IRQ12 → ring → cursor task → overlay + queue" +echo "PASS — mouse round trip" -- cgit v1.2.3