scripts/qemu-verify.sh
back to source
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# Scoped NumericalOS boot re-verify under QEMU.
# Usage: scripts/qemu-verify.sh kernel-initrd|iso
# Windows: run via MSYS bash with PATH including mingw64/bin.
set -euo pipefail
MODE="${1:-kernel-initrd}"
export PATH="/mingw64/bin:/usr/bin:${PATH:-}"
# Repo root (script in scripts/)
ROOT="$(cd "$(dirname "$0")/.." && pwd -W 2>/dev/null || cd "$(dirname "$0")/.." && pwd)"
# Prefer no-space junction if present
if [[ -d /c/numos-art ]]; then
ART=/c/numos-art
QART="C:/numos-art"
else
ART="$ROOT/build-out/artifacts"
QART="$ART"
fi
mkdir -p "$ROOT/build-out/artifacts"
STAMP=$(date +%Y%m%d%H%M%S)
TIMEOUT_SEC="${TIMEOUT_SEC:-90}"
if ! command -v qemu-system-x86_64 >/dev/null 2>&1; then
echo "ERROR: qemu-system-x86_64 not on PATH" >&2
exit 1
fi
case "$MODE" in
kernel-initrd|k|initrd)
MODE=kernel-initrd
LOG="$ROOT/build-out/artifacts/verify-kinitrd-${STAMP}.log"
KERNEL="${KERNEL:-$ART/vmlinuz}"
INITRD="${INITRD:-$ART/numericalos-self-init.cpio.gz}"
[[ -f "$KERNEL" ]] || { echo "missing $KERNEL" >&2; exit 1; }
[[ -f "$INITRD" ]] || { echo "missing $INITRD" >&2; exit 1; }
# Map to Windows paths for native qemu
if [[ -d /c/numos-art ]]; then
K="C:/numos-art/$(basename "$KERNEL")"
I="C:/numos-art/$(basename "$INITRD")"
else
K="$KERNEL"
I="$INITRD"
fi
timeout "$TIMEOUT_SEC" qemu-system-x86_64 -machine q35 -m 512 \
-kernel "$K" -initrd "$I" \
-append "console=ttyS0,115200n8 NUMOS_OFFLINE=1 NUMOS_PREFIX=/opt/numericalos NUMOS_STATE=/etc/numos.state NUMOS_LIB=/lib" \
-nographic -no-reboot \
>"$LOG" 2>&1 || true
PATH_CLAIM=kernel+initrd
;;
iso|cdrom)
MODE=iso
LOG="$ROOT/build-out/artifacts/verify-iso-${STAMP}.log"
ISO="${ISO:-$ART/numericalos-self-init.iso}"
[[ -f "$ISO" ]] || { echo "missing $ISO" >&2; exit 1; }
if [[ -d /c/numos-art ]]; then
ISOQ="C:/numos-art/$(basename "$ISO")"
else
ISOQ="$ISO"
fi
timeout "$TIMEOUT_SEC" qemu-system-x86_64 -machine q35 -m 512 \
-cdrom "$ISOQ" -boot order=d \
-nographic -no-reboot \
>"$LOG" 2>&1 || true
PATH_CLAIM=iso-cdrom
;;
*)
echo "usage: $0 kernel-initrd|iso" >&2
exit 1
;;
esac
echo "=== numericalos-qemu-verify ==="
echo "mode=$MODE path_claim=$PATH_CLAIM"
qemu-system-x86_64 --version | head -1
echo "log=$LOG"
echo "bytes=$(wc -c < "$LOG")"
echo "--- numos lines ---"
grep -aE 'numos:' "$LOG" || true
VERDICT=FAIL
if grep -aq 'numos: boot complete degraded=0' "$LOG"; then
VERDICT=PASS
elif grep -aq 'numos: boot complete degraded=1' "$LOG"; then
VERDICT=PASS-degraded
elif grep -aq 'numos: HALT:' "$LOG"; then
VERDICT=HALT
fi
echo "verdict=$VERDICT"
echo "not_proven=metal, non-x86_64, other artifacts"
[[ "$VERDICT" == PASS* ]] || exit 2