From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX0AL-0008Ua-FV for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:24:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WX0AF-0000Gr-7x for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:24:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19975) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX0AE-0000Ge-V8 for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:24:03 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s373O2S7025992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 6 Apr 2014 23:24:02 -0400 From: Juan Quintela Date: Mon, 7 Apr 2014 05:21:48 +0200 Message-Id: <1396840915-10384-91-git-send-email-quintela@redhat.com> In-Reply-To: <1396840915-10384-1-git-send-email-quintela@redhat.com> References: <1396840915-10384-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 90/97] vmstate: Test for VMSTATE_BUFFER_UNSAFE List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Juan Quintela --- 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