On 04/19/2018 12:46 PM, Philippe Mathieu-Daudé wrote: > Not all consoles require users to log in :/ >
You're breaking a lot of assumptions here (in a good way) ;). > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > 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 > > Since having docstrings for new parameters is a minor issue and not a requirement: Acked-by: Cleber Rosa <cr...@redhat.com>