From patchwork Mon Apr 21 14:41:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 341086 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B8FA01400ED for ; Tue, 22 Apr 2014 13:18:46 +1000 (EST) Received: from localhost ([::1]:49701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcG9A-00024z-P6 for incoming@patchwork.ozlabs.org; Mon, 21 Apr 2014 11:28:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcFSZ-00074l-Qu for qemu-devel@nongnu.org; Mon, 21 Apr 2014 10:44:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WcFST-0004aS-M9 for qemu-devel@nongnu.org; Mon, 21 Apr 2014 10:44:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35445) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcFST-0004aJ-EK for qemu-devel@nongnu.org; Mon, 21 Apr 2014 10:44:33 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3LEiVs2002813 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 21 Apr 2014 10:44:32 -0400 Received: from trasno.mitica (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3LEfi88019220; Mon, 21 Apr 2014 10:44:30 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 21 Apr 2014 16:41:42 +0200 Message-Id: <1398091304-10677-123-git-send-email-quintela@redhat.com> In-Reply-To: <1398091304-10677-1-git-send-email-quintela@redhat.com> References: <1398091304-10677-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 122/124] vmstate: Test for VMSTATE_STRUCT_VARRAY_POINTER_INT32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Juan Quintela --- tests/test-vmstate.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index c937661..fa69209 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -1660,6 +1660,7 @@ typedef struct TestStruct2 { uint16_t size4; SubStruct *p_1; SubStruct *p_2; + SubStruct *p_3; } TestStruct2; /* @@ -1686,6 +1687,8 @@ static const VMStateDescription vmstate_struct_varray = { vmstate_sub_struct, SubStruct), VMSTATE_STRUCT_VARRAY_POINTER_UINT32(p_2, TestStruct2, size2, vmstate_sub_struct, SubStruct), + VMSTATE_STRUCT_VARRAY_POINTER_INT32(p_3, TestStruct2, size3, + vmstate_sub_struct, SubStruct), VMSTATE_STRUCT_VARRAY_UINT8(a, TestStruct2, size, vmstate_sub_struct, SubStruct), VMSTATE_END_OF_LIST() @@ -1759,6 +1762,21 @@ uint8_t wire_struct_varray[] = { /* i64 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, /* buffer */ 0x62, 0x79, 0x65, 0x35, 0x20, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0x00, + /* p_3[0] */ + /* i32 */ 0x00, 0x00, 0x00, 0x79, + /* i64 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, + /* buffer */ 0x62, 0x79, 0x65, 0x36, 0x20, 0x20, 0x77, 0x6f, + 0x72, 0x6c, 0x64, 0x21, 0x00, + /* p_3[1] */ + /* i32 */ 0x00, 0x00, 0x00, 0x7a, + /* i64 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, + /* buffer */ 0x62, 0x79, 0x65, 0x37, 0x20, 0x20, 0x77, 0x6f, + 0x72, 0x6c, 0x64, 0x21, 0x00, + /* p_3[2] */ + /* i32 */ 0x00, 0x00, 0x00, 0x7b, + /* i64 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, + /* buffer */ 0x62, 0x79, 0x65, 0x38, 0x20, 0x20, 0x77, 0x6f, + 0x72, 0x6c, 0x64, 0x21, 0x00, /* a[0] */ /* i32 */ 0x00, 0x00, 0x00, 0x15, /* i64 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, @@ -1803,6 +1821,9 @@ static void obj_struct2_copy(void *arg1, void *arg2) target->p_2[i].i32 = source->p_2[i].i32; target->p_2[i].i64 = source->p_2[i].i64; memcpy(target->p_2[i].buffer, source->p_2[i].buffer, 13); + target->p_3[i].i32 = source->p_3[i].i32; + target->p_3[i].i64 = source->p_3[i].i64; + memcpy(target->p_3[i].buffer, source->p_3[i].buffer, 13); } } @@ -1815,6 +1836,7 @@ static TestStruct2 *create_struct2(void) obj->size4 = 3; obj->p_1 = g_malloc0(sizeof(SubStruct) * 3); obj->p_2 = g_malloc0(sizeof(SubStruct) * 3); + obj->p_3 = g_malloc0(sizeof(SubStruct) * 3); return obj; } @@ -1840,6 +1862,9 @@ static TestStruct2 *create_struct2_init(void) obj->p_2[i].i32 = i + 101; obj->p_2[i].i64 = i + 111; snprintf((char *)obj->p_2[i].buffer, 13, "bye%d world!", i + 3); + obj->p_3[i].i32 = i + 121; + obj->p_3[i].i64 = i + 131; + snprintf((char *)obj->p_3[i].buffer, 13, "bye%d world!", i + 6); } return obj; @@ -1867,6 +1892,7 @@ static void test_struct_varray(void) memset(obj->c, 0, sizeof(obj->c)); memset(obj->p_1, 0, sizeof(*obj->p_1) * 3); memset(obj->p_2, 0, sizeof(*obj->p_2) * 3); + memset(obj->p_2, 0, sizeof(*obj->p_3) * 3); obj->size = j; obj_struct2->size = j; wire_struct_varray[0] = j; @@ -1886,6 +1912,7 @@ static void test_struct_varray(void) STRUCT_EQUAL((&obj->c[i]), (&obj_struct2->c[i])); STRUCT_EQUAL((&obj->p_1[i]), (&obj_struct2->p_1[i])); STRUCT_EQUAL((&obj->p_2[i]), (&obj_struct2->p_2[i])); + STRUCT_EQUAL((&obj->p_3[i]), (&obj_struct2->p_3[i])); } } }