[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 107/124] vmstate: Test for VMSTATE_BUFFER_POINTER_UN
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 107/124] vmstate: Test for VMSTATE_BUFFER_POINTER_UNSAFE |
Date: |
Mon, 21 Apr 2014 16:41:27 +0200 |
Signed-off-by: Juan Quintela <address@hidden>
---
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
- [Qemu-devel] [PATCH 098/124] vmstate: Test for VMSTATE_PARTIAL_VBUFFER, (continued)
- [Qemu-devel] [PATCH 098/124] vmstate: Test for VMSTATE_PARTIAL_VBUFFER, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 100/124] vmstate: Create VMS_VBUFFER_UINT32, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 101/124] vmstate: Rename VMS_VBUFFER to VMST_VBUFFER_INT32 for consintency, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 102/124] vmstate: Test for VMSTATE_VBUFFER_UINT32, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 104/124] vmstate: Test for VMSTATE_POINTER, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 105/124] vmstate: Test for VMSTATE_POINTER_UNSAFE, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 103/124] vmstate: VMSTATE_POINTER() used the wrong type to calculate the size, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 106/124] vmstate: Test for VMSTATE_BUFFER_UNSAFE_TEST, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 108/124] vmstate: Test for VMSTATE_ARRAY_INT32_UNSAFE, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 109/124] vmstate: Test for VMSTATE_VARRAY, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 107/124] vmstate: Test for VMSTATE_BUFFER_POINTER_UNSAFE,
Juan Quintela <=
- [Qemu-devel] [PATCH 111/124] vmstate: Test for VMSTATE_VARRAY_UINT16_UNSAFE, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 113/124] vmstate: Test for VMSTATE_STRUCT{_TEST}, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 112/124] vmstate: Test for VMSTATE_VARRAY_INT32{_TEST}, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 117/124] vmstate: Test for VMSTATE_STRUCT_VARRAY_UINT8, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 118/124] vmstate: Test for VMSTATE_STRUCT_VARRAY_UINT32, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 119/124] vmstate: Test for VMSTATE_STRUCT_VARRAY_INT32, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 120/124] vmstate: Test for VMSTATE_STRUCT_VARRAY_POINTER_UINT16, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 121/124] vmstate: Test for VMSTATE_STRUCT_ARRAY_POINTER_UINT32, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 122/124] vmstate: Test for VMSTATE_STRUCT_VARRAY_POINTER_INT32, Juan Quintela, 2014/04/21
- [Qemu-devel] [PATCH 123/124] vmstate: Test for VMSTATE_ARRAY_OF_POINTER_TO_STRUCT, Juan Quintela, 2014/04/21