From 7958276c9f0d230053520ba20f2a00f5ecda18e4 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 1 Nov 2026 15:53:29 +0100 Subject: scripts: rebuild the dev loop around build.sh/run.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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. --- scripts/tests/test-msg.sh | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100755 scripts/tests/test-msg.sh (limited to 'scripts/tests/test-msg.sh') diff --git a/scripts/tests/test-msg.sh b/scripts/tests/test-msg.sh new file mode 100755 index 0000000..7786beb --- /dev/null +++ b/scripts/tests/test-msg.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash +# +# scripts/tests/test-msg.sh — automated scheduler message-queue round trip. +# +# Tests all message types (user, timer, key, mouse), real-input routing, +# and the queue-full boundary. +# +# Usage: ./scripts/tests/test-msg.sh +# Env: SYSTEM_IMG, OVMF, QEMU (see scripts/lib.sh) +# +set -euo pipefail +TNAME="msg" +# shellcheck source=../lib.sh +source "$(dirname "$0")/../lib.sh" + +echo "==> 1/5 build (kernel + bins)" +build_all + +echo "==> 2/5 stage system image" +stage_image --force + +echo "==> 3/5 boot QEMU (headless)" +test_boot + +echo "==> 4/5 drive the shell (msgrecv / send / mouse routing / queue-full)" +# msgrecv's task id is assigned at spawn time and shifts when the task +# table grows (the Windowed GUI added wm-input at slot 3) — read it from +# the log instead of hardcoding. +sendkeys "msgrecv" +sleep 1 +MID="$(sed -n 's/.*msgrecv: task \([0-9][0-9]*\) listening.*/\1/p' "$LOG" | tail -1)" +[ -n "$MID" ] || fail "msgrecv did not spawn (no 'msgrecv: task N listening' in the log)" +echo " msgrecv task id: $MID" + +sendkeys \ + "send $MID user 42" \ + "send $MID timer" \ + "send $MID key enter" \ + "send $MID key ctrl-c" \ + "send $MID key f3" \ + "send $MID mouse 5 -3 3" \ + "sleep 800" \ + "jobs" + +sendkeys "mouse $MID" +qemu_hmp "mouse_move 20 7" +qemu_hmp "mouse_button 1" +qemu_hmp "mouse_move -5 -3" +qemu_hmp "mouse_button 0" +qemu_hmp "sendkey ctrl-c" + +# Queue-full probe: overflow a queue that nobody drains. The shell used +# to be that task, but its exec pump now consumes its own User messages +# as completion codes (q=0 at the prompt), and msgrecv consumes on wake — +# the cursor task never calls recv, so its 16-slot ring fills for real. +CID="$(awk '$2 == "cursor" { print $1 }' "$LOG" | tail -1)" +[ -n "$CID" ] || fail "no cursor task in jobs output (cannot probe queue-full)" +echo " queue-full target: task $CID (cursor, never recv'd)" + +sendkeys \ + "send $CID user 1" \ + "send $CID user 2" \ + "send $CID user 3" \ + "send $CID user 4" \ + "send $CID user 5" \ + "send $CID user 6" \ + "send $CID user 7" \ + "send $CID user 8" \ + "send $CID user 9" \ + "send $CID user 10" \ + "send $CID user 11" \ + "send $CID user 12" \ + "send $CID user 13" \ + "send $CID user 14" \ + "send $CID user 15" \ + "send $CID user 16" \ + "send $CID user 17" \ + "sleep 800" \ + "jobs" \ + "poweroff" + +echo "==> 5/5 wait for shutdown + verify" +wait_qemu_exit 30 || fail "QEMU did not exit after poweroff" + +grep -aq "msgrecv: task $MID listening" "$LOG" || fail "msgrecv did not spawn" +grep -aq "msgrecv\[$MID\]: User(42)" "$LOG" || fail "user message missing" +grep -aq "msgrecv\[$MID\]: Timer" "$LOG" || fail "timer message missing" +grep -aq "msgrecv\[$MID\]: Key(Enter)" "$LOG" || fail "key enter missing" +grep -aq "msgrecv\[$MID\]: Key(Ctrl-c)" "$LOG" || fail "key ctrl-c missing" +grep -aq "msgrecv\[$MID\]: Key(F3)" "$LOG" || fail "key f3 missing" +grep -aq "msgrecv\[$MID\]: Mouse(+5,-3 L R)" "$LOG" || fail "synthesized mouse message missing" +grep -aq "msgrecv\[$MID\]: Mouse(+20,+7" "$LOG" || fail "real mouse move 20,7 not routed to queue" +grep -aq "msgrecv\[$MID\]: Mouse(-5,-3 L" "$LOG" || fail "held-button routed move missing" +grep -aq "queue full" "$LOG" || fail "17th send did not report queue full" +grep -aq "send: unknown type" "$LOG" && fail "a bad send slipped through (expected none)" + +echo "" +echo "PASS — message queues OK" -- cgit v1.2.3