qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 32/97] vmstate: Test for VMSTATE_UINT8_ARRAY


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 32/97] vmstate: Test for VMSTATE_UINT8_ARRAY
Date: Mon, 7 Apr 2014 05:20:50 +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        | 11 +++++++++++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index ac5a939..c74cdf3 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 656e563..8a73d4c 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -540,12 +540,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 = {
@@ -556,6 +560,7 @@ static const VMStateDescription vmstate_array_primitive = {
     .fields = (VMStateField[]) {
         VMSTATE_INT32(size, TestArray),
         VMSTATE_BOOL_ARRAY(b_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_UINT8_ARRAY(u8_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -563,6 +568,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 */
 };

@@ -611,10 +617,14 @@ 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_NOT_ASSERT(name, i) \
+    g_assert_cmpint(obj.name[i], !=, obj_array.name[i])

     FIELD_ASSERT(size);
     for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
         ELEM_ASSERT(b_1, i);
+        ELEM_ASSERT(u8_1, i);
+        ELEM_NOT_ASSERT(u8_2, i);
     }

     /* We save the file again.  We want the EOF this time */
@@ -701,6 +711,7 @@ static void test_array_test(void)
 }
 #undef FIELD_ASSERT
 #undef ELEM_ASSERT
+#undef ELEM_NOT_ASSERT


 typedef struct TestStruct {
-- 
1.9.0




reply via email to

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