[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH 5/7] avocado: Add an optional flag 'login' t
From: |
Cleber Rosa |
Subject: |
Re: [Qemu-devel] [RFC PATCH 5/7] avocado: Add an optional flag 'login' to get_console() |
Date: |
Tue, 1 May 2018 15:46:27 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
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é <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
>
>
Since having docstrings for new parameters is a minor issue and not a
requirement:
Acked-by: Cleber Rosa <address@hidden>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [RFC PATCH 5/7] avocado: Add an optional flag 'login' to get_console(),
Cleber Rosa <=