]> Git Repo - qemu.git/commitdiff
tests/boot_linux_console: refactor the console watcher into utility method
authorCleber Rosa <[email protected]>
Tue, 12 Mar 2019 17:18:15 +0000 (13:18 -0400)
committerEduardo Habkost <[email protected]>
Fri, 3 May 2019 00:33:26 +0000 (21:33 -0300)
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 <[email protected]>
Reviewed-by: Caio Carrara <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Message-Id: <20190312171824[email protected]>
Signed-off-by: Eduardo Habkost <[email protected]>
tests/acceptance/boot_linux_console.py

index bfcae3771ba9284ca4757ec6a4c8a7052b6a1983..32f1d4d0bf577df4efaf31a2acaf6a628bdf0e28 100644 (file)
@@ -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)
This page took 0.027122 seconds and 4 git commands to generate.