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/sendkeys.py | 103 ---------------------------------------------------- 1 file changed, 103 deletions(-) delete mode 100755 scripts/sendkeys.py (limited to 'scripts/sendkeys.py') diff --git a/scripts/sendkeys.py b/scripts/sendkeys.py deleted file mode 100755 index a67903d..0000000 --- a/scripts/sendkeys.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python3 -"""Type lines into a QEMU guest via the monitor's `sendkey` command. - -Each positional argument is one line: it is typed character by character -(US layout) followed by Enter. Use it to drive the rs-dos shell from a -test script without a display. - -Usage: - sendkeys.py "ls /disk" "echo hi WRITING /disk/a.txt" "poweroff" - sendkeys.py --sock /tmp/qmon.sock "date" - -Environment: QMON_SOCK (default: /tmp/qmon.sock) -""" -import os -import socket -import sys -import time - -SOCK = os.environ.get("QMON_SOCK", "/tmp/qmon.sock") - -# Unshifted punctuation needs QEMU's *named* keys — bare '-'/'.'/'/' are -# not valid sendkey names (and '-' is the modifier separator). -BASE = { - "-": "minus", "=": "equal", "[": "bracketleft", "]": "bracketright", - "\\": "backslash", ";": "semicolon", "'": "apostrophe", - ",": "comma", ".": "dot", "/": "slash", "`": "grave", -} - -# Characters that need a shift key on US layout, and the key QEMU's -# `sendkey` understands for them. -SHIFT = { - "~": "grave", "!": "1", "@": "2", "#": "3", "$": "4", "%": "5", - "^": "6", "&": "7", "*": "8", "(": "9", ")": "0", - "_": "minus", "+": "equal", "{": "bracketleft", "}": "bracketright", - "|": "backslash", ":": "semicolon", '"': "apostrophe", - "<": "comma", ">": "dot", "?": "slash", -} - -ALNUM = set("abcdefghijklmnopqrstuvwxyz0123456789") - - -def connect(path, timeout=60): - """Connect to the monitor socket, retrying until QEMU is up.""" - deadline = time.time() + timeout - while True: - try: - s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - s.connect(path) - return s - except OSError: - if time.time() > deadline: - raise - time.sleep(0.2) - - -def sendkey(sock, keys): - sock.sendall(("sendkey %s\n" % keys).encode()) - - -def type_line(sock, line): - for ch in line: - if ch == " ": - sendkey(sock, "spc") - elif ch in BASE: - sendkey(sock, BASE[ch]) - elif ch in SHIFT: - sendkey(sock, "shift-" + SHIFT[ch]) - elif ch.isupper(): - sendkey(sock, "shift-" + ch.lower()) - elif ch in ALNUM: - sendkey(sock, ch) - else: - sys.stderr.write("warning: no sendkey mapping for %r\n" % ch) - continue - time.sleep(0.25) - sendkey(sock, "ret") - time.sleep(1.5) - - -def main(): - args = [a for a in sys.argv[1:] if a != "--sock"] - sock_path = SOCK - if "--sock" in sys.argv: - i = sys.argv.index("--sock") - sock_path = sys.argv[i + 1] - args = sys.argv[i + 2:] - if not args: - sys.stderr.write(__doc__ or "") - return 1 - sock = connect(sock_path) - # Let the monitor drain any startup banner before typing. - time.sleep(0.5) - for line in args: - try: - type_line(sock, line) - except OSError: - # Guest powered off (last line was usually "poweroff"). - break - return 0 - - -if __name__ == "__main__": - sys.exit(main()) -- cgit v1.2.3