qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 90/97] vmstate: Test for VMSTATE_BUFFER_UNSAFE


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 90/97] vmstate: Test for VMSTATE_BUFFER_UNSAFE
Date: Mon, 7 Apr 2014 05:21:48 +0200

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

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index afcfbde..92e6bcc 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -956,12 +956,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 = {
@@ -973,6 +975,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()
     }
 };
@@ -981,6 +984,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 */
 };

@@ -1030,6 +1036,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 = {
-- 
1.9.0




reply via email to

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