"""Boot smoke tests for the rewritten emulator suite.""" from __future__ import annotations import pytest from .support.runtime import container_running, container_sh _MONITOR_COUNT_COMMAND = "ps -eo args | grep -c '[q]emu-arm.*monitor.app'" _INFORMER_COUNT_COMMAND = "ps -eo args | grep -c '[q]emu-arm.*informer'" pytestmark = pytest.mark.no_home_reset def _process_count(command: str) -> int: """Run one guest process-count shell command and return its count.""" result = container_sh(command, check=False) assert result.returncode == 0 return int(result.stdout.strip() or "0") def test_container_is_up(emulator): """The emulator fixture should leave a running container behind.""" assert emulator is not None assert container_running(), "expected emulator container to be running" def test_monitor_process_alive(emulator): """The guest monitor should stay alive after startup.""" assert emulator is not None assert _process_count(_MONITOR_COUNT_COMMAND) >= 1 def test_informer_process_alive(emulator): """The informer helper should still be alive inside the guest.""" assert emulator is not None assert _process_count(_INFORMER_COUNT_COMMAND) >= 1 def test_hwevent_queue_exists(emulator): """The monitor should create the hardware-event queue.""" assert emulator is not None result = container_sh("test -e /dev/mqueue/hwevent && echo ok") assert "ok" in result.stdout def test_task_state_dir_exists(emulator): """The task-state directory should be present for foreground tracking.""" assert emulator is not None result = container_sh("test -d /var/run/task && echo ok") assert "ok" in result.stdout