qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 039/124] vmstate: Test for VMSTATE_UINT32_ARRAY{_TES


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 039/124] vmstate: Test for VMSTATE_UINT32_ARRAY{_TEST}
Date: Mon, 21 Apr 2014 16:40:19 +0200

Once there, change only user of VMSTATE_UInT32_ARRAY_V.

Signed-off-by: Juan Quintela <address@hidden>
---
 hw/misc/arm_sysctl.c        |  3 ++-
 include/migration/vmstate.h | 15 ++++++---------
 tests/test-vmstate.c        | 20 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/hw/misc/arm_sysctl.c b/hw/misc/arm_sysctl.c
index 807d48e..0f61241 100644
--- a/hw/misc/arm_sysctl.c
+++ b/hw/misc/arm_sysctl.c
@@ -65,7 +65,8 @@ static const VMStateDescription vmstate_arm_sysctl = {
         VMSTATE_UINT32_TEST(sys_cfgctrl, arm_sysctl_state, vmstate_2_plus),
         VMSTATE_UINT32_TEST(sys_cfgstat, arm_sysctl_state, vmstate_2_plus),
         VMSTATE_UINT32_TEST(sys_clcd, arm_sysctl_state, vmstate_3_plus),
-        VMSTATE_UINT32_ARRAY_V(mb_clock, arm_sysctl_state, 6, 4),
+        VMSTATE_UINT32_ARRAY_TEST(mb_clock, arm_sysctl_state, 6,
+                                  vmstate_4_plus),
         VMSTATE_VARRAY_UINT32(db_clock, arm_sysctl_state, db_num_clocks,
                               4, vmstate_info_uint32, uint32_t),
         VMSTATE_END_OF_LIST()
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 5935d60..8f4a1a3 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -612,6 +612,12 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT16_ARRAY(_f, _s, _n)                              \
     VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_uint16, uint16_t)

+#define VMSTATE_UINT32_ARRAY_TEST(_f, _s, _n, _t)                     \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, _t, vmstate_info_uint32, uint32_t)
+
+#define VMSTATE_UINT32_ARRAY(_f, _s, _n)                              \
+    VMSTATE_UINT32_ARRAY_TEST(_f, _s, _n, NULL)
+
 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)

@@ -627,15 +633,9 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2)                       \
     VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, 0)

-#define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)                        \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
-
 #define VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint32, uint32_t)

-#define VMSTATE_UINT32_ARRAY(_f, _s, _n)                              \
-    VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2)                      \
     VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, 0)

@@ -660,9 +660,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)

-#define VMSTATE_UINT32_ARRAY(_f, _s, _n)                              \
-    VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v)                         \
     VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index baf9046..f81d470 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -515,6 +515,8 @@ typedef struct TestArray {
     uint8_t  u8_1[VMSTATE_ARRAY_SIZE];
     uint8_t  u8_2[VMSTATE_ARRAY_SIZE];
     uint16_t u16_1[VMSTATE_ARRAY_SIZE];
+    uint32_t u32_1[VMSTATE_ARRAY_SIZE];
+    uint32_t u32_2[VMSTATE_ARRAY_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -524,6 +526,8 @@ TestArray obj_array = {
     .u8_1 = { 1, 2, 3, 4, 5},
     .u8_2 = { 5, 4, 3, 2, 1},
     .u16_1 = {11, 12, 13, 14, 15},
+    .u32_1 = {21, 22, 23, 24, 25},
+    .u32_2 = {25, 24, 23, 22, 21},
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -536,6 +540,7 @@ static const VMStateDescription vmstate_array_primitive = {
         VMSTATE_BOOL_ARRAY(b_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT8_ARRAY(u8_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT16_ARRAY(u16_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_UINT32_ARRAY(u32_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -545,6 +550,9 @@ uint8_t wire_array_primitive[] = {
     /* b_1 */   0x00, 0x01, 0x00, 0x01, 0x00,
     /* u8_1 */  0x01, 0x02, 0x03, 0x04, 0x05,
     /* u16_1 */ 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x0e, 0x00, 0x0f,
+    /* u32_1 */ 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16,
+                0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18,
+                0x00, 0x00, 0x00, 0x19,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -562,6 +570,8 @@ static void obj_array_copy(void *arg1, void *arg2)
         target->u8_1[i] = source->u8_1[i];
         target->u8_2[i] = source->u8_2[i];
         target->u16_1[i] = source->u16_1[i];
+        target->u32_1[i] = source->u32_1[i];
+        target->u32_2[i] = source->u32_2[i];
     }
 }

@@ -593,6 +603,7 @@ static void test_array_primitive(void)
         ELEM_EQUAL(u8_1, i);
         ELEM_NOT_EQUAL(u8_2, i);
         ELEM_EQUAL(u16_1, i);
+        ELEM_EQUAL(u32_1, i);
     }
 }

@@ -605,6 +616,10 @@ static const VMStateDescription vmstate_array_test = {
         VMSTATE_INT32_EQUAL(size, TestArray),
         VMSTATE_BOOL_ARRAY_TEST(b_1, TestArray, VMSTATE_ARRAY_SIZE, test_true),
         VMSTATE_BOOL_ARRAY_TEST(b_2, TestArray, VMSTATE_ARRAY_SIZE, 
test_false),
+        VMSTATE_UINT32_ARRAY_TEST(u32_1, TestArray, VMSTATE_ARRAY_SIZE,
+                                  test_true),
+        VMSTATE_UINT32_ARRAY_TEST(u32_2, TestArray, VMSTATE_ARRAY_SIZE,
+                                  test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -612,6 +627,9 @@ static const VMStateDescription vmstate_array_test = {
 uint8_t wire_array_test[] = {
     /* size */  0x00, 0x00, 0x00, 0x05,
     /* b_1 */   0x00, 0x01, 0x00, 0x01, 0x00,
+    /* u32_1 */ 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16,
+                0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18,
+                0x00, 0x00, 0x00, 0x19,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -634,6 +652,8 @@ static void test_array_test(void)
     FIELD_EQUAL(size);
     for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
         ELEM_EQUAL(b_1, i);
+        ELEM_EQUAL(u32_1, i);
+        ELEM_NOT_EQUAL(u32_2, i);
     }
 }
 #undef FIELD_EQUAL
-- 
1.9.0




reply via email to

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