From patchwork Thu Jan 26 02:48:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 719960 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v85x80FZtz9tJD for ; Thu, 26 Jan 2017 13:49:48 +1100 (AEDT) Received: from localhost ([::1]:35814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWa89-000225-Jp for incoming@patchwork.ozlabs.org; Wed, 25 Jan 2017 21:49:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWa6u-0001Bp-Pm for qemu-devel@nongnu.org; Wed, 25 Jan 2017 21:48:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWa6t-00073Q-SO for qemu-devel@nongnu.org; Wed, 25 Jan 2017 21:48:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45152) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cWa6t-00073H-MI for qemu-devel@nongnu.org; Wed, 25 Jan 2017 21:48:27 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3BD8C0467F1; Thu, 26 Jan 2017 02:48:27 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-30.pek2.redhat.com [10.72.8.30]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0Q2mIv2002289; Wed, 25 Jan 2017 21:48:25 -0500 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 26 Jan 2017 10:48:15 +0800 Message-Id: <20170126024815.22841-3-famz@redhat.com> In-Reply-To: <20170126024815.22841-1-famz@redhat.com> References: <20170126024815.22841-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 26 Jan 2017 02:48:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/2] test-hbitmap: Add hbitmap_is_serializable() calls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Add calls to hbitmap_is_serializable() (asserting that it returns true) where necessary (i.e. before every series of (de-)serialization function invocations). Signed-off-by: Max Reitz Message-Id: <20161115225746.3590-3-mreitz@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Fam Zheng --- tests/test-hbitmap.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c index 9b7495c..23773d2 100644 --- a/tests/test-hbitmap.c +++ b/tests/test-hbitmap.c @@ -744,6 +744,8 @@ static void test_hbitmap_serialize_granularity(TestHBitmapData *data, int r; hbitmap_test_init(data, L3 * 2, 3); + g_assert(hbitmap_is_serializable(data->hb)); + r = hbitmap_serialization_granularity(data->hb); g_assert_cmpint(r, ==, 64 << 3); } @@ -768,6 +770,8 @@ static void hbitmap_test_serialize_range(TestHBitmapData *data, if (count) { hbitmap_set(data->hb, pos, count); } + + g_assert(hbitmap_is_serializable(data->hb)); hbitmap_serialize_part(data->hb, buf, 0, data->size); /* Serialized buffer is inherently LE, convert it back manually to test */ @@ -788,6 +792,8 @@ static void hbitmap_test_serialize_range(TestHBitmapData *data, memset(buf, 0, buf_size); hbitmap_serialize_part(data->hb, buf, 0, data->size); hbitmap_reset_all(data->hb); + + g_assert(hbitmap_is_serializable(data->hb)); hbitmap_deserialize_part(data->hb, buf, 0, data->size, true); for (i = 0; i < data->size; i++) { @@ -810,6 +816,7 @@ static void test_hbitmap_serialize_basic(TestHBitmapData *data, int num_positions = sizeof(positions) / sizeof(positions[0]); hbitmap_test_init(data, L3, 0); + g_assert(hbitmap_is_serializable(data->hb)); buf_size = hbitmap_serialization_size(data->hb, 0, data->size); buf = g_malloc0(buf_size); @@ -841,6 +848,8 @@ static void test_hbitmap_serialize_part(TestHBitmapData *data, hbitmap_set(data->hb, positions[i], 1); } + g_assert(hbitmap_is_serializable(data->hb)); + for (i = 0; i < data->size; i += buf_size) { unsigned long *el = (unsigned long *)buf; hbitmap_serialize_part(data->hb, buf, i, buf_size); @@ -879,6 +888,8 @@ static void test_hbitmap_serialize_zeroes(TestHBitmapData *data, hbitmap_set(data->hb, positions[i], L1); } + g_assert(hbitmap_is_serializable(data->hb)); + for (i = 0; i < num_positions; i++) { hbitmap_deserialize_zeroes(data->hb, positions[i], min_l1, true); hbitmap_iter_init(&iter, data->hb, 0);