Signed-off-by: Juan Quintela <quint...@redhat.com> --- tests/test-vmstate.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index cea5984..ddfa017 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -867,10 +867,12 @@ static void test_array_sub(void) typedef struct TestBuffer { uint8_t buffer[6]; + uint8_t partial[13]; } TestBuffer; TestBuffer obj_buffer = { .buffer = "hello", + .partial = "This is Juan", }; static const VMStateDescription vmstate_buffer_simple = { @@ -880,12 +882,14 @@ static const VMStateDescription vmstate_buffer_simple = { .minimum_version_id_old = 1, .fields = (VMStateField[]) { VMSTATE_BUFFER(buffer, TestBuffer), + VMSTATE_PARTIAL_BUFFER(partial, TestBuffer, 4), VMSTATE_END_OF_LIST() } }; uint8_t wire_buffer_simple[] = { /* buffer */ 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, + /* partial */ 0x54, 0x68, 0x69, 0x73, QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */ }; @@ -895,6 +899,7 @@ static void obj_buffer_copy(void *arg1, void *arg2) TestBuffer *source = arg2; memcpy(target->buffer, source->buffer, 6); + memcpy(target->partial, source->partial, 13); } static void test_buffer_simple(void) @@ -912,6 +917,8 @@ static void test_buffer_simple(void) sizeof(wire_buffer_simple))); SUCCESS(memcmp(obj.buffer, obj_buffer.buffer, sizeof(obj.buffer))); + SUCCESS(memcmp(obj.partial, obj_buffer.partial, 4)); + FAILURE(memcmp(obj.partial+4, obj_buffer.partial+4, sizeof(obj.partial)-4)); } typedef struct TestVersioned { -- 1.9.0