#!/usr/bin/env bash # Boot the normal (non-headless) kernel with no window, "type" some keys into # it through the QEMU monitor's `sendkey` command, then dump the VGA screen to # a PNG. Doubles as an automated keyboard + user-mode test: the default types # a line (with a typo fixed by Backspace) and presses Enter; the `echo` user # program reads it with read(0) and prints it back, all visible on serial. # # Usage: ./scripts/screenshot.sh [out.png] [text-to-type] [expected-result] # In text-to-type, "<" means Backspace and "|" means Enter. # Exits 1 if the expected text doesn't show up on serial. set -euo pipefail cd "$(dirname "$0")/.." cargo build # Force bootimage to repack the disk image (see scripts/runner.sh for why). touch target/x86_64-rust_kernel/debug/rust_kernel cargo bootimage IMG=target/x86_64-rust_kernel/debug/bootimage-rust_kernel.bin OUT="${1:-$PWD/boot.png}" TEXT="${2:-Hello, kernex '$EXPECT'" else echo "[screenshot] keyboard echo NOT found (expected '$EXPECT')" rm -f "$SERIAL_LOG" exit 1 fi rm -f "$SERIAL_LOG" echo "[screenshot] saved $OUT"