diff mbox

[2/2] test-vmstate: Silence expected errors

Message ID 20161020103636.22228-3-dgilbert@redhat.com
State New
Headers show

Commit Message

Dr. David Alan Gilbert Oct. 20, 2016, 10:36 a.m. UTC
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

test-vmstate has some expected failure tests (from explicitly
truncating an input stream); these trigger errors in the migration
code that are now reported;  silence these errors.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 tests/test-vmstate.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Markus Armbruster Oct. 24, 2016, 12:55 p.m. UTC | #1
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> writes:

> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> test-vmstate has some expected failure tests (from explicitly
> truncating an input stream); these trigger errors in the migration
> code that are now reported;  silence these errors.
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>  tests/test-vmstate.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
> index d8da26f..79cca87 100644
> --- a/tests/test-vmstate.c
> +++ b/tests/test-vmstate.c
> @@ -27,8 +27,10 @@
>  #include "qemu-common.h"
>  #include "migration/migration.h"
>  #include "migration/vmstate.h"
> +#include "monitor/monitor.h"
>  #include "qemu/coroutine.h"
>  #include "io/channel-file.h"
> +#include "libqtest.h"
>  
>  static char temp_file[] = "/tmp/vmst.test.XXXXXX";
>  static int temp_fd;
> @@ -132,6 +134,9 @@ static int load_vmstate(const VMStateDescription *desc,
>                          void (*obj_copy)(void *, void*),
>                          int version, uint8_t *wire, size_t size)
>  {
> +    /* Silence errors during the expected failures */
> +    cur_mon = &stubs_silent_monitor;
> +
>      /* We test with zero size */
>      obj_copy(obj_clone, obj);
>      FAILURE(load_vmstate_one(desc, obj, version, wire, 0));
> @@ -154,6 +159,9 @@ static int load_vmstate(const VMStateDescription *desc,
>          FAILURE(load_vmstate_one(desc, obj, version, wire + (size/2), size/2));
>  
>      }
> +    /* Now we shouldn't get any more errors - go back to normal */

I feel this comment is of marginal value, especially once the pattern
becomes more widely used.

> +    cur_mon = NULL;
> +
>      obj_copy(obj, obj_clone);
>      return load_vmstate_one(desc, obj, version, wire, size);
>  }

Works.  My autopilot would do

       old_mon = cur_mon;
       cur_mon = &stubs_silent_monitor;

       ...

       cur_mon = old_mon

because it avoids making assumptions on cur_mon's value.  Pick what you
like better.
Paolo Bonzini Oct. 24, 2016, 1 p.m. UTC | #2
On 24/10/2016 14:55, Markus Armbruster wrote:
> Works.  My autopilot would do
> 
>        old_mon = cur_mon;
>        cur_mon = &stubs_silent_monitor;
> 
>        ...
> 
>        cur_mon = old_mon
> 
> because it avoids making assumptions on cur_mon's value.  Pick what you
> like better.

I don't think we should rely on a monitor.  The assertion here is that
there was no error_report.

Paolo
diff mbox

Patch

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index d8da26f..79cca87 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -27,8 +27,10 @@ 
 #include "qemu-common.h"
 #include "migration/migration.h"
 #include "migration/vmstate.h"
+#include "monitor/monitor.h"
 #include "qemu/coroutine.h"
 #include "io/channel-file.h"
+#include "libqtest.h"
 
 static char temp_file[] = "/tmp/vmst.test.XXXXXX";
 static int temp_fd;
@@ -132,6 +134,9 @@  static int load_vmstate(const VMStateDescription *desc,
                         void (*obj_copy)(void *, void*),
                         int version, uint8_t *wire, size_t size)
 {
+    /* Silence errors during the expected failures */
+    cur_mon = &stubs_silent_monitor;
+
     /* We test with zero size */
     obj_copy(obj_clone, obj);
     FAILURE(load_vmstate_one(desc, obj, version, wire, 0));
@@ -154,6 +159,9 @@  static int load_vmstate(const VMStateDescription *desc,
         FAILURE(load_vmstate_one(desc, obj, version, wire + (size/2), size/2));
 
     }
+    /* Now we shouldn't get any more errors - go back to normal */
+    cur_mon = NULL;
+
     obj_copy(obj, obj_clone);
     return load_vmstate_one(desc, obj, version, wire, size);
 }