@@ -1142,6 +1142,7 @@ static void test_vbuffer_simple(void)
typedef struct TestPointer {
uint8_t *u8_1p;
uint8_t *u8_2p;
+ uint32_t *u32_p[VMSTATE_ARRAY_SIZE];
} TestPointer;
static const VMStateDescription vmstate_pointer_simple = {
@@ -1153,6 +1154,8 @@ static const VMStateDescription vmstate_pointer_simple = {
VMSTATE_POINTER(u8_1p, TestPointer, NULL, vmstate_info_uint8, uint8_t),
VMSTATE_POINTER_UNSAFE(u8_2p, TestPointer,
vmstate_info_uint16, uint16_t),
+ VMSTATE_ARRAY_OF_POINTER(u32_p, TestPointer, VMSTATE_ARRAY_SIZE,
+ vmstate_info_uint32, uint32_t*),
VMSTATE_END_OF_LIST()
}
};
@@ -1160,6 +1163,11 @@ static const VMStateDescription vmstate_pointer_simple = {
uint8_t wire_pointer_simple[] = {
/* u8_1p */ 0x11,
/* u8_2p */ 0x02, 0x2b,
+ /* u32_p */ 0x00, 0x00, 0x00, 0x21,
+ 0x00, 0x00, 0x00, 0x2b,
+ 0x00, 0x00, 0x00, 0x35,
+ 0x00, 0x00, 0x00, 0x3f,
+ 0x00, 0x00, 0x00, 0x49,
QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
};
@@ -1167,23 +1175,32 @@ static void obj_pointer_copy(void *arg1, void *arg2)
{
TestPointer *target = arg1;
TestPointer *source = arg2;
+ int i;
*target->u8_1p = *source->u8_1p;
*((uint16_t *)target->u8_2p) = *((uint16_t *)source->u8_2p);
+ for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
+ *target->u32_p[i] = *source->u32_p[i];
+ }
}
static TestPointer *create_pointer(void)
{
TestPointer *obj = g_malloc0(sizeof(*obj));
+ int i;
+
obj->u8_1p = g_malloc0(sizeof(*obj->u8_1p));
obj->u8_2p = g_malloc0(sizeof(uint16_t));
-
+ for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
+ obj->u32_p[i] = g_malloc0(sizeof(uint32_t));
+ }
return obj;
}
static void test_pointer_simple(void)
{
TestPointer *obj, *obj_clone, *obj_pointer;
+ int i;
obj_pointer = create_pointer();
obj = create_pointer();
@@ -1194,6 +1211,10 @@ static void test_pointer_simple(void)
*obj->u8_1p = 22;
*((uint16_t *)obj->u8_2p) = 777;
+ for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
+ *obj_pointer->u32_p[i] = 10 * i + 33;
+ }
+
save_vmstate(&vmstate_pointer_simple, obj_pointer);
compare_vmstate(wire_pointer_simple, sizeof(wire_pointer_simple));
@@ -1205,6 +1226,10 @@ static void test_pointer_simple(void)
g_assert_cmpint(*obj->u8_1p, ==, *obj_pointer->u8_1p);
g_assert_cmpint(*((uint16_t *)obj->u8_2p), ==,
*((uint16_t *)obj_pointer->u8_2p));
+
+ for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
+ g_assert_cmpint(*obj->u32_p[i], ==, *obj_pointer->u32_p[i]);
+ }
}
#undef FIELD_EQUAL
Signed-off-by: Juan Quintela <quintela@redhat.com> --- tests/test-vmstate.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)