Signed-off-by: Juan Quintela <quint...@redhat.com> --- tests/test-vmstate.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index a8a1dfe..f7fd3e2 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -535,11 +535,13 @@ static void test_simple_bitmap(void) typedef struct TestArray { int32_t size; + int32_t size2; 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]; uint16_t u16_1[VMSTATE_ARRAY_SIZE]; + uint16_t u16_2[VMSTATE_ARRAY_SIZE]; uint32_t u32_1[VMSTATE_ARRAY_SIZE]; uint32_t u32_2[VMSTATE_ARRAY_SIZE]; uint64_t u64_1[VMSTATE_ARRAY_SIZE]; @@ -556,11 +558,13 @@ typedef struct TestArray { TestArray obj_array = { .size = VMSTATE_ARRAY_SIZE, + .size2 = VMSTATE_ARRAY_SIZE - 1, .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}, .u16_1 = {11, 12, 13, 14, 15}, + .u16_2 = {11, 12, 13, 14, 15}, .u32_1 = {21, 22, 23, 24, 25}, .u32_2 = {25, 24, 23, 22, 21}, .u64_1 = {31, 32, 33, 34, 35}, @@ -604,6 +608,9 @@ static const VMStateDescription vmstate_array_primitive = { VMSTATE_2D_SIZE), VMSTATE_UINT32_2DARRAY(u32_1d, TestArray, VMSTATE_2D_SIZE, VMSTATE_2D_SIZE), + VMSTATE_INT32_EQUAL(size2, TestArray), + VMSTATE_ARRAY_INT32_UNSAFE(u16_2, TestArray, size2, + vmstate_info_uint16, uint16_t), VMSTATE_END_OF_LIST() } }; @@ -650,6 +657,8 @@ uint8_t wire_array_primitive[] = { 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x63, + /* size2 */ 0x00, 0x00, 0x00, 0x04, + /* u16_2 */ 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x0e, QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */ }; @@ -660,6 +669,7 @@ static void obj_array_copy(void *arg1, void *arg2) int i, j; target->size = source->size; + target->size2 = source->size2; for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) { target->b_1[i] = source->b_1[i]; @@ -667,6 +677,7 @@ static void obj_array_copy(void *arg1, void *arg2) target->u8_1[i] = source->u8_1[i]; target->u8_2[i] = source->u8_2[i]; target->u16_1[i] = source->u16_1[i]; + target->u16_2[i] = source->u16_2[i]; target->u32_1[i] = source->u32_1[i]; target->u32_2[i] = source->u32_2[i]; target->u64_1[i] = source->u64_1[i]; @@ -694,6 +705,7 @@ static void test_array_primitive(void) memset(&obj, 0, sizeof(obj)); obj.size = VMSTATE_ARRAY_SIZE; + obj.size2 = VMSTATE_ARRAY_SIZE - 1; save_vmstate(&vmstate_array_primitive, &obj_array); @@ -731,6 +743,12 @@ static void test_array_primitive(void) ELEM_EQUAL_2D(u32_1d, i, j); } } + + FIELD_EQUAL(size2); + for (i = 0; i < VMSTATE_ARRAY_SIZE-1; i++) { + ELEM_EQUAL(u16_2, i); + } + ELEM_NOT_EQUAL(u16_2, VMSTATE_ARRAY_SIZE-1); } static const VMStateDescription vmstate_array_test = { @@ -782,6 +800,7 @@ static void test_array_test(void) memset(&obj, 0, sizeof(obj)); obj.size = VMSTATE_ARRAY_SIZE; + obj.size2 = VMSTATE_ARRAY_SIZE - 1; save_vmstate(&vmstate_array_test, &obj_array); -- 1.9.0