qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 40/97] vmstate: Test for VMSTATE_UINT8_2DARRAY


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 40/97] vmstate: Test for VMSTATE_UINT8_2DARRAY
Date: Mon, 7 Apr 2014 05:20:58 +0200

Remove unused _V version.

Signed-off-by: Juan Quintela <address@hidden>
---
 include/migration/vmstate.h |  9 +++------
 tests/test-vmstate.c        | 19 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f925cc6..24f2bcf 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -639,21 +639,18 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_FLOAT64_ARRAY(_f, _s, _n)                             \
     VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_float64, float64)

+#define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2)                       \
+    VMSTATE_2DARRAY(_f, _s, _n1, _n2, 0, vmstate_info_uint8, uint8_t)
+
 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)

 #define VMSTATE_UINT16_2DARRAY(_f, _s, _n1, _n2)                      \
     VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, 0)

-#define VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, _v)                 \
-    VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint8, uint8_t)
-
 #define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)

-#define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2)                       \
-    VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, 0)
-
 #define VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint32, uint32_t)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index e64706f..e029960 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -535,6 +535,7 @@ static void test_simple_bitmap(void)
 #undef FIELD_ASSERT

 #define VMSTATE_ARRAY_SIZE 5
+#define VMSTATE_2D_SIZE 3

 typedef struct TestArray {
     int32_t  size;
@@ -552,6 +553,7 @@ typedef struct TestArray {
     int32_t i32_2[VMSTATE_ARRAY_SIZE];
     int64_t i64_1[VMSTATE_ARRAY_SIZE];
     float64 f64_1[VMSTATE_ARRAY_SIZE];
+    uint8_t u8_1d[VMSTATE_2D_SIZE][VMSTATE_2D_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -571,6 +573,9 @@ TestArray obj_array = {
     .i64_1 = {61, 62, 63, 64, 65},
     .f64_1 = {float64_zero, float64_one, float64_ln2, float64_pi,
               float64_infinity},
+    .u8_1d = { {71, 72, 73},
+               {74, 75, 76},
+               {77, 78, 79} },
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -589,6 +594,8 @@ static const VMStateDescription vmstate_array_primitive = {
         VMSTATE_INT32_ARRAY(i32_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_INT64_ARRAY(i64_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_FLOAT64_ARRAY(f64_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_UINT8_2DARRAY(u8_1d, TestArray, VMSTATE_2D_SIZE,
+                              VMSTATE_2D_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -620,13 +627,16 @@ uint8_t wire_array_primitive[] = {
                 0x3f, 0xe6, 0x2e, 0x42, 0xfe, 0xfa, 0x39, 0xef,
                 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18,
                 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    /* u8_1d */ 0x47, 0x48, 0x49,
+                0x4a, 0x4b, 0x4c,
+                0x4d, 0x4e, 0x4f,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

 static void test_array_primitive(void)
 {
     QEMUFile *fsave = open_test_file(true);
-    int i;
+    int i, j;

     /* Save file with vmstate */
     vmstate_save_state(fsave, &vmstate_array_primitive, &obj_array);
@@ -668,6 +678,8 @@ static void test_array_primitive(void)
 #define FIELD_ASSERT(name)   g_assert_cmpint(obj.name, ==, obj_array.name)
 #define ELEM_ASSERT(name, i) \
     g_assert_cmpint(obj.name[i], ==, obj_array.name[i])
+#define ELEM_ASSERT_2D(name, i, j)                        \
+    g_assert_cmpint(obj.name[i][j], ==, obj_array.name[i][j])
 #define ELEM_NOT_ASSERT(name, i) \
     g_assert_cmpint(obj.name[i], !=, obj_array.name[i])

@@ -684,6 +696,11 @@ static void test_array_primitive(void)
         ELEM_ASSERT(i64_1, i);
         ELEM_ASSERT(f64_1, i);
     }
+    for (i = 0; i < VMSTATE_2D_SIZE; i++) {
+        for (j = 0; j < VMSTATE_2D_SIZE; j++) {
+            ELEM_ASSERT_2D(u8_1d, i, j);
+        }
+    }

     /* We save the file again.  We want the EOF this time */

-- 
1.9.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]