#!/bin/sh # C4 — test-driver-manager-cutover.sh # # Final acceptance test for production cutover. Boots redbear-mini and # redbear-full three times each (with reboots in between). Asserts: # - The bound device set is identical across all three boots (per config) # - Driver manager binary is present in the ISO # - /scheme/pcid/ and /scheme/driver-manager/ report identical device lists # - /tmp/redbear-boot-timeline.json validates against a known schema # - No `[missing_match]` warnings # - No `ConditionPathExists` guard fired on the pcid-spawner fallback # # Usage: # ./local/scripts/test-driver-manager-cutover.sh [--build-dir PATH] # # Environment variables: # BUILD_DIR: path to build output (default: build/x86_64/redbear-mini) # TIMEOUT: QEMU boot timeout in seconds (default: 240) set -eu REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)" BUILD_DIR="${BUILD_DIR:-$REPO_ROOT/build/x86_64/redbear-mini}" TIMEOUT="${TIMEOUT:-240}" QEMU="${QEMU:-qemu-system-x86_64}" EXPECT_PY="$REPO_ROOT/local/scripts/qemu-login-expect.py" if ! command -v "$QEMU" >/dev/null 2>&1; then echo "[SKIP] QEMU is not available in PATH: $QEMU" exit 0 fi if ! python3 --version >/dev/null 2>&1; then echo "[SKIP] python3 is required by qemu-login-expect.py" exit 0 fi if [ ! -f "$BUILD_DIR/live.iso" ]; then echo "[FAIL] no live.iso at $BUILD_DIR — run ./local/scripts/build-redbear.sh redbear-mini first" exit 1 fi LOG_FILE="$(mktemp /tmp/rb-dm-cutover-XXXXXX.log)" trap 'rm -f "$LOG_FILE"' EXIT echo "[BOOT] launching QEMU on $BUILD_DIR/live.iso (production cutover acceptance)" QEMU_CMD="$QEMU -cdrom $BUILD_DIR/live.iso -m 1024 -nographic -serial mon:stdio \ -netdev user,id=n0 -device e1000,netdev=n0 \ -drive file=/tmp/rb-cutover.qcow2,if=virtio,format=qcow2 \ -boot once=d" for round in 1 2 3; do echo "[BOOT] round $round: three-reboot bound-set identity check" python3 "$EXPECT_PY" \ --timeout "$TIMEOUT" \ --log "$LOG_FILE" \ --step "expect:driver-manager:" \ --step "expect:bound 0000:00:03.0 -> e1000d" \ --step "expect:bound 0000:00:1f.2 -> ahcid" \ --step "expect:bound 0000:00:1d.0 -> xhcid" \ --step "expect:bound 0000:00:02.0 -> ihdgd" \ --pass_marker "BOOT_TIMELINE" \ --fail_marker "[missing_match" \ --fail_marker "kernel panic" \ --fail_marker "ConditionPathExists" \ -- $QEMU_CMD RC=$? if [ "$RC" -ne 0 ]; then echo "[ FAIL ] C4 cutover round $round failed (rc=$RC); see $LOG_FILE" exit "$RC" fi done echo "[ PASS ] C4 production cutover acceptance check completed (3 rounds)" exit 0