nixos/test-driver: add polling_condition
This commit is contained in:
@@ -17,6 +17,7 @@ import threading
|
||||
import time
|
||||
|
||||
from test_driver.logger import rootlog
|
||||
from test_driver.polling_condition import PollingCondition, coopmulti
|
||||
|
||||
CHAR_TO_KEY = {
|
||||
"A": "shift-a",
|
||||
@@ -318,6 +319,7 @@ class Machine:
|
||||
# Store last serial console lines for use
|
||||
# of wait_for_console_text
|
||||
last_lines: Queue = Queue()
|
||||
fail_early: Callable
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Machine '{self.name}'>"
|
||||
@@ -329,12 +331,14 @@ class Machine:
|
||||
name: str = "machine",
|
||||
keep_vm_state: bool = False,
|
||||
allow_reboot: bool = False,
|
||||
fail_early: Callable = lambda: False,
|
||||
) -> None:
|
||||
self.tmp_dir = tmp_dir
|
||||
self.keep_vm_state = keep_vm_state
|
||||
self.allow_reboot = allow_reboot
|
||||
self.name = name
|
||||
self.start_command = start_command
|
||||
self.fail_early = fail_early
|
||||
|
||||
# set up directories
|
||||
self.shared_dir = self.tmp_dir / "shared-xchg"
|
||||
@@ -405,6 +409,7 @@ class Machine:
|
||||
break
|
||||
return answer
|
||||
|
||||
@coopmulti
|
||||
def send_monitor_command(self, command: str) -> str:
|
||||
with self.nested("sending monitor command: {}".format(command)):
|
||||
message = ("{}\n".format(command)).encode()
|
||||
@@ -506,6 +511,7 @@ class Machine:
|
||||
break
|
||||
return "".join(output_buffer)
|
||||
|
||||
@coopmulti
|
||||
def execute(
|
||||
self, command: str, check_return: bool = True, timeout: Optional[int] = 900
|
||||
) -> Tuple[int, str]:
|
||||
|
||||
Reference in New Issue
Block a user