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-msg.sh | 62 ++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 41 deletions(-) (limited to 'scripts/test-msg.sh') 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 @@ # # scripts/test-msg.sh — automated scheduler message-queue round trip. # -# Builds the kernel, boots QEMU headless, and verifies inter-task -# messaging end to end: -# - `msgrecv` spawns a task that blocks on recv_blocking -# - `send ` delivers every message type in order -# - `mouse ` routes *real* IRQ12 mouse events into the queue -# (the window-manager input path) -# - queue-full is a clean error (16-cap; tested against the shell's -# own never-consumed queue) -# - jobs shows q=0 after everything drains, task back to blocked +# Tests all message types (user, timer, key, mouse), real-input routing, +# and queue-full boundary. # -# Usage: -# ./scripts/test-msg.sh -# -# Environment: -# OVMF firmware (default: /usr/share/edk2/x64/OVMF.4m.fd) -# QEMU qemu binary (default: qemu-system-x86_64) +# 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-msg-qpid SOCK=/tmp/rsdos-msg-qmon.sock LOG=/tmp/rsdos-msg-serial.log @@ -37,7 +25,7 @@ trap 'kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true' EXIT fail() { echo "FAIL: $1" - [ -f "$LOG" ] && tail -20 "$LOG" + [ -f "$LOG" ] && tail -40 "$LOG" exit 1 } @@ -51,16 +39,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 @@ -71,19 +49,29 @@ time.sleep(0.4) EOF } +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 +} + echo "==> 1/5 build kernel (debug)" cargo build --package rsdos --target x86_64-unknown-uefi -echo "==> 2/5 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/5 stage system image" +"$SCRIPT_DIR/mksystem.sh" --force "$SYSTEM_IMG" echo "==> 3/5 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 \ @@ -93,7 +81,6 @@ echo $! >"$QPID" wait_log "$LOG" "boot: entering shell" 90 || fail "kernel never reached the shell" echo "==> 4/5 drive the shell (msgrecv / send / mouse routing / queue-full)" -# msgrecv spawns as task 3 (task 2 is the cursor task). python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ "msgrecv" \ "send 3 user 42" \ @@ -105,8 +92,6 @@ python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ "sleep 800" \ "jobs" -# Real IRQ12 events through the queue: start routing to task 3, inject -# moves + a left press, stop. python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" "mouse 3" qemu_hmp "mouse_move 20 7" qemu_hmp "mouse_button 1" @@ -114,8 +99,6 @@ qemu_hmp "mouse_move -5 -3" qemu_hmp "mouse_button 0" qemu_hmp "sendkey ctrl-c" -# Queue-full boundary: 16 sends fit, the 17th must fail cleanly. The -# shell never consumes its own queue, so nothing races the drain here. python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ "send 0 user 1" \ "send 0 user 2" \ @@ -148,13 +131,10 @@ grep -aq "msgrecv\[3\]: Key(Enter)" "$LOG" || fail "key enter missing" grep -aq "msgrecv\[3\]: Key(Ctrl-c)" "$LOG" || fail "key ctrl-c missing" grep -aq "msgrecv\[3\]: Key(F3)" "$LOG" || fail "key f3 missing" grep -aq "msgrecv\[3\]: Mouse(+5,-3 L R)" "$LOG" || fail "synthesized mouse message missing" -# Real IRQ12 events routed through the queue (button held across the move). grep -aq "msgrecv\[3\]: Mouse(+20,+7" "$LOG" || fail "real mouse move 20,7 not routed to queue" grep -aq "msgrecv\[3\]: 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 (all types, ordering, real-input routing, queue-full)" -echo " sent: user · timer · key(enter,ctrl-c,f3) · mouse · 16+1 queue-full" -echo " routed: mouse_move 20,7 → queue → msgrecv[3]" +echo "PASS — message queues OK" -- cgit v1.2.3