From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Andrew Baumann" <Andrew.Baumann@microsoft.com>,
"Niek Linnenbank" <nieklinnenbank@gmail.com>,
qemu-arm@nongnu.org, "Cleber Rosa" <crosa@redhat.com>,
"Laurent Bonnans" <laurent.bonnans@here.com>,
"Cheng Xiang" <ext-cheng.xiang@here.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH v4 3/7] Acceptance tests: Add interrupt_interactive_console_until_pattern()
Date: Tue, 21 Jan 2020 00:51:55 +0100 [thread overview]
Message-ID: <20200120235159.18510-4-f4bug@amsat.org> (raw)
In-Reply-To: <20200120235159.18510-1-f4bug@amsat.org>
We need a function to interrupt interactive consoles.
Example: Interrupt U-Boot to set different environment values.
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
tests/acceptance/avocado_qemu/__init__.py | 32 +++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index 0a50fcf2be..d4358eb431 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -56,13 +56,15 @@ def pick_default_qemu_bin(arch=None):
def _console_interaction(test, success_message, failure_message,
- send_string):
+ send_string, keep_sending=False):
+ assert not keep_sending or 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
+ if not keep_sending:
+ send_string = None # send only once
msg = console.readline().strip()
if not msg:
continue
@@ -74,6 +76,32 @@ def _console_interaction(test, success_message, failure_message,
fail = 'Failure message found in console: %s' % failure_message
test.fail(fail)
+def interrupt_interactive_console_until_pattern(test, success_message,
+ failure_message=None,
+ interrupt_string='\r'):
+ """
+ Keep sending a string to interrupt a console prompt, while logging the
+ console output. Typical use case is to break a boot loader prompt, such:
+
+ Press a key within 5 seconds to interrupt boot process.
+ 5
+ 4
+ 3
+ 2
+ 1
+ Booting default image...
+
+ :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
+ :param interrupt_string: a string to send to the console before trying
+ to read a new line
+ """
+ _console_interaction(test, success_message, failure_message,
+ interrupt_string, True)
+
def wait_for_console_pattern(test, success_message, failure_message=None):
"""
Waits for messages to appear on the console, while logging the content
--
2.21.1
next prev parent reply other threads:[~2020-01-20 23:53 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-20 23:51 [PATCH v4 0/7] hw/arm/raspi: Run U-Boot on the raspi machines Philippe Mathieu-Daudé
2020-01-20 23:51 ` [PATCH v4 1/7] hw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus' Philippe Mathieu-Daudé
2020-01-21 2:34 ` Alistair Francis
2020-01-20 23:51 ` [PATCH v4 2/7] Acceptance tests: Extract _console_interaction() Philippe Mathieu-Daudé
2020-01-28 11:01 ` Liam Merwick
2020-01-28 19:34 ` Wainer dos Santos Moschetta
2020-01-28 19:58 ` Wainer dos Santos Moschetta
2020-01-30 22:18 ` Philippe Mathieu-Daudé
2020-01-20 23:51 ` Philippe Mathieu-Daudé [this message]
2020-01-28 11:01 ` [PATCH v4 3/7] Acceptance tests: Add interrupt_interactive_console_until_pattern() Liam Merwick
2020-01-28 19:59 ` Wainer dos Santos Moschetta
2020-01-30 22:19 ` Philippe Mathieu-Daudé
2020-01-20 23:51 ` [PATCH v4 4/7] python/qemu/machine: Allow to use other serial consoles than default Philippe Mathieu-Daudé
2020-01-21 8:20 ` Philippe Mathieu-Daudé
2020-01-28 11:01 ` Liam Merwick
2020-01-28 19:12 ` Wainer dos Santos Moschetta
2020-01-30 22:15 ` Philippe Mathieu-Daudé
2020-01-20 23:51 ` [PATCH v4 5/7] tests/boot_linux_console: Test booting U-Boot on the Raspberry Pi 2 Philippe Mathieu-Daudé
2020-01-21 6:57 ` Gerd Hoffmann
2020-01-21 8:32 ` Philippe Mathieu-Daudé
2020-01-27 16:02 ` Thomas Huth
2020-01-27 16:09 ` Philippe Mathieu-Daudé
2020-01-27 16:15 ` Thomas Huth
2020-01-28 20:08 ` Wainer dos Santos Moschetta
2020-01-20 23:51 ` [PATCH v4 6/7] tests/boot_linux_console: Test booting U-Boot on the Raspberry Pi 3 Philippe Mathieu-Daudé
2020-01-28 20:10 ` Wainer dos Santos Moschetta
2020-01-20 23:51 ` [PATCH v4 7/7] tests/boot_linux_console: Tag Emcraft Smartfusion2 as running 'u-boot' Philippe Mathieu-Daudé
2020-01-27 16:05 ` Thomas Huth
2020-01-28 20:23 ` Wainer dos Santos Moschetta
2020-01-31 2:10 ` Philippe Mathieu-Daudé
2020-01-28 6:53 ` [PATCH v4 0/7] hw/arm/raspi: Run U-Boot on the raspi machines Philippe Mathieu-Daudé
2020-01-30 13:43 ` Peter Maydell
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=20200120235159.18510-4-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=Andrew.Baumann@microsoft.com \
--cc=alistair@alistair23.me \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=ext-cheng.xiang@here.com \
--cc=laurent.bonnans@here.com \
--cc=nieklinnenbank@gmail.com \
--cc=peter.maydell@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).