All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niek Linnenbank <nieklinnenbank@gmail.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Fam Zheng" <fam@euphon.net>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Kamil Rytarowski" <kamil@netbsd.org>,
	qemu-arm <qemu-arm@nongnu.org>, "Cleber Rosa" <crosa@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH 1/4] Acceptance tests: Extract _console_interaction()
Date: Sun, 19 Jan 2020 01:26:02 +0100	[thread overview]
Message-ID: <CAPan3WqEd10j4SJ_HE3zN+STGVHnM7j8MWh72G7vL8E99FJCLg@mail.gmail.com> (raw)
In-Reply-To: <20200118191623.32549-2-f4bug@amsat.org>

[-- Attachment #1: Type: text/plain, Size: 3456 bytes --]

On Sat, Jan 18, 2020 at 8:16 PM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> Since we are going to re-use the code shared between
> wait_for_console_pattern() and exec_command_and_wait_for_pattern(),
> extract the common part into a local function.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>

> ---
>  tests/acceptance/avocado_qemu/__init__.py | 31 +++++++++++++----------
>  1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/tests/acceptance/avocado_qemu/__init__.py
> b/tests/acceptance/avocado_qemu/__init__.py
> index 6618ea67c1..0a50fcf2be 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -55,19 +55,14 @@ def pick_default_qemu_bin(arch=None):
>          return qemu_bin_from_src_dir_path
>
>
> -def wait_for_console_pattern(test, success_message, failure_message=None):
> -    """
> -    Waits for messages to appear on the console, while logging the content
> -
> -    :param test: an Avocado test containing a VM that will have its
> console
> -                 read and probed for a success or failure message
> -    :type test: :class:`avocado_qemu.Test`
> -    :param success_message: if this message appears, test succeeds
> -    :param failure_message: if this message appears, test fails
> -    """
> +def _console_interaction(test, success_message, failure_message,
> +                         send_string):
>      console = test.vm.console_socket.makefile()
>      console_logger = logging.getLogger('console')
>      while True:
> +        if send_string:
> +            test.vm.console_socket.sendall(send_string.encode())
> +            send_string = None # send only once
>          msg = console.readline().strip()
>          if not msg:
>              continue
> @@ -79,6 +74,17 @@ def wait_for_console_pattern(test, success_message,
> failure_message=None):
>              fail = 'Failure message found in console: %s' %
> failure_message
>              test.fail(fail)
>
> +def wait_for_console_pattern(test, success_message, failure_message=None):
> +    """
> +    Waits for messages to appear on the console, while logging the content
> +
> +    :param test: an Avocado test containing a VM that will have its
> console
> +                 read and probed for a success or failure message
> +    :type test: :class:`avocado_qemu.Test`
> +    :param success_message: if this message appears, test succeeds
> +    :param failure_message: if this message appears, test fails
> +    """
> +    _console_interaction(test, success_message, failure_message, None)
>
>  def exec_command_and_wait_for_pattern(test, command,
>                                        success_message,
> failure_message=None):
> @@ -94,10 +100,7 @@ def exec_command_and_wait_for_pattern(test, command,
>      :param success_message: if this message appears, test succeeds
>      :param failure_message: if this message appears, test fails
>      """
> -    command += '\r'
> -    test.vm.console_socket.sendall(command.encode())
> -    wait_for_console_pattern(test, success_message, failure_message)
> -
> +    _console_interaction(test, success_message, failure_message, command
> + '\r')
>
>  class Test(avocado.Test):
>      def _get_unique_tag_val(self, tag_name):
> --
> 2.21.1
>
>

-- 
Niek Linnenbank

[-- Attachment #2: Type: text/html, Size: 4512 bytes --]

  reply	other threads:[~2020-01-19  0:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-18 19:16 [PATCH 0/4] tests/boot_linux_console: Test booting NetBSD via U-Boot on OrangePi PC Philippe Mathieu-Daudé
2020-01-18 19:16 ` [PATCH 1/4] Acceptance tests: Extract _console_interaction() Philippe Mathieu-Daudé
2020-01-19  0:26   ` Niek Linnenbank [this message]
2020-01-18 19:16 ` [PATCH 2/4] Acceptance tests: Add interrupt_interactive_console_until_pattern() Philippe Mathieu-Daudé
2020-01-19  0:26   ` Niek Linnenbank
2020-01-18 19:16 ` [PATCH 3/4] tests/boot_linux_console: Test booting NetBSD via U-Boot on OrangePi PC Philippe Mathieu-Daudé
2020-01-19  0:25   ` Niek Linnenbank
2020-01-18 19:16 ` [PATCH 4/4] .travis.yml: Allow untrusted code and large files Philippe Mathieu-Daudé
2020-01-19  0:28   ` Niek Linnenbank
2020-01-19 11:20     ` Philippe Mathieu-Daudé
2020-01-19  8:52 ` [PATCH 0/4] tests/boot_linux_console: Test booting NetBSD via U-Boot on OrangePi PC Kamil Rytarowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPan3WqEd10j4SJ_HE3zN+STGVHnM7j8MWh72G7vL8E99FJCLg@mail.gmail.com \
    --to=nieklinnenbank@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=fam@euphon.net \
    --cc=kamil@netbsd.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.