From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX097-0006KF-6v for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:22:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WX091-0008KC-1Y for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:22:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23139) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX090-0008Jv-QB for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:22:46 -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 s373MkFu005405 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 6 Apr 2014 23:22:46 -0400 From: Juan Quintela Date: Mon, 7 Apr 2014 05:20:52 +0200 Message-Id: <1396840915-10384-35-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 34/97] vmstate: Test for VMSTATE_UINT32_ARRAY{_TEST} List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Once there, change only user of VMSTATE_UInT32_ARRAY_V. Signed-off-by: Juan Quintela --- hw/misc/arm_sysctl.c | 3 ++- include/migration/vmstate.h | 15 ++++++--------- tests/test-vmstate.c | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/hw/misc/arm_sysctl.c b/hw/misc/arm_sysctl.c index 807d48e..0f61241 100644 --- a/hw/misc/arm_sysctl.c +++ b/hw/misc/arm_sysctl.c @@ -65,7 +65,8 @@ static const VMStateDescription vmstate_arm_sysctl = { VMSTATE_UINT32_TEST(sys_cfgctrl, arm_sysctl_state, vmstate_2_plus), VMSTATE_UINT32_TEST(sys_cfgstat, arm_sysctl_state, vmstate_2_plus), VMSTATE_UINT32_TEST(sys_clcd, arm_sysctl_state, vmstate_3_plus), - VMSTATE_UINT32_ARRAY_V(mb_clock, arm_sysctl_state, 6, 4), + VMSTATE_UINT32_ARRAY_TEST(mb_clock, arm_sysctl_state, 6, + vmstate_4_plus), VMSTATE_VARRAY_UINT32(db_clock, arm_sysctl_state, db_num_clocks, 4, vmstate_info_uint32, uint32_t), VMSTATE_END_OF_LIST() diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 2579c4f..703f07b 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -612,6 +612,12 @@ extern const VMStateInfo vmstate_info_bitmap; #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \ VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_uint16, uint16_t) +#define VMSTATE_UINT32_ARRAY_TEST(_f, _s, _n, _t) \ + VMSTATE_ARRAY_TEST(_f, _s, _n, _t, vmstate_info_uint32, uint32_t) + +#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ + VMSTATE_UINT32_ARRAY_TEST(_f, _s, _n, NULL) + #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v) \ VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t) @@ -627,15 +633,9 @@ extern const VMStateInfo vmstate_info_bitmap; #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2) \ VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, 0) -#define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t) - #define VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, _v) \ VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint32, uint32_t) -#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ - VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) - #define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2) \ VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, 0) @@ -660,9 +660,6 @@ extern const VMStateInfo vmstate_info_bitmap; #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \ VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t) -#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ - VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) - #define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t) diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index ae0421e..76ad401 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -543,6 +543,8 @@ typedef struct TestArray { uint8_t u8_1[VMSTATE_ARRAY_SIZE]; uint8_t u8_2[VMSTATE_ARRAY_SIZE]; uint16_t u16_1[VMSTATE_ARRAY_SIZE]; + uint32_t u32_1[VMSTATE_ARRAY_SIZE]; + uint32_t u32_2[VMSTATE_ARRAY_SIZE]; } TestArray; TestArray obj_array = { @@ -552,6 +554,8 @@ TestArray obj_array = { .u8_1 = { 1, 2, 3, 4, 5}, .u8_2 = { 5, 4, 3, 2, 1}, .u16_1 = {11, 12, 13, 14, 15}, + .u32_1 = {21, 22, 23, 24, 25}, + .u32_2 = {25, 24, 23, 22, 21}, }; static const VMStateDescription vmstate_array_primitive = { @@ -564,6 +568,7 @@ static const VMStateDescription vmstate_array_primitive = { VMSTATE_BOOL_ARRAY(b_1, TestArray, VMSTATE_ARRAY_SIZE), VMSTATE_UINT8_ARRAY(u8_1, TestArray, VMSTATE_ARRAY_SIZE), VMSTATE_UINT16_ARRAY(u16_1, TestArray, VMSTATE_ARRAY_SIZE), + VMSTATE_UINT32_ARRAY(u32_1, TestArray, VMSTATE_ARRAY_SIZE), VMSTATE_END_OF_LIST() } }; @@ -573,6 +578,9 @@ uint8_t wire_array_primitive[] = { /* b_1 */ 0x00, 0x01, 0x00, 0x01, 0x00, /* u8_1 */ 0x01, 0x02, 0x03, 0x04, 0x05, /* u16_1 */ 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x0e, 0x00, 0x0f, + /* u32_1 */ 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 */ }; @@ -630,6 +638,7 @@ static void test_array_primitive(void) ELEM_ASSERT(u8_1, i); ELEM_NOT_ASSERT(u8_2, i); ELEM_ASSERT(u16_1, i); + ELEM_ASSERT(u32_1, i); } /* We save the file again. We want the EOF this time */ @@ -656,6 +665,10 @@ static const VMStateDescription vmstate_array_test = { VMSTATE_INT32(size, TestArray), VMSTATE_BOOL_ARRAY_TEST(b_1, TestArray, VMSTATE_ARRAY_SIZE, test_true), VMSTATE_BOOL_ARRAY_TEST(b_2, TestArray, VMSTATE_ARRAY_SIZE, test_false), + VMSTATE_UINT32_ARRAY_TEST(u32_1, TestArray, VMSTATE_ARRAY_SIZE, + test_true), + VMSTATE_UINT32_ARRAY_TEST(u32_2, TestArray, VMSTATE_ARRAY_SIZE, + test_false), VMSTATE_END_OF_LIST() } }; @@ -663,6 +676,9 @@ static const VMStateDescription vmstate_array_test = { uint8_t wire_array_test[] = { /* size */ 0x00, 0x00, 0x00, 0x05, /* b_1 */ 0x00, 0x01, 0x00, 0x01, 0x00, + /* u32_1 */ 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 */ }; @@ -712,6 +728,8 @@ static void test_array_test(void) FIELD_ASSERT(size); for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) { ELEM_ASSERT(b_1, i); + ELEM_ASSERT(u32_1, i); + ELEM_NOT_ASSERT(u32_2, i); } } #undef FIELD_ASSERT -- 1.9.0