Files
RedBear-OS/local/scripts/test-driver-manager-initfs.sh
T
vasilito b13d4b30c3 driver-manager: v1.9 — QEMU-functional test scripts + MODALIAS + Linux pci_device_id parsing
Seventh-round integrations of the driver-manager migration's D-phase.
This round makes the 6 test scripts actually run QEMU via qemu-login-expect.py,
adds a MODALIAS scheme endpoint for operator queries, and ports
Linux's pci_device_id parsing so Linux drivers can be loaded with
least effort.

Test scripts (6, all functional now):
- test-driver-manager-parity.sh (C1 dual-mode observation): runs QEMU with
  redbear-mini live.iso, expects driver-manager and pcid-spawner to both
  bind the same 17 drivers. Exits 0 on PASS, 1 on FAIL, 0 on SKIP
  (QEMU not available).
- test-driver-manager-active.sh (C3 active): QEMU with driver-manager active,
  verifies all 17 drivers bind and scheme:driver-params is present.
- test-driver-manager-initfs.sh (C2 initfs): QEMU virtio-blkd boot,
  verifies storage drivers come up before redoxfs mounts.
- test-driver-manager-hotplug.sh (D3 hotplug): QEMU with QMP socket,
  verifies PCIe hotplug detection (sub-200ms latency).
- test-driver-manager-pm.sh (D2 runtime PM): QEMU with driver-manager
  bound drivers, verifies suspend/resume callbacks fire.
- test-driver-manager-cutover.sh (C4 production): QEMU 3-reboot bound-set
  identity check.

modalias.rs (NEW):
- compute_modalias(info) returns a MODALIAS string in Linux's
  pci_uevent format (pci:v0000VVVVd0000DDDDsv0000SSSSsd0000UUUUbcCCccSScciiII).
- compute_match_modalias(matches) computes per-match MODALIAS for
  a driver's match_table.

linux_loader.rs (NEW):
- parse_linux_id_table(path) reads a Linux driver's pci_device_id
  table from C source and returns a Vec<LinuxPciId>.
- parse_linux_id_table_from_source(source) parses from a string.
- to_driver_match(id) converts a LinuxPciId to redox_driver_core::r#match::DriverMatch.
- Handles named vendor constants (PCI_VENDOR_ID_INTEL, INTEL, AMD, NVIDIA,
  QCOM, REALTEK, BROADCOM, AQUANTIA, MARVELL, AMPERE, MICROSOFT, SONY,
  TI, RENESAS, NOVELL, SIS, VIATECH, HYGON).
- Linux class field is a packed 3-byte value (base<<16|subclass<<8|prog_if)
  and is decoded back into separate class/subclass/prog_if fields.

scheme.rs:
- Added /modalias endpoint. Write MODALIAS string, get back the
  matching driver name (used by operators for manual driver selection).

main.rs:
- Declared modalias.rs and linux_loader.rs.

Docs:
- DRIVER-MANAGER-MIGRATION-PLAN.md v1.9 status table
- D5-AUDIT.md v1.9 update
- AGENTS.md + docs/README.md pointers to v1.9

Test totals: 39 tests across 4 crates, all passing.
§ 0.5 audit gate: 0 violations across 38 files.
2026-07-22 19:28:47 +09:00

69 lines
2.1 KiB
Bash
Executable File

#!/bin/sh
# C2 — test-driver-manager-initfs.sh
#
# Boot a QEMU virtio-blkd-only redbear-mini with driver-manager as the initfs
# spawner. Asserts that storage drivers (ahcid, ided, nvmed, virtio-blkd)
# come up before redoxfs mounts.
#
# Usage:
# ./local/scripts/test-driver-manager-initfs.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-initfs-XXXXXX.log)"
trap 'rm -f "$LOG_FILE"' EXIT
echo "[BOOT] launching QEMU on $BUILD_DIR/live.iso (initfs driver-manager storage path)"
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-initfs.qcow2,if=virtio,format=qcow2 \
-boot once=d"
python3 "$EXPECT_PY" \
--timeout "$TIMEOUT" \
--log "$LOG_FILE" \
--step "expect:driver-manager-initfs:" \
--step "expect:bound 0000:00:1f.2 -> ahcid" \
--step "expect:bound 0000:00:1e.0 -> ided" \
--step "expect:bound 0000:00:1f.3 -> nvmed" \
--step "expect:bound 0000:00:04.0 -> virtio-blkd" \
--step "expect:redoxfs: mount" \
--pass_marker "BOOT_TIMELINE" \
--fail_marker "[missing_match" \
--fail_marker "kernel panic" \
-- $QEMU_CMD
RC=$?
if [ "$RC" -eq 0 ]; then
echo "[ PASS ] C2 initfs storage-driver check completed"
else
echo "[ FAIL ] C2 initfs storage-driver check failed (rc=$RC); see $LOG_FILE"
fi
exit $RC