@@ -869,12 +869,14 @@ typedef struct TestBuffer {
uint8_t buffer[6];
uint8_t partial[13];
uint8_t middle[13];
+ uint32_t scratch[5];
} TestBuffer;
TestBuffer obj_buffer = {
.buffer = "hello",
.partial = "This is Juan",
- .middle = "hello world!"
+ .middle = "hello world!",
+ .scratch = {21, 22, 23, 24, 25},
};
static const VMStateDescription vmstate_buffer_simple = {
@@ -886,6 +888,7 @@ static const VMStateDescription vmstate_buffer_simple = {
VMSTATE_BUFFER(buffer, TestBuffer),
VMSTATE_PARTIAL_BUFFER(partial, TestBuffer, 4),
VMSTATE_BUFFER_START_MIDDLE(middle, TestBuffer, 6),
+ VMSTATE_BUFFER_UNSAFE(scratch, TestBuffer, 5 * sizeof(uint32_t)),
VMSTATE_END_OF_LIST()
}
};
@@ -894,6 +897,9 @@ uint8_t wire_buffer_simple[] = {
/* buffer */ 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00,
/* partial */ 0x54, 0x68, 0x69, 0x73,
/* middle */ 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0x00,
+ /* scratch */ 0x15, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
+ 0x17, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+ 0x19, 0x00, 0x00, 0x00,
QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
};
@@ -905,6 +911,7 @@ static void obj_buffer_copy(void *arg1, void *arg2)
memcpy(target->buffer, source->buffer, 6);
memcpy(target->partial, source->partial, 13);
memcpy(target->middle, source->middle, 13);
+ memcpy(target->scratch, source->scratch, 5 * sizeof(uint32_t));
}
static void test_buffer_simple(void)
@@ -926,6 +933,7 @@ static void test_buffer_simple(void)
FAILURE(memcmp(obj.partial+4, obj_buffer.partial+4, sizeof(obj.partial)-4));
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)));
}
static const VMStateDescription vmstate_buffer_test = {
Signed-off-by: Juan Quintela <quintela@redhat.com> --- tests/test-vmstate.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)