[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/19] tests/boot_linux_console: refactor the console
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PULL 11/19] tests/boot_linux_console: refactor the console watcher into utility method |
Date: |
Thu, 2 May 2019 21:41:22 -0300 |
From: Cleber Rosa <address@hidden>
This introduces a utility method that monitors the console device and
looks for either a message that signals the test success or failure.
Signed-off-by: Cleber Rosa <address@hidden>
Reviewed-by: Caio Carrara <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
tests/acceptance/boot_linux_console.py | 30 ++++++++++++++++++--------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/tests/acceptance/boot_linux_console.py
b/tests/acceptance/boot_linux_console.py
index bfcae3771b..32f1d4d0bf 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -23,6 +23,25 @@ class BootLinuxConsole(Test):
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
+ def wait_for_console_pattern(self, success_message,
+ failure_message='Kernel panic - not syncing'):
+ """
+ Waits for messages to appear on the console, while logging the content
+
+ :param success_message: if this message appears, test succeeds
+ :param failure_message: if this message appears, test fails
+ """
+ console = self.vm.console_socket.makefile()
+ console_logger = logging.getLogger('console')
+ while True:
+ msg = console.readline()
+ console_logger.debug(msg.strip())
+ if success_message in msg:
+ break
+ if failure_message in msg:
+ fail = 'Failure message found in console: %s' % failure_message
+ self.fail(fail)
+
def test_x86_64_pc(self):
"""
:avocado: tags=arch:x86_64
@@ -39,12 +58,5 @@ class BootLinuxConsole(Test):
self.vm.add_args('-kernel', kernel_path,
'-append', kernel_command_line)
self.vm.launch()
- console = self.vm.console_socket.makefile()
- console_logger = logging.getLogger('console')
- while True:
- msg = console.readline()
- console_logger.debug(msg.strip())
- if 'Kernel command line: %s' % kernel_command_line in msg:
- break
- if 'Kernel panic - not syncing' in msg:
- self.fail("Kernel panic reached")
+ console_pattern = 'Kernel command line: %s' % kernel_command_line
+ self.wait_for_console_pattern(console_pattern)
--
2.18.0.rc1.1.g3f1ff2140
- [Qemu-devel] [PULL 06/19] tests/acceptance: look for target architecture in test tags first, (continued)
- [Qemu-devel] [PULL 06/19] tests/acceptance: look for target architecture in test tags first, Eduardo Habkost, 2019/05/02
- [Qemu-devel] [PULL 07/19] tests/boot_linux_console: rename the x86_64 after the arch and machine, Eduardo Habkost, 2019/05/02
- [Qemu-devel] [PULL 08/19] tests/boot_linux_console: update the x86_64 kernel, Eduardo Habkost, 2019/05/02
- [Qemu-devel] [PULL 09/19] tests/boot_linux_console: add common kernel command line options, Eduardo Habkost, 2019/05/02
- [Qemu-devel] [PULL 10/19] tests/boot_linux_console: increase timeout, Eduardo Habkost, 2019/05/02
[Qemu-devel] [PULL 11/19] tests/boot_linux_console: refactor the console watcher into utility method,
Eduardo Habkost <=
[Qemu-devel] [PULL 12/19] scripts/qemu.py: support adding a console with the default serial device, Eduardo Habkost, 2019/05/02
[Qemu-devel] [PULL 13/19] tests/boot_linux_console: add a test for mips + malta, Eduardo Habkost, 2019/05/02
[Qemu-devel] [PULL 15/19] tests/boot_linux_console: add a test for aarch64 + virt, Eduardo Habkost, 2019/05/02
[Qemu-devel] [PULL 14/19] tests/boot_linux_console: add a test for mips64el + malta, Eduardo Habkost, 2019/05/02
[Qemu-devel] [PULL 18/19] tests/boot_linux_console: add a test for alpha + clipper, Eduardo Habkost, 2019/05/02
[Qemu-devel] [PULL 16/19] tests/boot_linux_console: add a test for arm + virt, Eduardo Habkost, 2019/05/02
[Qemu-devel] [PULL 17/19] tests/boot_linux_console: add a test for s390x + s390-ccw-virtio, Eduardo Habkost, 2019/05/02
[Qemu-devel] [PULL 19/19] configure: automatically pick python3 is available, Eduardo Habkost, 2019/05/02