Signed-off-by: Juan Quintela <[email protected]>
---
tests/test-vmstate.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 9f7256c..a8a1dfe 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -865,12 +865,15 @@ static void test_array_sub(void)
#undef ELEM_EQUAL_2D
#undef ELEM_NOT_EQUAL
+uint32_t test_scratch3[5] = {41, 42, 43, 44, 45};
+
typedef struct TestBuffer {
uint8_t buffer[6];
uint8_t partial[13];
uint8_t middle[13];
uint32_t scratch[5];
uint32_t scratch2[5];
+ uint32_t *scratch3;
} TestBuffer;
TestBuffer obj_buffer = {
@@ -879,6 +882,7 @@ TestBuffer obj_buffer = {
.middle = "hello world!",
.scratch = {21, 22, 23, 24, 25},
.scratch2 = {31, 32, 33, 34, 35},
+ .scratch3 = test_scratch3,
};
static const VMStateDescription vmstate_buffer_simple = {
@@ -891,6 +895,8 @@ static const VMStateDescription vmstate_buffer_simple = {
VMSTATE_PARTIAL_BUFFER(partial, TestBuffer, 4),
VMSTATE_BUFFER_START_MIDDLE(middle, TestBuffer, 6),
VMSTATE_BUFFER_UNSAFE(scratch, TestBuffer, 5 * sizeof(uint32_t)),
+ VMSTATE_BUFFER_POINTER_UNSAFE(scratch3,
+ TestBuffer, 5 * sizeof(uint32_t)),
VMSTATE_END_OF_LIST()
}
};
@@ -902,6 +908,9 @@ uint8_t wire_buffer_simple[] = {
/* scratch */ 0x15, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
0x17, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
0x19, 0x00, 0x00, 0x00,
+ /* scratch3 */ 0x29, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00,
+ 0x2b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
+ 0x2d, 0x00, 0x00, 0x00,
QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
};
@@ -917,14 +926,19 @@ static void obj_buffer_copy(void *arg1, void *arg2)
for (i = 0; i < 5; i++) {
target->scratch[0] = source->scratch[0];
target->scratch2[0] = source->scratch2[0];
+ target->scratch3[0] = source->scratch3[0];
}
}
static void test_buffer_simple(void)
{
TestBuffer obj, obj_clone;
+ uint32_t local_scratch[5];
+ uint32_t local_scratch_clone[5];
memset(&obj, 0, sizeof(obj));
+ obj.scratch3 = local_scratch;
+ obj_clone.scratch3 = local_scratch_clone;
save_vmstate(&vmstate_buffer_simple, &obj_buffer);
@@ -940,6 +954,7 @@ static void test_buffer_simple(void)
FAILURE(memcmp(obj.middle, obj_buffer.middle, 6));
SUCCESS(memcmp(obj.middle+6, obj_buffer.middle+6, sizeof(obj.middle)-6));
SUCCESS(memcmp(obj.scratch, obj_buffer.scratch, sizeof(obj.scratch)));
+ SUCCESS(memcmp(obj.scratch3, obj_buffer.scratch3, 5 * sizeof(uint32_t)));
}
/* just sent the fields in the reverse order that are stored */
@@ -998,8 +1013,12 @@ uint8_t wire_buffer_test[] = {
static void test_buffer_test(void)
{
TestBuffer obj, obj_clone;
+ uint32_t local_scratch[5];
+ uint32_t local_scratch_clone[5];
memset(&obj, 0, sizeof(obj));
+ obj.scratch3 = local_scratch;
+ obj_clone.scratch3 = local_scratch_clone;
save_vmstate(&vmstate_buffer_test, &obj_buffer);
--
1.9.0