Files
bfe-core1106-sdk/qemu/tests/boot-smoke.sh
T
NoahandClaude Sonnet 5.5 445b2082f5
ci / test (push) Canceled after 0s
ci / mcdc (push) Canceled after 0s
ci / bench (push) Canceled after 0s
ci / qemu-tools (push) Canceled after 0s
ci / kernel-symbols (push) Canceled after 0s
ci / patches-apply (push) Canceled after 0s
ci / prune-artifacts (push) Canceled after 0s
ci / kernel-build (push) Canceled after 0s
ci / quality (push) Canceled after 0s
ci / badges (push) Canceled after 0s
qemu: check the kernel contract at boot and run a staged script (warden.run)
init verifies build/required-symbols.txt against the guest's /proc/config.gz,
the cgroup v2 controllers and PSI and prints markers; boot-smoke.sh fails when a
marker is missing. mkinitramfs.sh stages the list and merges EXTRA_DIR; run.sh
--append passes warden.run=<path>, which init runs before powering off (used by the
flare-edge M0 limit tests). README notes the symbol lists.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
2026-10-09 10:45:22 -06:00

64 lines
2.6 KiB
Bash
Executable File

#!/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 <zImage> [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 <zImage> [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
# Delegate the qemu invocation to run.sh (--no-disk) so the machine shape
# (-M virt,highmem=off, cpu, memory, virtio topology) lives in exactly one
# place: the two hand-copied invocations had already drifted once.
# timeout -k: a wedged qemu that ignores SIGTERM gets SIGKILLed 10s later
# instead of holding the job until the workflow-level timeout.
timeout -k 10 180 bash "$QDIR/run.sh" \
--kernel "$ZIMAGE" --initrd "$INITRD" --no-disk \
--ssh-port 0 --http-port 0 --api-port 0 \
</dev/null | tee "$LOG" || {
echo "FATAL: qemu exited non-zero (or hung until the 180s timeout)" >&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
}
# Kernel contract (rebuild M0): init checked build/required-symbols.txt against the
# running kernel's /proc/config.gz, the cgroup v2 controllers and PSI. A missing
# marker is as fatal as a MISSING one: the check must have run.
grep -q "^WARDEN-QEMU-SYMBOLS-OK " "$LOG" || {
echo "FATAL: the required-symbols check did not pass: $(grep -E 'WARDEN-QEMU-SYMBOLS' "$LOG" | head -1)" >&2
exit 1
}
ctl="$(sed -n 's/^WARDEN-QEMU-CGROUP-CONTROLLERS //p' "$LOG" | head -1 | tr -d '\r')"
for c in cpu memory pids; do
case " $ctl " in *" $c "*) ;; *)
echo "FATAL: cgroup v2 controller '$c' missing in the guest (have: '$ctl')" >&2; exit 1 ;; esac
done
grep -q "^WARDEN-QEMU-PSI-OK" "$LOG" || {
echo "FATAL: pressure stall information is not available: $(grep -E 'WARDEN-QEMU-PSI' "$LOG" | head -1)" >&2
exit 1
}
echo "boot smoke OK (symbols, cgroup controllers [$ctl], PSI)"