qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 112/124] vmstate: Test for VMSTATE_VARRAY_INT32{_TES


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 112/124] vmstate: Test for VMSTATE_VARRAY_INT32{_TEST}
Date: Mon, 21 Apr 2014 16:41:32 +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 edceaee..7e69b14 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -1213,6 +1213,9 @@ typedef struct TestVarray {
     uint8_t  *u8_2p;
     int32_t size;
     uint32_t *u32_1p;
+    uint32_t size3;
+    int32_t *i32_1p;
+    int32_t *i32_2p;
     uint16_t size2;
     uint16_t u16_1[0];
 } TestVArray;
@@ -1228,6 +1231,9 @@ static const VMStateDescription vmstate_varray_simple = {
         VMSTATE_INT32(size, TestVArray),
         VMSTATE_VARRAY_INT32(u32_1p, TestVArray, size,
                              vmstate_info_uint32, uint32_t),
+        VMSTATE_UINT32_EQUAL(size3, TestVArray),
+        VMSTATE_VARRAY_UINT32(i32_1p, TestVArray, size3,
+                              vmstate_info_int32, int32_t),
         VMSTATE_UINT16_EQUAL(size2, TestVArray),
         VMSTATE_VARRAY_UINT16_UNSAFE(u16_1, TestVArray, size2,
                                      vmstate_info_uint16, uint16_t),
@@ -1241,6 +1247,10 @@ uint8_t wire_varray_simple[] = {
     /* u32_1p */        0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16,
                         0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18,
                         0x00, 0x00, 0x00, 0x19,
+    /* size3 */         0x00, 0x00, 0x00, 0x05,
+    /* i32_1 */         0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x34,
+                        0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x36,
+                        0x00, 0x00, 0x00, 0x37,
     /* size2 */         0x00, 0x05,
     /* u16_1 */         0x00, 0x0b, 0x00, 0x0c, 0x00, 0x0d,
                         0x00, 0x0e, 0x00, 0x0f,
@@ -1255,11 +1265,14 @@ static void obj_varray_copy(void *arg1, void *arg2)

     target->size = source->size;
     target->size2 = source->size2;
+    target->size3 = source->size3;
     for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
         target->u8_1p[i] = source->u8_1p[i];
         target->u8_2p[i] = source->u8_2p[i];
         target->u32_1p[i] = source->u32_1p[i];
         target->u16_1[i] = source->u16_1[i];
+        target->i32_1p[i] = source->i32_1p[i];
+        target->i32_2p[i] = source->i32_2p[i];
     }
 }

@@ -1269,9 +1282,12 @@ static TestVArray *create_varray(void)
                                 VMSTATE_ARRAY_SIZE * sizeof(uint16_t));
     obj->size = VMSTATE_ARRAY_SIZE;
     obj->size2 = VMSTATE_ARRAY_SIZE;
+    obj->size3 = VMSTATE_ARRAY_SIZE;
     obj->u8_1p = g_malloc0(VMSTATE_ARRAY_SIZE);
     obj->u8_2p = g_malloc0(VMSTATE_ARRAY_SIZE);
     obj->u32_1p = g_malloc0(VMSTATE_ARRAY_SIZE * sizeof(uint32_t));
+    obj->i32_1p = g_malloc0(VMSTATE_ARRAY_SIZE * sizeof(int32_t));
+    obj->i32_2p = g_malloc0(VMSTATE_ARRAY_SIZE * sizeof(int32_t));

     return obj;
 }
@@ -1286,6 +1302,8 @@ static TestVArray *create_varray_init(void)
         obj->u8_2p[i] = i + 11;
         obj->u32_1p[i] = i + 21;
         obj->u16_1[i] = i + 11;
+        obj->i32_1p[i] = i + 51;
+        obj->i32_2p[i] = 55 - i;
     }
     return obj;
 }
@@ -1316,6 +1334,8 @@ static void test_varray_simple(void)
         ELEM_NOT_EQUAL(u8_2p, i);
         ELEM_EQUAL(u32_1p, i);
         ELEM_EQUAL(u16_1, i);
+        ELEM_EQUAL(i32_1p, i);
+        ELEM_NOT_EQUAL(i32_2p, i);
     }
 }
 static const VMStateDescription vmstate_varray_test = {
@@ -1328,12 +1348,21 @@ static const VMStateDescription vmstate_varray_test = {
                        test_true, vmstate_info_uint8, uint8_t),
         VMSTATE_VARRAY(u8_2p, TestVArray, VMSTATE_ARRAY_SIZE,
                        test_false, vmstate_info_uint8, uint8_t),
+        VMSTATE_UINT32_EQUAL(size3, TestVArray),
+        VMSTATE_VARRAY_UINT32_TEST(i32_1p, TestVArray, size3, test_true,
+                                   vmstate_info_int32, int32_t),
+        VMSTATE_VARRAY_UINT32_TEST(i32_2p, TestVArray, size3, test_false,
+                                   vmstate_info_int32, int32_t),
         VMSTATE_END_OF_LIST()
     }
 };

 uint8_t wire_varray_test[] = {
     /* u8_1p */         0x01, 0x02, 0x03, 0x04, 0x05,
+    /* size3 */         0x00, 0x00, 0x00, 0x05,
+    /* i32_1 */         0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x34,
+                        0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x36,
+                        0x00, 0x00, 0x00, 0x37,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -1357,6 +1386,8 @@ static void test_varray_test(void)
     for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
         ELEM_EQUAL(u8_1p, i);
         ELEM_NOT_EQUAL(u8_2p, i);
+        ELEM_EQUAL(i32_1p, i);
+        ELEM_NOT_EQUAL(i32_2p, i);
     }
 }
 #undef ELEM_EQUAL
-- 
1.9.0




reply via email to

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