To navigate things like grub we need to send individual keys without
trying to look for success messages.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
tests/functional/qemu_test/__init__.py | 3 ++-
tests/functional/qemu_test/cmd.py | 15 +++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py
index 03e5c73d39d..9ed8c6a4b53 100644
--- a/tests/functional/qemu_test/__init__.py
+++ b/tests/functional/qemu_test/__init__.py
@@ -10,7 +10,8 @@
from .config import BUILD_DIR, dso_suffix
from .cmd import is_readable_executable_file, \
interrupt_interactive_console_until_pattern, wait_for_console_pattern, \
- exec_command, exec_command_and_wait_for_pattern, get_qemu_img, which
+ exec_command, exec_command_and_wait_for_pattern, get_qemu_img, \
+ which, send_key
from .testcase import QemuBaseTest, QemuUserTest, QemuSystemTest
from .linuxkernel import LinuxKernelTest
from .decorators import skipIfMissingCommands, skipIfNotMachine, \
diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py
index f544566245b..381e5162f02 100644
--- a/tests/functional/qemu_test/cmd.py
+++ b/tests/functional/qemu_test/cmd.py
@@ -142,6 +142,21 @@ def _console_interaction(test, success_message, failure_message,
return out
+def send_key(test, key, delay=0.2, vm=None):
+ """
+ Send a single key to the console.
+
+ :key: key to send
+ :delay: debounce delay to wait
+ :vm: the vm to send to, defaults to test.vm
+ """
+ if vm is None:
+ vm = test.vm
+
+ test.log.debug(f"Sending key: {key}")
+ vm.console_socket.sendall(key.encode())
+
+
def interrupt_interactive_console_until_pattern(test, success_message,
failure_message=None,
interrupt_string='\r',
--
2.47.3