qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 092/124] vmstate: Test for VMSTATE_BUFFER_START_MIDD


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 092/124] vmstate: Test for VMSTATE_BUFFER_START_MIDDLE
Date: Mon, 21 Apr 2014 16:41:12 +0200

Signed-off-by: Juan Quintela <address@hidden>
---
 tests/test-vmstate.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index ddfa017..8b114fa 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -868,11 +868,13 @@ static void test_array_sub(void)
 typedef struct TestBuffer {
     uint8_t  buffer[6];
     uint8_t  partial[13];
+    uint8_t  middle[13];
 } TestBuffer;

 TestBuffer obj_buffer = {
     .buffer = "hello",
     .partial = "This is Juan",
+    .middle = "hello world!"
 };

 static const VMStateDescription vmstate_buffer_simple = {
@@ -883,6 +885,7 @@ static const VMStateDescription vmstate_buffer_simple = {
     .fields = (VMStateField[]) {
         VMSTATE_BUFFER(buffer, TestBuffer),
         VMSTATE_PARTIAL_BUFFER(partial, TestBuffer, 4),
+        VMSTATE_BUFFER_START_MIDDLE(middle, TestBuffer, 6),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -890,6 +893,7 @@ static const VMStateDescription vmstate_buffer_simple = {
 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,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -900,6 +904,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);
 }

 static void test_buffer_simple(void)
@@ -919,6 +924,8 @@ static void test_buffer_simple(void)
     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));
+    FAILURE(memcmp(obj.middle, obj_buffer.middle, 6));
+    SUCCESS(memcmp(obj.middle+6, obj_buffer.middle+6, sizeof(obj.middle)-6));
 }

 typedef struct TestVersioned {
-- 
1.9.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]