From patchwork Mon Apr 21 14:41:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 341167 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 A16DB1400DF for ; Tue, 22 Apr 2014 13:23:20 +1000 (EST) Received: from localhost ([::1]:49839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcGJM-0006va-2q for incoming@patchwork.ozlabs.org; Mon, 21 Apr 2014 11:39:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcGBM-0005Oo-QO for qemu-devel@nongnu.org; Mon, 21 Apr 2014 11:31:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WcGBF-0000Q6-DC for qemu-devel@nongnu.org; Mon, 21 Apr 2014 11:30:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5126) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcGBF-0000Po-4A for qemu-devel@nongnu.org; Mon, 21 Apr 2014 11:30:49 -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 s3LFUm7f018962 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 21 Apr 2014 11:30:48 -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 s3LEfi7u019220; Mon, 21 Apr 2014 10:44:14 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 21 Apr 2014 16:41:30 +0200 Message-Id: <1398091304-10677-111-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 110/124] vmstate: Test for VMSTATE_VARRAY_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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index 1fa2899..8a6ca48 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -1211,6 +1211,8 @@ static void test_pointer_simple(void) typedef struct TestVarray { uint8_t *u8_1p; uint8_t *u8_2p; + int32_t size; + uint32_t *u32_1p; } TestVArray; static const VMStateDescription vmstate_varray_simple = { @@ -1221,12 +1223,19 @@ static const VMStateDescription vmstate_varray_simple = { .fields = (VMStateField[]) { VMSTATE_VARRAY(u8_1p, TestVArray, VMSTATE_ARRAY_SIZE, NULL, vmstate_info_uint8, uint8_t), + VMSTATE_INT32(size, TestVArray), + VMSTATE_VARRAY_INT32(u32_1p, TestVArray, size, + vmstate_info_uint32, uint32_t), VMSTATE_END_OF_LIST() } }; uint8_t wire_varray_simple[] = { /* u8_1p */ 0x01, 0x02, 0x03, 0x04, 0x05, + /* size */ 0x00, 0x00, 0x00, 0x05, + /* u32_1p */ 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16, + 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18, + 0x00, 0x00, 0x00, 0x19, QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */ }; @@ -1236,9 +1245,11 @@ static void obj_varray_copy(void *arg1, void *arg2) TestVArray *source = arg2; int i; + target->size = source->size; for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) { target->u8_1p[i] = source->u8_1p[i]; target->u8_2p[i] = source->u8_2p[i]; + target->u32_1p[i] = source->u32_1p[i]; } } @@ -1247,6 +1258,8 @@ static TestVArray *create_varray(void) TestVArray *obj = g_malloc0(sizeof(*obj)); obj->u8_1p = g_malloc0(VMSTATE_ARRAY_SIZE); obj->u8_2p = g_malloc0(VMSTATE_ARRAY_SIZE); + obj->size = VMSTATE_ARRAY_SIZE; + obj->u32_1p = g_malloc0(VMSTATE_ARRAY_SIZE * sizeof(uint32_t)); return obj; } @@ -1259,6 +1272,7 @@ static TestVArray *create_varray_init(void) for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) { obj->u8_1p[i] = i + 1; obj->u8_2p[i] = i + 11; + obj->u32_1p[i] = i + 21; } return obj; } @@ -1287,6 +1301,7 @@ static void test_varray_simple(void) for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) { ELEM_EQUAL(u8_1p, i); ELEM_NOT_EQUAL(u8_2p, i); + ELEM_EQUAL(u32_1p, i); } } static const VMStateDescription vmstate_varray_test = {