summaryrefslogtreecommitdiffstats
path: root/scripts/test-msg.sh
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-08-27 18:35:59 +0200
committersalmonik <salmonik@tuta.io>2026-08-27 18:35:59 +0200
commitacd0fe1bc38746f36fff24a7497041e5c5010977 (patch)
tree5db6335b732409c7f180f8514196c52a7b88f434 /scripts/test-msg.sh
parentGUI: fire-and-forget spawn for /bin/gui binaries (diff)
downloadrs-dos-acd0fe1bc38746f36fff24a7497041e5c5010977.tar.gz
rs-dos-acd0fe1bc38746f36fff24a7497041e5c5010977.zip
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.
Diffstat (limited to '')
-rwxr-xr-xscripts/test-msg.sh62
1 files changed, 21 insertions, 41 deletions
diff --git a/scripts/test-msg.sh b/scripts/test-msg.sh
index d81d8d7..95b7af3 100755
--- a/scripts/test-msg.sh
+++ b/scripts/test-msg.sh
@@ -2,32 +2,20 @@
2# 2#
3# scripts/test-msg.sh — automated scheduler message-queue round trip. 3# scripts/test-msg.sh — automated scheduler message-queue round trip.
4# 4#
5# Builds the kernel, boots QEMU headless, and verifies inter-task 5# Tests all message types (user, timer, key, mouse), real-input routing,
6# messaging end to end: 6# and queue-full boundary.
7# - `msgrecv` spawns a task that blocks on recv_blocking
8# - `send <id> <type>` delivers every message type in order
9# - `mouse <id>` routes *real* IRQ12 mouse events into the queue
10# (the window-manager input path)
11# - queue-full is a clean error (16-cap; tested against the shell's
12# own never-consumed queue)
13# - jobs shows q=0 after everything drains, task back to blocked
14# 7#
15# Usage: 8# Env: OVMF, QEMU, SYSTEM_IMG
16# ./scripts/test-msg.sh
17#
18# Environment:
19# OVMF firmware (default: /usr/share/edk2/x64/OVMF.4m.fd)
20# QEMU qemu binary (default: qemu-system-x86_64)
21# 9#
22set -euo pipefail 10set -euo pipefail
23 11
24SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 12SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
25PROJECT_DIR="$(dirname "$SCRIPT_DIR")" 13PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
26cd "$PROJECT_DIR" 14cd "$PROJECT_DIR"
27 15
28OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" 16OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}"
29QEMU="${QEMU:-qemu-system-x86_64}" 17QEMU="${QEMU:-qemu-system-x86_64}"
30ESP_DIR="$PROJECT_DIR/esp" 18SYSTEM_IMG="${SYSTEM_IMG:-/tmp/system.img}"
31QPID=/tmp/rsdos-msg-qpid 19QPID=/tmp/rsdos-msg-qpid
32SOCK=/tmp/rsdos-msg-qmon.sock 20SOCK=/tmp/rsdos-msg-qmon.sock
33LOG=/tmp/rsdos-msg-serial.log 21LOG=/tmp/rsdos-msg-serial.log
@@ -37,7 +25,7 @@ trap 'kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true' EXIT
37 25
38fail() { 26fail() {
39 echo "FAIL: $1" 27 echo "FAIL: $1"
40 [ -f "$LOG" ] && tail -20 "$LOG" 28 [ -f "$LOG" ] && tail -40 "$LOG"
41 exit 1 29 exit 1
42} 30}
43 31
@@ -51,16 +39,6 @@ wait_log() {
51 return 1 39 return 1
52} 40}
53 41
54wait_qemu_exit() {
55 local i=0
56 while [ "$i" -lt $((${1:-30} * 10)) ]; do
57 kill -0 "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || return 0
58 sleep 0.1
59 i=$((i + 1))
60 done
61 return 1
62}
63
64qemu_hmp() { 42qemu_hmp() {
65 python3 - "$SOCK" "$1" <<'EOF' 43 python3 - "$SOCK" "$1" <<'EOF'
66import socket, sys, time 44import socket, sys, time
@@ -71,19 +49,29 @@ time.sleep(0.4)
71EOF 49EOF
72} 50}
73 51
52wait_qemu_exit() {
53 local i=0
54 while [ "$i" -lt $((${1:-30} * 10)) ]; do
55 kill -0 "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || return 0
56 sleep 0.1
57 i=$((i + 1))
58 done
59 return 1
60}
61
74echo "==> 1/5 build kernel (debug)" 62echo "==> 1/5 build kernel (debug)"
75cargo build --package rsdos --target x86_64-unknown-uefi 63cargo build --package rsdos --target x86_64-unknown-uefi
76 64
77echo "==> 2/5 deploy to ESP" 65echo "==> 2/5 stage system image"
78mkdir -p "$ESP_DIR/EFI/BOOT" 66"$SCRIPT_DIR/mksystem.sh" --force "$SYSTEM_IMG"
79cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI"
80 67
81echo "==> 3/5 boot QEMU (headless)" 68echo "==> 3/5 boot QEMU (headless)"
82kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true 69kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true
83sleep 1 70sleep 1
84rm -f "$SOCK" "$LOG" 71rm -f "$SOCK" "$LOG"
85"$QEMU" -bios "$OVMF" \ 72"$QEMU" -bios "$OVMF" \
86 -drive file=fat:rw:"$ESP_DIR",format=raw \ 73 -drive file="$SYSTEM_IMG",format=raw,if=none,id=disk \
74 -device ide-hd,drive=disk,bus=ide.0 \
87 -serial file:"$LOG" \ 75 -serial file:"$LOG" \
88 -monitor unix:"$SOCK",server,nowait \ 76 -monitor unix:"$SOCK",server,nowait \
89 -m 256M -machine q35 -cpu qemu64 -no-reboot -display none \ 77 -m 256M -machine q35 -cpu qemu64 -no-reboot -display none \
@@ -93,7 +81,6 @@ echo $! >"$QPID"
93wait_log "$LOG" "boot: entering shell" 90 || fail "kernel never reached the shell" 81wait_log "$LOG" "boot: entering shell" 90 || fail "kernel never reached the shell"
94 82
95echo "==> 4/5 drive the shell (msgrecv / send / mouse routing / queue-full)" 83echo "==> 4/5 drive the shell (msgrecv / send / mouse routing / queue-full)"
96# msgrecv spawns as task 3 (task 2 is the cursor task).
97python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ 84python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \
98 "msgrecv" \ 85 "msgrecv" \
99 "send 3 user 42" \ 86 "send 3 user 42" \
@@ -105,8 +92,6 @@ python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \
105 "sleep 800" \ 92 "sleep 800" \
106 "jobs" 93 "jobs"
107 94
108# Real IRQ12 events through the queue: start routing to task 3, inject
109# moves + a left press, stop.
110python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" "mouse 3" 95python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" "mouse 3"
111qemu_hmp "mouse_move 20 7" 96qemu_hmp "mouse_move 20 7"
112qemu_hmp "mouse_button 1" 97qemu_hmp "mouse_button 1"
@@ -114,8 +99,6 @@ qemu_hmp "mouse_move -5 -3"
114qemu_hmp "mouse_button 0" 99qemu_hmp "mouse_button 0"
115qemu_hmp "sendkey ctrl-c" 100qemu_hmp "sendkey ctrl-c"
116 101
117# Queue-full boundary: 16 sends fit, the 17th must fail cleanly. The
118# shell never consumes its own queue, so nothing races the drain here.
119python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ 102python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \
120 "send 0 user 1" \ 103 "send 0 user 1" \
121 "send 0 user 2" \ 104 "send 0 user 2" \
@@ -148,13 +131,10 @@ grep -aq "msgrecv\[3\]: Key(Enter)" "$LOG" || fail "key enter missing"
148grep -aq "msgrecv\[3\]: Key(Ctrl-c)" "$LOG" || fail "key ctrl-c missing" 131grep -aq "msgrecv\[3\]: Key(Ctrl-c)" "$LOG" || fail "key ctrl-c missing"
149grep -aq "msgrecv\[3\]: Key(F3)" "$LOG" || fail "key f3 missing" 132grep -aq "msgrecv\[3\]: Key(F3)" "$LOG" || fail "key f3 missing"
150grep -aq "msgrecv\[3\]: Mouse(+5,-3 L R)" "$LOG" || fail "synthesized mouse message missing" 133grep -aq "msgrecv\[3\]: Mouse(+5,-3 L R)" "$LOG" || fail "synthesized mouse message missing"
151# Real IRQ12 events routed through the queue (button held across the move).
152grep -aq "msgrecv\[3\]: Mouse(+20,+7" "$LOG" || fail "real mouse move 20,7 not routed to queue" 134grep -aq "msgrecv\[3\]: Mouse(+20,+7" "$LOG" || fail "real mouse move 20,7 not routed to queue"
153grep -aq "msgrecv\[3\]: Mouse(-5,-3 L" "$LOG" || fail "held-button routed move missing" 135grep -aq "msgrecv\[3\]: Mouse(-5,-3 L" "$LOG" || fail "held-button routed move missing"
154grep -aq "queue full" "$LOG" || fail "17th send did not report queue full" 136grep -aq "queue full" "$LOG" || fail "17th send did not report queue full"
155grep -aq "send: unknown type" "$LOG" && fail "a bad send slipped through (expected none)" 137grep -aq "send: unknown type" "$LOG" && fail "a bad send slipped through (expected none)"
156 138
157echo "" 139echo ""
158echo "PASS — message queues OK (all types, ordering, real-input routing, queue-full)" 140echo "PASS — message queues OK"
159echo " sent: user · timer · key(enter,ctrl-c,f3) · mouse · 16+1 queue-full"
160echo " routed: mouse_move 20,7 → queue → msgrecv[3]"