diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-01 15:53:29 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-01 15:53:29 +0100 |
| commit | 7958276c9f0d230053520ba20f2a00f5ecda18e4 (patch) | |
| tree | 596f5f71ad597ed951bae98de818cb37f171a18d /scripts/tests/test-disk.sh | |
| parent | fs: /bin alias for the system volume (diff) | |
| download | rs-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 'scripts/tests/test-disk.sh')
| -rwxr-xr-x | scripts/tests/test-disk.sh | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/scripts/tests/test-disk.sh b/scripts/tests/test-disk.sh new file mode 100755 index 0000000..3836b6d --- /dev/null +++ b/scripts/tests/test-disk.sh | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | # | ||
| 3 | # scripts/tests/test-disk.sh — full automated data-disk round trip. | ||
| 4 | # | ||
| 5 | # Builds, stages the system image, boots QEMU headless, drives the shell | ||
| 6 | # via the monitor (ls / mkdir / echo WRITING / cat / poweroff), then | ||
| 7 | # verifies the results with mtools and fsck. | ||
| 8 | # | ||
| 9 | # Usage: | ||
| 10 | # ./scripts/tests/test-disk.sh reuse the existing image | ||
| 11 | # ./scripts/tests/test-disk.sh --fresh reformat + reseed first | ||
| 12 | # | ||
| 13 | # Env: SYSTEM_IMG, OVMF, QEMU (see scripts/lib.sh) | ||
| 14 | # | ||
| 15 | set -euo pipefail | ||
| 16 | TNAME="disk" | ||
| 17 | # shellcheck source=../lib.sh | ||
| 18 | source "$(dirname "$0")/../lib.sh" | ||
| 19 | |||
| 20 | FRESH=0 | ||
| 21 | [ "${1:-}" = "--fresh" ] && FRESH=1 | ||
| 22 | STAMP="$(date +%s)" | ||
| 23 | |||
| 24 | echo "==> 1/6 build (kernel + bins)" | ||
| 25 | build_all | ||
| 26 | |||
| 27 | echo "==> 2/6 stage system image" | ||
| 28 | if [ "$FRESH" -eq 1 ]; then stage_image --force; else stage_image; fi | ||
| 29 | |||
| 30 | echo "==> 3/6 boot QEMU (headless)" | ||
| 31 | test_boot | ||
| 32 | sleep 1 | ||
| 33 | |||
| 34 | # Volumes mount under /disk/<UID>/ where UID = "LABEL-SERIAL" (e.g. | ||
| 35 | # RSDOS-5BD1E55F). Discover it from the boot log so the test works on | ||
| 36 | # any image without knowing the serial in advance. | ||
| 37 | VOL_UID="$(grep -a 'fat: mounted' "$LOG" | sed -n 's/.*at \/disk\/\([^ )]*\).*/\1/p' | head -1)" | ||
| 38 | [ -n "$VOL_UID" ] || fail "no FAT32 volume was mounted (look for 'fat: mounted' in the log)" | ||
| 39 | echo " mounted volume UID: $VOL_UID" | ||
| 40 | |||
| 41 | echo "==> 4/6 drive the shell (ls / mkdir / echo WRITING / cat / poweroff)" | ||
| 42 | # The filename is deliberately >13 chars so the FAT LFN path gets | ||
| 43 | # multi-entry entries (they're stored last-first on disk). | ||
| 44 | TESTFILE="disk-test-$STAMP.txt" | ||
| 45 | sendkeys \ | ||
| 46 | "ls /disk" \ | ||
| 47 | "mkdir /disk/$VOL_UID/sub" \ | ||
| 48 | "echo disk-test-$STAMP WRITING /disk/$VOL_UID/sub/$TESTFILE" \ | ||
| 49 | "cat /disk/$VOL_UID/sub/$TESTFILE" \ | ||
| 50 | "poweroff" | ||
| 51 | |||
| 52 | echo "==> 5/6 wait for shutdown" | ||
| 53 | wait_qemu_exit 30 || fail "QEMU did not exit after poweroff" | ||
| 54 | |||
| 55 | echo "==> 6/6 verify" | ||
| 56 | grep -a "disk-test-$STAMP" "$LOG" >/dev/null || fail "cat output missing from serial log" | ||
| 57 | if ! fsck.fat -n "$SYSTEM_IMG" >/tmp/rsdos-fsck.out 2>&1; then | ||
| 58 | fail "fsck.fat reports problems: $(tail -3 /tmp/rsdos-fsck.out)" | ||
| 59 | fi | ||
| 60 | MT="$(mtype -i "$SYSTEM_IMG" "::/sub/$TESTFILE" 2>/dev/null || true)" | ||
| 61 | [ "$MT" = "disk-test-$STAMP" ] || fail "mtype mismatch: got '$MT'" | ||
| 62 | |||
| 63 | echo "" | ||
| 64 | echo "PASS — disk round trip OK (fsck clean, file survived poweroff)" | ||
| 65 | echo " image: $SYSTEM_IMG" | ||
| 66 | echo " volume: /disk/$VOL_UID" | ||
| 67 | echo " written: /disk/$VOL_UID/sub/$TESTFILE = \"disk-test-$STAMP\"" | ||
