qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 119/124] vmstate: Test for VMSTATE_STRUCT_VARRAY_INT


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 119/124] vmstate: Test for VMSTATE_STRUCT_VARRAY_INT32
Date: Mon, 21 Apr 2014 16:41:39 +0200

Signed-off-by: Juan Quintela <address@hidden>
---
 tests/test-vmstate.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 25e162f..8ccf07d 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -1655,6 +1655,8 @@ typedef struct TestStruct2 {
     SubStruct a[3];
     uint32_t size2;
     SubStruct b[3];
+    int32_t size3;
+    SubStruct c[3];
 } TestStruct2;

 /*
@@ -1673,6 +1675,9 @@ static const VMStateDescription vmstate_struct_varray = {
         VMSTATE_UINT32_EQUAL(size2, TestStruct2),
         VMSTATE_STRUCT_VARRAY_UINT32(b, TestStruct2, size2,
                                      vmstate_sub_struct, SubStruct),
+        VMSTATE_INT32_EQUAL(size3, TestStruct2),
+        VMSTATE_STRUCT_VARRAY_INT32(c, TestStruct2, size3,
+                                    vmstate_sub_struct, SubStruct),
         VMSTATE_STRUCT_VARRAY_UINT8(a, TestStruct2, size,
                                     vmstate_sub_struct, SubStruct),
         VMSTATE_END_OF_LIST()
@@ -1699,6 +1704,22 @@ uint8_t wire_struct_varray[] = {
     /* i64 */       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35,
     /* buffer */    0x62, 0x79, 0x65, 0x35, 0x20, 0x20, 0x77, 0x6f,
                     0x72, 0x6c, 0x64, 0x21, 0x00,
+    /* size3 */     0x00, 0x00, 0x00, 0x03,
+    /* c[0] */
+    /* i32 */       0x00, 0x00, 0x00, 0x3d,
+    /* i64 */       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
+    /* buffer */    0x62, 0x79, 0x65, 0x36, 0x20, 0x20, 0x77, 0x6f,
+                    0x72, 0x6c, 0x64, 0x21, 0x00,
+    /* c[1] */
+    /* i32 */       0x00, 0x00, 0x00, 0x3e,
+    /* i64 */       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48,
+    /* buffer */    0x62, 0x79, 0x65, 0x37, 0x20, 0x20, 0x77, 0x6f,
+                    0x72, 0x6c, 0x64, 0x21, 0x00,
+    /* c[2] */
+    /* i32 */       0x00, 0x00, 0x00, 0x3f,
+    /* i64 */       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49,
+    /* buffer */    0x62, 0x79, 0x65, 0x38, 0x20, 0x20, 0x77, 0x6f,
+                    0x72, 0x6c, 0x64, 0x21, 0x00,
     /* a[0] */
     /* i32 */       0x00, 0x00, 0x00, 0x15,
     /* i64 */       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
@@ -1725,6 +1746,7 @@ static void obj_struct2_copy(void *arg1, void *arg2)

     target->size = source->size;
     target->size2 = source->size2;
+    target->size3 = source->size3;
     for (i = 0; i < 3; i++) {
         target->a[i].i32 = source->a[i].i32;
         target->a[i].i64 = source->a[i].i64;
@@ -1732,6 +1754,9 @@ static void obj_struct2_copy(void *arg1, void *arg2)
         target->b[i].i32 = source->b[i].i32;
         target->b[i].i64 = source->b[i].i64;
         memcpy(target->b[i].buffer, source->b[i].buffer, 13);
+        target->c[i].i32 = source->c[i].i32;
+        target->c[i].i64 = source->c[i].i64;
+        memcpy(target->c[i].buffer, source->c[i].buffer, 13);
     }
 }

@@ -1740,6 +1765,7 @@ static TestStruct2 *create_struct2(void)
     TestStruct2 *obj = g_malloc0(sizeof(*obj));
     obj->size = 3;
     obj->size2 = 3;
+    obj->size3 = 3;

     return obj;
 }
@@ -1756,6 +1782,9 @@ static TestStruct2 *create_struct2_init(void)
         obj->b[i].i32 = i + 41;
         obj->b[i].i64 = i + 51;
         snprintf((char *)obj->b[i].buffer, 13, "bye%d  world!", i + 3);
+        obj->c[i].i32 = i + 61;
+        obj->c[i].i64 = i + 71;
+        snprintf((char *)obj->c[i].buffer, 13, "bye%d  world!", i + 6);
     }

     return obj;
@@ -1780,6 +1809,7 @@ static void test_struct_varray(void)
         sub_struct_size = sizeof(uint32_t) + sizeof(uint64_t) + 13;
         memset(obj->a, 0, sizeof(obj->a));
         memset(obj->b, 0, sizeof(obj->b));
+        memset(obj->c, 0, sizeof(obj->c));
         obj->size = j;
         obj_struct2->size = j;
         wire_struct_varray[0] = j;
@@ -1796,6 +1826,7 @@ static void test_struct_varray(void)
         }
         for (i = 0; i < 3; i++) {
             STRUCT_EQUAL((&obj->b[i]), (&obj_struct2->b[i]));
+            STRUCT_EQUAL((&obj->c[i]), (&obj_struct2->c[i]));
         }
     }
 }
-- 
1.9.0




reply via email to

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