diff options
author | Willian Rampazzo | 2021-03-03 21:53:19 +0100 |
---|---|---|
committer | Cleber Rosa | 2021-03-17 03:17:33 +0100 |
commit | cd093d5a2c92c34657c328affcb6ce5413cd205e (patch) | |
tree | e92512bf552119a1d35fd35599ca5cf6101e527c /tests/acceptance | |
parent | tests/migration: fix unix socket batch migration (diff) | |
download | qemu-cd093d5a2c92c34657c328affcb6ce5413cd205e.tar.gz qemu-cd093d5a2c92c34657c328affcb6ce5413cd205e.tar.xz qemu-cd093d5a2c92c34657c328affcb6ce5413cd205e.zip |
avocado_qemu: add exec_command function
Sometimes a test needs to send a command to a console without waiting
for a pattern as a result, or the command issued do not produce any kind
of output, like, for example, a `mount` command.
This introduces the `exec_command` function to the avocado_qemu,
allowing the test to send a command to the console without the need to
match a pattern produced as a result.
Signed-off-by: Willian Rampazzo <willianr@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20210303205320.146047-2-willianr@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
Diffstat (limited to 'tests/acceptance')
-rw-r--r-- | tests/acceptance/avocado_qemu/__init__.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index ed338caaba..ac8041821f 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -93,7 +93,7 @@ def _console_interaction(test, success_message, failure_message, if not msg: continue console_logger.debug(msg) - if success_message in msg: + if success_message is None or success_message in msg: break if failure_message and failure_message in msg: console.close() @@ -140,6 +140,18 @@ def wait_for_console_pattern(test, success_message, failure_message=None, """ _console_interaction(test, success_message, failure_message, None, vm=vm) +def exec_command(test, command): + """ + Send a command to a console (appending CRLF characters), while logging + the content. + + :param test: an Avocado test containing a VM. + :type test: :class:`avocado_qemu.Test` + :param command: the command to send + :type command: str + """ + _console_interaction(test, None, None, command + '\r') + def exec_command_and_wait_for_pattern(test, command, success_message, failure_message=None): """ |