qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 34/97] vmstate: Test for VMSTATE_UINT32_ARRAY{_TEST}


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 34/97] vmstate: Test for VMSTATE_UINT32_ARRAY{_TEST}
Date: Mon, 7 Apr 2014 05:20:52 +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        | 18 ++++++++++++++++++
 3 files changed, 26 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 2579c4f..703f07b 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 ae0421e..76ad401 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -543,6 +543,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 = {
@@ -552,6 +554,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 = {
@@ -564,6 +568,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()
     }
 };
@@ -573,6 +578,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 */
 };

@@ -630,6 +638,7 @@ static void test_array_primitive(void)
         ELEM_ASSERT(u8_1, i);
         ELEM_NOT_ASSERT(u8_2, i);
         ELEM_ASSERT(u16_1, i);
+        ELEM_ASSERT(u32_1, i);
     }

     /* We save the file again.  We want the EOF this time */
@@ -656,6 +665,10 @@ static const VMStateDescription vmstate_array_test = {
         VMSTATE_INT32(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()
     }
 };
@@ -663,6 +676,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 */
 };

@@ -712,6 +728,8 @@ static void test_array_test(void)
     FIELD_ASSERT(size);
     for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
         ELEM_ASSERT(b_1, i);
+        ELEM_ASSERT(u32_1, i);
+        ELEM_NOT_ASSERT(u32_2, i);
     }
 }
 #undef FIELD_ASSERT
-- 
1.9.0




reply via email to

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