summaryrefslogtreecommitdiffstats
path: root/scripts/tests/test-msg.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-msg.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 '')
-rwxr-xr-xscripts/tests/test-msg.sh98
1 files changed, 98 insertions, 0 deletions
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 @@
1#!/usr/bin/env bash
2#
3# scripts/tests/test-msg.sh — automated scheduler message-queue round trip.
4#
5# Tests all message types (user, timer, key, mouse), real-input routing,
6# and the queue-full boundary.
7#
8# Usage: ./scripts/tests/test-msg.sh
9# Env: SYSTEM_IMG, OVMF, QEMU (see scripts/lib.sh)
10#
11set -euo pipefail
12TNAME="msg"
13# shellcheck source=../lib.sh
14source "$(dirname "$0")/../lib.sh"
15
16echo "==> 1/5 build (kernel + bins)"
17build_all
18
19echo "==> 2/5 stage system image"
20stage_image --force
21
22echo "==> 3/5 boot QEMU (headless)"
23test_boot
24
25echo "==> 4/5 drive the shell (msgrecv / send / mouse routing / queue-full)"
26# msgrecv's task id is assigned at spawn time and shifts when the task
27# table grows (the Windowed GUI added wm-input at slot 3) — read it from
28# the log instead of hardcoding.
29sendkeys "msgrecv"
30sleep 1
31MID="$(sed -n 's/.*msgrecv: task \([0-9][0-9]*\) listening.*/\1/p' "$LOG" | tail -1)"
32[ -n "$MID" ] || fail "msgrecv did not spawn (no 'msgrecv: task N listening' in the log)"
33echo " msgrecv task id: $MID"
34
35sendkeys \
36 "send $MID user 42" \
37 "send $MID timer" \
38 "send $MID key enter" \
39 "send $MID key ctrl-c" \
40 "send $MID key f3" \
41 "send $MID mouse 5 -3 3" \
42 "sleep 800" \
43 "jobs"
44
45sendkeys "mouse $MID"
46qemu_hmp "mouse_move 20 7"
47qemu_hmp "mouse_button 1"
48qemu_hmp "mouse_move -5 -3"
49qemu_hmp "mouse_button 0"
50qemu_hmp "sendkey ctrl-c"
51
52# Queue-full probe: overflow a queue that nobody drains. The shell used
53# to be that task, but its exec pump now consumes its own User messages
54# as completion codes (q=0 at the prompt), and msgrecv consumes on wake —
55# the cursor task never calls recv, so its 16-slot ring fills for real.
56CID="$(awk '$2 == "cursor" { print $1 }' "$LOG" | tail -1)"
57[ -n "$CID" ] || fail "no cursor task in jobs output (cannot probe queue-full)"
58echo " queue-full target: task $CID (cursor, never recv'd)"
59
60sendkeys \
61 "send $CID user 1" \
62 "send $CID user 2" \
63 "send $CID user 3" \
64 "send $CID user 4" \
65 "send $CID user 5" \
66 "send $CID user 6" \
67 "send $CID user 7" \
68 "send $CID user 8" \
69 "send $CID user 9" \
70 "send $CID user 10" \
71 "send $CID user 11" \
72 "send $CID user 12" \
73 "send $CID user 13" \
74 "send $CID user 14" \
75 "send $CID user 15" \
76 "send $CID user 16" \
77 "send $CID user 17" \
78 "sleep 800" \
79 "jobs" \
80 "poweroff"
81
82echo "==> 5/5 wait for shutdown + verify"
83wait_qemu_exit 30 || fail "QEMU did not exit after poweroff"
84
85grep -aq "msgrecv: task $MID listening" "$LOG" || fail "msgrecv did not spawn"
86grep -aq "msgrecv\[$MID\]: User(42)" "$LOG" || fail "user message missing"
87grep -aq "msgrecv\[$MID\]: Timer" "$LOG" || fail "timer message missing"
88grep -aq "msgrecv\[$MID\]: Key(Enter)" "$LOG" || fail "key enter missing"
89grep -aq "msgrecv\[$MID\]: Key(Ctrl-c)" "$LOG" || fail "key ctrl-c missing"
90grep -aq "msgrecv\[$MID\]: Key(F3)" "$LOG" || fail "key f3 missing"
91grep -aq "msgrecv\[$MID\]: Mouse(+5,-3 L R)" "$LOG" || fail "synthesized mouse message missing"
92grep -aq "msgrecv\[$MID\]: Mouse(+20,+7" "$LOG" || fail "real mouse move 20,7 not routed to queue"
93grep -aq "msgrecv\[$MID\]: Mouse(-5,-3 L" "$LOG" || fail "held-button routed move missing"
94grep -aq "queue full" "$LOG" || fail "17th send did not report queue full"
95grep -aq "send: unknown type" "$LOG" && fail "a bad send slipped through (expected none)"
96
97echo ""
98echo "PASS — message queues OK"