from __future__ import annotations import pytest from pyro_mcp.runtime_boot_check import _classify_result, run_boot_check def test_classify_result_reports_kernel_panic() -> None: reason = _classify_result( firecracker_log="Successfully started microvm", serial_log="Kernel panic - not syncing: VFS: Unable to mount root fs", vm_alive=False, ) assert reason == "guest kernel panic during boot" def test_classify_result_reports_success_when_vm_stays_alive() -> None: reason = _classify_result( firecracker_log="Successfully started microvm", serial_log="boot log", vm_alive=True, ) assert reason is None def test_classify_result_reports_logger_failure_and_early_exit() -> None: logger_reason = _classify_result( firecracker_log="Successfully started microvm", serial_log="Could not initialize logger", vm_alive=False, ) early_exit_reason = _classify_result( firecracker_log="partial log", serial_log="boot log", vm_alive=False, ) assert logger_reason == "firecracker logger initialization failed" assert early_exit_reason == "firecracker did not fully start the microVM" def test_classify_result_reports_boot_window_exit_after_start() -> None: reason = _classify_result( firecracker_log="Successfully started microvm", serial_log="boot log", vm_alive=False, ) assert reason == "microVM exited before boot validation window elapsed" def test_run_boot_check_requires_positive_wait_seconds() -> None: with pytest.raises(ValueError, match="wait_seconds must be positive"): run_boot_check(wait_seconds=0)