[PATCH] tests/acceptance: Print expected message on wait_for_console_pattern

Wainer dos Santos Moschetta posted 1 patch 4 years, 8 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210309153507.1905682-1-wainersm@redhat.com
Maintainers: "Philippe Mathieu-Daudé" <philmd@redhat.com>, Cleber Rosa <crosa@redhat.com>, Wainer dos Santos Moschetta <wainersm@redhat.com>
tests/acceptance/avocado_qemu/__init__.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] tests/acceptance: Print expected message on wait_for_console_pattern
Posted by Wainer dos Santos Moschetta 4 years, 8 months ago
For the sake of improve debuggability of tests which use the
wait_for_console_pattern(), this changed the _console_interaction() so that
the expected message is printed if the test fail.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
---
While I was testing  "[PATCH v2 2/2] tests/acceptance: Test ast2600 machine"
I could not clearly determine which of the called wait_for_console_pattern()
was failing. So this patch improves debuggability in such as situations.

 tests/acceptance/avocado_qemu/__init__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index df167b142c..ed338caaba 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -97,7 +97,8 @@ def _console_interaction(test, success_message, failure_message,
             break
         if failure_message and failure_message in msg:
             console.close()
-            fail = 'Failure message found in console: %s' % failure_message
+            fail = 'Failure message found in console: "%s". Expected: "%s"' % \
+                    (failure_message, success_message)
             test.fail(fail)
 
 def interrupt_interactive_console_until_pattern(test, success_message,
-- 
2.29.2


Re: [PATCH] tests/acceptance: Print expected message on wait_for_console_pattern
Posted by Joel Stanley 4 years, 8 months ago
On Tue, 9 Mar 2021 at 16:00, Wainer dos Santos Moschetta
<wainersm@redhat.com> wrote:
>
> For the sake of improve debuggability of tests which use the
> wait_for_console_pattern(), this changed the _console_interaction() so that
> the expected message is printed if the test fail.
>
> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
> ---
> While I was testing  "[PATCH v2 2/2] tests/acceptance: Test ast2600 machine"
> I could not clearly determine which of the called wait_for_console_pattern()
> was failing. So this patch improves debuggability in such as situations.

Nice!

Reviewed-by: Joel Stanley <joel@jms.id.au>

>
>  tests/acceptance/avocado_qemu/__init__.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> index df167b142c..ed338caaba 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -97,7 +97,8 @@ def _console_interaction(test, success_message, failure_message,
>              break
>          if failure_message and failure_message in msg:
>              console.close()
> -            fail = 'Failure message found in console: %s' % failure_message
> +            fail = 'Failure message found in console: "%s". Expected: "%s"' % \
> +                    (failure_message, success_message)
>              test.fail(fail)
>
>  def interrupt_interactive_console_until_pattern(test, success_message,
> --
> 2.29.2
>
>

Re: [PATCH] tests/acceptance: Print expected message on wait_for_console_pattern
Posted by Cleber Rosa 4 years, 8 months ago
On Tue, Mar 09, 2021 at 12:35:07PM -0300, Wainer dos Santos Moschetta wrote:
> For the sake of improve debuggability of tests which use the
> wait_for_console_pattern(), this changed the _console_interaction() so that
> the expected message is printed if the test fail.
> 
> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
> ---
> While I was testing  "[PATCH v2 2/2] tests/acceptance: Test ast2600 machine"
> I could not clearly determine which of the called wait_for_console_pattern()
> was failing. So this patch improves debuggability in such as situations.
> 
>  tests/acceptance/avocado_qemu/__init__.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>

Reviewed-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
Re: [PATCH] tests/acceptance: Print expected message on wait_for_console_pattern
Posted by Willian Rampazzo 4 years, 8 months ago
On Tue, Mar 9, 2021 at 12:36 PM Wainer dos Santos Moschetta
<wainersm@redhat.com> wrote:
>
> For the sake of improve debuggability of tests which use the
> wait_for_console_pattern(), this changed the _console_interaction() so that
> the expected message is printed if the test fail.
>
> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
> ---
> While I was testing  "[PATCH v2 2/2] tests/acceptance: Test ast2600 machine"
> I could not clearly determine which of the called wait_for_console_pattern()
> was failing. So this patch improves debuggability in such as situations.
>
>  tests/acceptance/avocado_qemu/__init__.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>

Reviewed-by: Willian Rampazzo <willianr@redhat.com>

> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> index df167b142c..ed338caaba 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -97,7 +97,8 @@ def _console_interaction(test, success_message, failure_message,
>              break
>          if failure_message and failure_message in msg:
>              console.close()
> -            fail = 'Failure message found in console: %s' % failure_message
> +            fail = 'Failure message found in console: "%s". Expected: "%s"' % \
> +                    (failure_message, success_message)
>              test.fail(fail)
>
>  def interrupt_interactive_console_until_pattern(test, success_message,
> --
> 2.29.2
>