#!/bin/sh # C1 — test-driver-manager-parity.sh # # Boots a QEMU redbear-mini ISO with driver-manager in dual-mode observation # (pcid-spawner active, driver-manager in --observe mode). Asserts that # the driver-manager sees the same 17-driver bound set as pcid-spawner. # # Uses local/scripts/qemu-login-expect.py to drive the guest over serial. # # Usage: # ./local/scripts/test-driver-manager-parity.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) # EXPECT_LOGIN_PROMPT: 1 to require login prompt (default: 1) set -eu REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)" BUILD_DIR="${BUILD_DIR:-$REPO_ROOT/build/x86_64/redbear-mini}" TIMEOUT="${TIMEOUT:-240}" EXPECT_LOGIN_PROMPT="${EXPECT_LOGIN_PROMPT:-1}" 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-parity-XXXXXX.log)" trap 'rm -f "$LOG_FILE"' EXIT echo "[BOOT] launching QEMU on $BUILD_DIR/live.iso (parity: pcid-spawner + driver-manager --observe)" 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-parity.qcow2,if=virtio,format=qcow2 \ -boot once=d" if [ "$EXPECT_LOGIN_PROMPT" = "1" ]; then 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" \ --step "expect:login" \ --pass_marker "BOOT_TIMELINE" \ --fail_marker "[missing_match" \ --fail_marker "kernel panic" \ --fail_marker "FATAL: no driver found for" \ -- $QEMU_CMD RC=$? else 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" \ -- $QEMU_CMD RC=$? fi if [ "$RC" -eq 0 ]; then echo "[ PASS ] C1 dual-mode observation parity check completed" else echo "[ FAIL ] C1 dual-mode observation parity check failed (rc=$RC); see $LOG_FILE" fi exit $RC