qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 037/124] vmstate: Test for VMSTATE_UINT8_ARRAY


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 037/124] vmstate: Test for VMSTATE_UINT8_ARRAY
Date: Mon, 21 Apr 2014 16:40:17 +0200

Remove VMSTATE_UINT8_ARRAY_V that was unused.

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

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 490f0f4..19789c4 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -606,6 +606,9 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_BOOL_ARRAY(_f, _s, _n)                                \
     VMSTATE_BOOL_ARRAY_TEST(_f, _s, _n, NULL)

+#define VMSTATE_UINT8_ARRAY(_f, _s, _n)                               \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_uint8, uint8_t)
+
 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v)                         \
     VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)

@@ -621,12 +624,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #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_ARRAY_V(_f, _s, _n, _v)                         \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
-
-#define VMSTATE_UINT8_ARRAY(_f, _s, _n)                               \
-    VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 5cc5706..b2590e3 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -512,12 +512,16 @@ typedef struct TestArray {
     int32_t  size;
     bool     b_1[VMSTATE_ARRAY_SIZE];
     bool     b_2[VMSTATE_ARRAY_SIZE];
+    uint8_t  u8_1[VMSTATE_ARRAY_SIZE];
+    uint8_t  u8_2[VMSTATE_ARRAY_SIZE];
 } TestArray;

 TestArray obj_array = {
     .size = VMSTATE_ARRAY_SIZE,
     .b_1 = { false, true, false, true, false},
     .b_2 = { true, false, true, false, true},
+    .u8_1 = { 1, 2, 3, 4, 5},
+    .u8_2 = { 5, 4, 3, 2, 1},
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -528,6 +532,7 @@ static const VMStateDescription vmstate_array_primitive = {
     .fields = (VMStateField[]) {
         VMSTATE_INT32_EQUAL(size, TestArray),
         VMSTATE_BOOL_ARRAY(b_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_UINT8_ARRAY(u8_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -535,6 +540,7 @@ static const VMStateDescription vmstate_array_primitive = {
 uint8_t wire_array_primitive[] = {
     /* size */  0x00, 0x00, 0x00, 0x05,
     /* b_1 */   0x00, 0x01, 0x00, 0x01, 0x00,
+    /* u8_1 */  0x01, 0x02, 0x03, 0x04, 0x05,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -549,6 +555,8 @@ static void obj_array_copy(void *arg1, void *arg2)
     for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
         target->b_1[i] = source->b_1[i];
         target->b_2[i] = source->b_2[i];
+        target->u8_1[i] = source->u8_1[i];
+        target->u8_2[i] = source->u8_2[i];
     }
 }

@@ -571,10 +579,14 @@ static void test_array_primitive(void)
 #define FIELD_EQUAL(name)   g_assert_cmpint(obj.name, ==, obj_array.name)
 #define ELEM_EQUAL(name, i) \
     g_assert_cmpint(obj.name[i], ==, obj_array.name[i])
+#define ELEM_NOT_EQUAL(name, i) \
+    g_assert_cmpint(obj.name[i], !=, obj_array.name[i])

     FIELD_EQUAL(size);
     for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
         ELEM_EQUAL(b_1, i);
+        ELEM_EQUAL(u8_1, i);
+        ELEM_NOT_EQUAL(u8_2, i);
     }
 }

@@ -620,6 +632,7 @@ static void test_array_test(void)
 }
 #undef FIELD_EQUAL
 #undef ELEM_EQUAL
+#undef ELEM_NOT_EQUAL

 typedef struct TestVersioned {
     uint32_t a, b, c, e;
-- 
1.9.0




reply via email to

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