qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH 5/7] avocado: Add an optional flag 'login' to ge


From: Philippe Mathieu-Daudé
Subject: [Qemu-devel] [RFC PATCH 5/7] avocado: Add an optional flag 'login' to get_console()
Date: Thu, 19 Apr 2018 13:46:40 -0300

Not all consoles require users to log in :/

Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
 tests/avocado/avocado_qemu/test.py | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/tests/avocado/avocado_qemu/test.py 
b/tests/avocado/avocado_qemu/test.py
index 1ead917014..ac8ee6d250 100644
--- a/tests/avocado/avocado_qemu/test.py
+++ b/tests/avocado/avocado_qemu/test.py
@@ -244,7 +244,7 @@ class _VM(qemu.QEMUMachine):
         super(_VM, self).__init__(qemu_bin, name=self.name, arch=arch)
         logging.getLogger('QMP').setLevel(logging.INFO)
 
-    def get_console(self, console_address=None, prompt=r"[\#\$] "):
+    def get_console(self, console_address=None, prompt=r"[\#\$] ", login=True):
         """
         :param address: Socket address, can be either a unix socket path
                         (string) or a tuple in the form (address, port)
@@ -252,9 +252,6 @@ class _VM(qemu.QEMUMachine):
         :param prompt: The regex to identify we reached the prompt.
         """
 
-        if not all((self.username, self.password)):
-            raise QEMULoginError('Username or password not set.')
-
         if not self.is_running():
             raise QEMULoginError('VM is not running.')
 
@@ -272,13 +269,17 @@ class _VM(qemu.QEMUMachine):
             nc_cmd += ' -U %s' % console_address
 
         console = aexpect.ShellSession(nc_cmd)
-        try:
-            logging.info('Console: Waiting login prompt...')
-            _handle_prompts(console, self.username, self.password, prompt)
-            logging.info('Console: Ready!')
-        except:
-            console.close()
-            raise
+        if login:
+            if not all((self.username, self.password)):
+                raise QEMULoginError('Username or password not set.')
+
+            try:
+                logging.info('Console: Waiting login prompt...')
+                _handle_prompts(console, self.username, self.password, prompt)
+            except:
+                console.close()
+                raise
+        logging.info('Console: Ready!')
 
         return console
 
-- 
2.17.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]