Skip to content

Add option to redirect guest serial console output to file #5350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Aug 18, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 0 additions & 58 deletions tests/framework/state_machine.py

This file was deleted.

38 changes: 3 additions & 35 deletions tests/integration_tests/functional/test_serial_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,10 @@

from framework import utils
from framework.microvm import Serial
from framework.state_machine import TestState

PLATFORM = platform.machine()


class WaitTerminal(TestState):
"""Initial state when we wait for the login prompt."""

def handle_input(self, serial, input_char) -> TestState:
"""Handle input and return next state."""
if self.match(input_char):
serial.tx("id")
return WaitIDResult("uid=0(root) gid=0(root) groups=0(root)")
return self


class WaitIDResult(TestState):
"""Wait for the console to show the result of the 'id' shell command."""

def handle_input(self, unused_serial, input_char) -> TestState:
"""Handle input and return next state."""
if self.match(input_char):
return TestFinished()
return self


class TestFinished(TestState):
"""Test complete and successful."""

def handle_input(self, unused_serial, _) -> TestState:
"""Return self since the test is about to end."""
return self


def test_serial_after_snapshot(uvm_plain, microvm_factory):
"""
Serial I/O after restoring from a snapshot.
Expand Down Expand Up @@ -104,11 +74,9 @@ def test_serial_console_login(uvm_plain_any):

serial = Serial(microvm)
serial.open()
current_state = WaitTerminal("ubuntu-fc-uvm:")

while not isinstance(current_state, TestFinished):
output_char = serial.rx_char()
current_state = current_state.handle_input(serial, output_char)
serial.rx("ubuntu-fc-uvm:")
serial.tx("id")
serial.rx("uid=0(root) gid=0(root) groups=0(root)")


def get_total_mem_size(pid):
Expand Down