|
11 | 11 |
|
12 | 12 | from framework import utils
|
13 | 13 | from framework.microvm import Serial
|
14 |
| -from framework.state_machine import TestState |
15 | 14 |
|
16 | 15 | PLATFORM = platform.machine()
|
17 | 16 |
|
18 | 17 |
|
19 |
| -class WaitTerminal(TestState): |
20 |
| - """Initial state when we wait for the login prompt.""" |
21 |
| - |
22 |
| - def handle_input(self, serial, input_char) -> TestState: |
23 |
| - """Handle input and return next state.""" |
24 |
| - if self.match(input_char): |
25 |
| - serial.tx("id") |
26 |
| - return WaitIDResult("uid=0(root) gid=0(root) groups=0(root)") |
27 |
| - return self |
28 |
| - |
29 |
| - |
30 |
| -class WaitIDResult(TestState): |
31 |
| - """Wait for the console to show the result of the 'id' shell command.""" |
32 |
| - |
33 |
| - def handle_input(self, unused_serial, input_char) -> TestState: |
34 |
| - """Handle input and return next state.""" |
35 |
| - if self.match(input_char): |
36 |
| - return TestFinished() |
37 |
| - return self |
38 |
| - |
39 |
| - |
40 |
| -class TestFinished(TestState): |
41 |
| - """Test complete and successful.""" |
42 |
| - |
43 |
| - def handle_input(self, unused_serial, _) -> TestState: |
44 |
| - """Return self since the test is about to end.""" |
45 |
| - return self |
46 |
| - |
47 |
| - |
48 | 18 | def test_serial_after_snapshot(uvm_plain, microvm_factory):
|
49 | 19 | """
|
50 | 20 | Serial I/O after restoring from a snapshot.
|
@@ -104,11 +74,9 @@ def test_serial_console_login(uvm_plain_any):
|
104 | 74 |
|
105 | 75 | serial = Serial(microvm)
|
106 | 76 | serial.open()
|
107 |
| - current_state = WaitTerminal("ubuntu-fc-uvm:") |
108 |
| - |
109 |
| - while not isinstance(current_state, TestFinished): |
110 |
| - output_char = serial.rx_char() |
111 |
| - current_state = current_state.handle_input(serial, output_char) |
| 77 | + serial.rx("ubuntu-fc-uvm:") |
| 78 | + serial.tx("id") |
| 79 | + serial.rx("uid=0(root) gid=0(root) groups=0(root)") |
112 | 80 |
|
113 | 81 |
|
114 | 82 | def get_total_mem_size(pid):
|
|
0 commit comments