Signed-off-by: Juan Quintela <quint...@redhat.com> --- tests/test-vmstate.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index 1fa2899..8a6ca48 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -1211,6 +1211,8 @@ static void test_pointer_simple(void) typedef struct TestVarray { uint8_t *u8_1p; uint8_t *u8_2p; + int32_t size; + uint32_t *u32_1p; } TestVArray; static const VMStateDescription vmstate_varray_simple = { @@ -1221,12 +1223,19 @@ static const VMStateDescription vmstate_varray_simple = { .fields = (VMStateField[]) { VMSTATE_VARRAY(u8_1p, TestVArray, VMSTATE_ARRAY_SIZE, NULL, vmstate_info_uint8, uint8_t), + VMSTATE_INT32(size, TestVArray), + VMSTATE_VARRAY_INT32(u32_1p, TestVArray, size, + vmstate_info_uint32, uint32_t), VMSTATE_END_OF_LIST() } }; uint8_t wire_varray_simple[] = { /* u8_1p */ 0x01, 0x02, 0x03, 0x04, 0x05, + /* size */ 0x00, 0x00, 0x00, 0x05, + /* u32_1p */ 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16, + 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18, + 0x00, 0x00, 0x00, 0x19, QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */ }; @@ -1236,9 +1245,11 @@ static void obj_varray_copy(void *arg1, void *arg2) TestVArray *source = arg2; int i; + target->size = source->size; 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]; } } @@ -1247,6 +1258,8 @@ static TestVArray *create_varray(void) TestVArray *obj = g_malloc0(sizeof(*obj)); obj->u8_1p = g_malloc0(VMSTATE_ARRAY_SIZE); obj->u8_2p = g_malloc0(VMSTATE_ARRAY_SIZE); + obj->size = VMSTATE_ARRAY_SIZE; + obj->u32_1p = g_malloc0(VMSTATE_ARRAY_SIZE * sizeof(uint32_t)); return obj; } @@ -1259,6 +1272,7 @@ static TestVArray *create_varray_init(void) for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) { obj->u8_1p[i] = i + 1; obj->u8_2p[i] = i + 11; + obj->u32_1p[i] = i + 21; } return obj; } @@ -1287,6 +1301,7 @@ static void test_varray_simple(void) for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) { ELEM_EQUAL(u8_1p, i); ELEM_NOT_EQUAL(u8_2p, i); + ELEM_EQUAL(u32_1p, i); } } static const VMStateDescription vmstate_varray_test = { -- 1.9.0