[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 18/20] Acceptance tests: Add interrupt_interactive_console_unt
From: |
Niek Linnenbank |
Subject: |
[PATCH v4 18/20] Acceptance tests: Add interrupt_interactive_console_until_pattern() |
Date: |
Sun, 19 Jan 2020 01:51:00 +0100 |
From: Philippe Mathieu-Daudé <address@hidden>
We need a function to interrupt interactive consoles.
Example: Interrupt U-Boot to set different environment values.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Tested-by: Niek Linnenbank <address@hidden>
Signed-off-by: Niek Linnenbank <address@hidden>
---
tests/acceptance/avocado_qemu/__init__.py | 32 +++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/tests/acceptance/avocado_qemu/__init__.py
b/tests/acceptance/avocado_qemu/__init__.py
index 0a50fcf2be..d4358eb431 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -56,13 +56,15 @@ def pick_default_qemu_bin(arch=None):
def _console_interaction(test, success_message, failure_message,
- send_string):
+ send_string, keep_sending=False):
+ assert not keep_sending or send_string
console = test.vm.console_socket.makefile()
console_logger = logging.getLogger('console')
while True:
if send_string:
test.vm.console_socket.sendall(send_string.encode())
- send_string = None # send only once
+ if not keep_sending:
+ send_string = None # send only once
msg = console.readline().strip()
if not msg:
continue
@@ -74,6 +76,32 @@ def _console_interaction(test, success_message,
failure_message,
fail = 'Failure message found in console: %s' % failure_message
test.fail(fail)
+def interrupt_interactive_console_until_pattern(test, success_message,
+ failure_message=None,
+ interrupt_string='\r'):
+ """
+ Keep sending a string to interrupt a console prompt, while logging the
+ console output. Typical use case is to break a boot loader prompt, such:
+
+ Press a key within 5 seconds to interrupt boot process.
+ 5
+ 4
+ 3
+ 2
+ 1
+ Booting default image...
+
+ :param test: an Avocado test containing a VM that will have its console
+ read and probed for a success or failure message
+ :type test: :class:`avocado_qemu.Test`
+ :param success_message: if this message appears, test succeeds
+ :param failure_message: if this message appears, test fails
+ :param interrupt_string: a string to send to the console before trying
+ to read a new line
+ """
+ _console_interaction(test, success_message, failure_message,
+ interrupt_string, True)
+
def wait_for_console_pattern(test, success_message, failure_message=None):
"""
Waits for messages to appear on the console, while logging the content
--
2.17.1
- Re: [PATCH v4 05/20] hw/arm/allwinner-h3: add System Control module, (continued)
- [PATCH v4 07/20] hw/arm/allwinner: add Security Identifier device, Niek Linnenbank, 2020/01/18
- [PATCH v4 01/20] hw/arm: add Allwinner H3 System-on-Chip, Niek Linnenbank, 2020/01/18
- [PATCH v4 10/20] hw/arm/allwinner-h3: add Boot ROM support, Niek Linnenbank, 2020/01/18
- [PATCH v4 06/20] hw/arm/allwinner: add CPU Configuration module, Niek Linnenbank, 2020/01/18
- [PATCH v4 17/20] Acceptance tests: Extract _console_interaction(), Niek Linnenbank, 2020/01/18
- [PATCH v4 18/20] Acceptance tests: Add interrupt_interactive_console_until_pattern(),
Niek Linnenbank <=
- [PATCH v4 13/20] tests/boot_linux_console: Add a quick test for the OrangePi PC board, Niek Linnenbank, 2020/01/18
- [PATCH v4 15/20] tests/boot_linux_console: Add a SD card test for the OrangePi PC board, Niek Linnenbank, 2020/01/18
- [PATCH v4 14/20] tests/boot_linux_console: Add initrd test for the Orange Pi PC board, Niek Linnenbank, 2020/01/18
- [PATCH v4 16/20] tests/boot_linux_console: Add a SLOW test booting Ubuntu on OrangePi PC, Niek Linnenbank, 2020/01/18
- [PATCH v4 11/20] hw/arm/allwinner-h3: add SDRAM controller device, Niek Linnenbank, 2020/01/18
- [PATCH v4 12/20] hw/arm/allwinner: add RTC device support, Niek Linnenbank, 2020/01/18
- [PATCH v4 09/20] hw/arm/allwinner-h3: add EMAC ethernet device, Niek Linnenbank, 2020/01/18
- [PATCH v4 20/20] docs: add Orange Pi PC document, Niek Linnenbank, 2020/01/18
- [PATCH v4 19/20] tests/boot_linux_console: Test booting NetBSD via U-Boot on OrangePi PC, Niek Linnenbank, 2020/01/18