From: John Levon <john.levon@nutanix.com>
To: qemu-devel@nongnu.org
Cc: "Cédric Le Goater" <clg@redhat.com>,
"Thanos Makatos" <thanos.makatos@nutanix.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"John Levon" <john.levon@nutanix.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH v4 2/3] tests/functional: add vm param to cmd.py helpers
Date: Wed, 3 Sep 2025 22:19:30 +0200 [thread overview]
Message-ID: <20250903201931.168317-3-john.levon@nutanix.com> (raw)
In-Reply-To: <20250903201931.168317-1-john.levon@nutanix.com>
Extend the "vm" parameter of wait_for_console_pattern() to all the other
utility functions; this allows them to be used on a VM other than
test.vm.
Signed-off-by: John Levon <john.levon@nutanix.com>
---
tests/functional/qemu_test/cmd.py | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py
index c19dfc577f..8069c89730 100644
--- a/tests/functional/qemu_test/cmd.py
+++ b/tests/functional/qemu_test/cmd.py
@@ -144,7 +144,8 @@ def _console_interaction(test, success_message, failure_message,
def interrupt_interactive_console_until_pattern(test, success_message,
failure_message=None,
- interrupt_string='\r'):
+ interrupt_string='\r',
+ vm=None):
"""
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:
@@ -164,12 +165,13 @@ def interrupt_interactive_console_until_pattern(test, success_message,
: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
+ :param vm: VM to use
:return: The collected output (in bytes form).
"""
assert success_message
return _console_interaction(test, success_message, failure_message,
- interrupt_string, True)
+ interrupt_string, True, vm=vm)
def wait_for_console_pattern(test, success_message, failure_message=None,
vm=None):
@@ -181,6 +183,7 @@ def wait_for_console_pattern(test, success_message, failure_message=None,
:type test: :class:`qemu_test.QemuSystemTest`
:param success_message: if this message appears, test succeeds
:param failure_message: if this message appears, test fails
+ :param vm: VM to use
:return: The collected output (in bytes form).
"""
@@ -188,7 +191,7 @@ def wait_for_console_pattern(test, success_message, failure_message=None,
return _console_interaction(test, success_message, failure_message,
None, vm=vm)
-def exec_command(test, command):
+def exec_command(test, command, vm=None):
"""
Send a command to a console (appending CRLF characters), while logging
the content.
@@ -196,14 +199,16 @@ def exec_command(test, command):
:param test: a test containing a VM.
:type test: :class:`qemu_test.QemuSystemTest`
:param command: the command to send
+ :param vm: VM to use
:type command: str
:return: The collected output (in bytes form).
"""
- return _console_interaction(test, None, None, command + '\r')
+ return _console_interaction(test, None, None, command + '\r', vm=vm)
def exec_command_and_wait_for_pattern(test, command,
- success_message, failure_message=None):
+ success_message, failure_message=None,
+ vm=None):
"""
Send a command to a console (appending CRLF characters), then wait
for success_message to appear on the console, while logging the.
@@ -215,13 +220,14 @@ def exec_command_and_wait_for_pattern(test, command,
:param command: the command to send
:param success_message: if this message appears, test succeeds
:param failure_message: if this message appears, test fails
+ :param vm: VM to use
:return: The collected output (in bytes form).
"""
assert success_message
return _console_interaction(test, success_message, failure_message,
- command + '\r')
+ command + '\r', vm=vm)
def get_qemu_img(test):
test.log.debug('Looking for and selecting a qemu-img binary')
--
2.43.0
next prev parent reply other threads:[~2025-09-03 20:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 20:19 [PATCH v4 0/3] vfio-user client functional test John Levon
2025-09-03 20:19 ` [PATCH v4 1/3] tests/functional: return output from cmd.py helpers John Levon
2025-09-08 14:32 ` Daniel P. Berrangé
2025-09-03 20:19 ` John Levon [this message]
2025-09-08 14:33 ` [PATCH v4 2/3] tests/functional: add vm param to " Daniel P. Berrangé
2025-09-03 20:19 ` [PATCH v4 3/3] tests/functional: add a vfio-user smoke test John Levon
2025-09-08 14:42 ` Daniel P. Berrangé
2025-09-09 14:44 ` John Levon
2025-09-09 13:58 ` [PATCH v4 0/3] vfio-user client functional test Thomas Huth
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=20250903201931.168317-3-john.levon@nutanix.com \
--to=john.levon@nutanix.com \
--cc=berrange@redhat.com \
--cc=clg@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thanos.makatos@nutanix.com \
--cc=thuth@redhat.com \
--cc=zhao1.liu@intel.com \
/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).