#!/usr/bin/env bash # Boot the warden kernel under qemu-system-arm -M virt and assert the initramfs # sentinel appears on the console. FAILS CLOSED: a missing zImage, initramfs, # or qemu binary is an error, never a skip. # # Usage: boot-smoke.sh [initramfs.cpio.gz] set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # qemu/tests/ QDIR="$(cd "$HERE/.." && pwd)" # qemu/ ZIMAGE="${1:-}" if [ -z "$ZIMAGE" ] || [ ! -f "$ZIMAGE" ]; then echo "FATAL: usage: $0 [initramfs] — zImage missing or not a file: '${ZIMAGE:-}'" >&2 exit 1 fi INITRD="${2:-$QDIR/out/initramfs.cpio.gz}" [ -f "$INITRD" ] || { echo "FATAL: initramfs not found at $INITRD — run qemu/mkinitramfs.sh first" >&2 exit 1 } command -v qemu-system-arm >/dev/null || { echo "FATAL: qemu-system-arm not on PATH (apt-get install qemu-system-arm) — see qemu/README.md" >&2 exit 1 } LOG="$(mktemp "${TMPDIR:-/tmp}/warden-qemu-smoke.XXXXXX")" trap 'rm -f "$LOG"' EXIT # NOTE: never pass `earlyprintk` — the config's DEBUG_UART_PHYS is the RV1106's # 0xff4c0000, which does not exist on -M virt. timeout 180 qemu-system-arm \ -M virt,highmem=off -cpu cortex-a7 -smp 1 -m 256M \ -kernel "$ZIMAGE" -initrd "$INITRD" \ -append "console=ttyAMA0 rdinit=/init" \ -nographic -no-reboot &2 exit 1 } grep -q "WARDEN-QEMU-BOOT-OK" "$LOG" || { echo "FATAL: boot sentinel WARDEN-QEMU-BOOT-OK not found in console log" >&2 exit 1 } echo "boot smoke OK"