test-xhci-irq-qemu.sh: grep for actual xHCI reactor log lines

The old --check section looked for log strings that do not exist in the
xhcid codebase ("xhcid: using MSI/MSI-X interrupt delivery" etc.).
All six grep patterns were fictitious — the script was written ahead of
P0-A1 anticipating different logging.

Rewrite to match actual debug-level output from xhcid:

  irq_reactor.rs:208 — "Running IRQ reactor with IRQ file and event queue"
    (irq_file is Some — this is the main proof that interrupts fired)
  irq_reactor.rs:125 — "Running IRQ reactor in polling mode."
    (irq_file is None — must NOT appear in a passing run)
  main.rs:88        — "Enabled MSI-X"  (debug, MSI-X configured)
  main.rs:95        — "Legacy IRQ <n>" (debug, INTx fallback)
  main.rs:143       — "XHCI <pci_name>" (info, controller detected)

Also fails if both polling and IRQ-driven mode appear in the same boot.
This commit is contained in:
2026-07-07 00:39:06 +03:00
parent b5205e162d
commit 33465b59e0
+39 -12
View File
@@ -104,32 +104,59 @@ if [[ "$check_mode" -eq 1 ]]; then
> "$log_file" 2>&1
status=$?
set -e
if ! grep -q "xhcid: using MSI/MSI-X interrupt delivery\|xhcid: using legacy INTx interrupt delivery\|XHCI .* IRQ:" "$log_file"; then
echo "ERROR: xhcid did not report an interrupt-driven mode; see $log_file" >&2
# --- Post-P0-A1 checks: the reactor MUST run the IRQ-driven path, NOT polling.
# The reactor logs at debug level:
# "Running IRQ reactor with IRQ file and event queue" (irq_file is Some)
# "Running IRQ reactor in polling mode." (irq_file is None)
if ! grep -q "Running IRQ reactor with IRQ file and event queue" "$log_file"; then
echo "ERROR: xhcid IRQ reactor did NOT run the interrupt-driven path" >&2
echo " Expected: 'Running IRQ reactor with IRQ file and event queue'" >&2
if grep -q "Running IRQ reactor in polling mode" "$log_file"; then
echo " Found: 'Running IRQ reactor in polling mode' (polling — IRQs still bypassed)" >&2
fi
echo " See $log_file" >&2
exit 1
fi
if ! grep -q "xhcid: begin attach for port\|xhcid: queueing initial enumeration for port" "$log_file"; then
echo "ERROR: xhcid interrupt-mode proof never observed attached-device enumeration pressure; see $log_file" >&2
if grep -q "Running IRQ reactor in polling mode" "$log_file"; then
echo "ERROR: xhcid IRQ reactor logged polling mode alongside IRQ-driven mode" >&2
echo " Both 'Running IRQ reactor with IRQ file and event queue' AND" >&2
echo " 'Running IRQ reactor in polling mode' appeared in the same boot." >&2
echo " Only one reactor runs per xhcid instance — this should be impossible." >&2
echo " See $log_file" >&2
exit 1
fi
# Determine which interrupt delivery method was selected.
# get_int_method() at main.rs:54-101 logs at debug level:
# "Enabled MSI-X" (MSI-X was configured and enabled)
# "Legacy IRQ <n>" (MSI/MSI-X absent, falling back to INTx)
mode="unknown"
reason="unknown"
if grep -q "xhcid: using MSI/MSI-X interrupt delivery" "$log_file"; then
if grep -q "Enabled MSI-X" "$log_file"; then
mode="msi_or_msix"
reason="driver_selected_interrupt_delivery"
elif grep -q "xhcid: using legacy INTx interrupt delivery" "$log_file"; then
reason="msix_configured"
elif grep -q "Legacy IRQ" "$log_file"; then
mode="legacy"
reason="driver_fell_back_to_legacy_intx"
elif grep -q "xhcid: falling back to polling mode" "$log_file"; then
mode="polling"
reason="driver_fell_back_to_polling"
reason="fell_back_to_legacy_intx"
else
# If neither MSI-X nor Legacy IRQ logged, the reactor ran the IRQ path
# (proven above) but the delivery method wasn't captured — still a pass.
mode="irq_path_active"
reason="delivery_method_not_captured_in_log"
fi
# Verify the xHCI controller was actually detected.
# main.rs:143 logs at info level: "XHCI <pci_name>"
if ! grep -q "^.*XHCI " "$log_file"; then
echo "ERROR: xHCI controller not detected in boot log; see $log_file" >&2
exit 1
fi
echo "IRQ_DRIVER=xhcid"
echo "IRQ_MODE=$mode"
echo "IRQ_REASON=$reason"
echo "IRQ_LOG=$log_file"
echo "xHCI interrupt mode detected in $log_file"
echo "xHCI interrupt-driven mode confirmed in $log_file"
exit 0
fi