Received: from eggs.gnu.org ([2001:4830:134:3::10]:33837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brp6J-0004aY-IS for qemu-devel@nongnu.org; Wed, 05 Oct 2016 12:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brp6H-0005fd-Kk for qemu-devel@nongnu.org; Wed, 05 Oct 2016 12:31:22 -0400 References: <1475621564-26623-1-git-send-email-jsnow@redhat.com> <1475621564-26623-10-git-send-email-jsnow@redhat.com> From: Max Reitz Message-ID: Date: Wed, 5 Oct 2016 18:31:11 +0200 MIME-Version: 1.0 In-Reply-To: <1475621564-26623-10-git-send-email-jsnow@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="JBb2lD3XOhDIEUhHU863uhtG0XWoaFfth" Subject: Re: [Qemu-devel] [PATCH v9 09/10] tests: Add test code for hbitmap serialization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow , qemu-block@nongnu.org Cc: vsementsov@virtuozzo.com, famz@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --JBb2lD3XOhDIEUhHU863uhtG0XWoaFfth From: Max Reitz To: John Snow , qemu-block@nongnu.org Cc: vsementsov@virtuozzo.com, famz@redhat.com, qemu-devel@nongnu.org Message-ID: Subject: Re: [PATCH v9 09/10] tests: Add test code for hbitmap serialization References: <1475621564-26623-1-git-send-email-jsnow@redhat.com> <1475621564-26623-10-git-send-email-jsnow@redhat.com> In-Reply-To: <1475621564-26623-10-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 05.10.2016 00:52, John Snow wrote: > From: Fam Zheng >=20 > Signed-off-by: Fam Zheng > [Fixed minor constant issue. --js] > Signed-off-by: John Snow >=20 > Signed-off-by: John Snow > --- > tests/test-hbitmap.c | 155 +++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 155 insertions(+) >=20 > diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c > index e3abde1..4fc5612 100644 > --- a/tests/test-hbitmap.c > +++ b/tests/test-hbitmap.c [...] > +static void test_hbitmap_serialize_zeroes(TestHBitmapData *data, > + const void *unused) > +{ > + int i; > + HBitmapIter iter; > + int64_t next; > + uint64_t positions[] =3D { 0, L1, L2, L3 - L1}; > + int num_positions =3D sizeof(positions) / sizeof(positions[0]); > + > + hbitmap_test_init(data, L3, 0); > + > + for (i =3D 0; i < num_positions; i++) { > + hbitmap_set(data->hb, positions[i], L1); > + } > + > + for (i =3D 0; i < num_positions; i++) { > + hbitmap_deserialize_zeroes(data->hb, positions[i], L1, true); This tries to deserialize L1 (=3D BITS_PER_LONG) bits; this is bad on 32 bit hosts, because the serialization granularity is (at least) 64 bits, and the hbitmap code really doesn't like start or end positions (and therefore also lengths) which aren't aligned to the granularity. (Therefore, make check fails with -m32.) Max > + hbitmap_iter_init(&iter, data->hb, 0); > + next =3D hbitmap_iter_next(&iter); > + if (i =3D=3D num_positions - 1) { > + g_assert_cmpint(next, =3D=3D, -1); > + } else { > + g_assert_cmpint(next, =3D=3D, positions[i + 1]); > + } > + } > +} > + > static void hbitmap_test_add(const char *testpath, > void (*test_func)(TestHBitmapData *= data, const void *user_data)) > { > @@ -799,6 +945,15 @@ int main(int argc, char **argv) > hbitmap_test_add("/hbitmap/meta/byte", test_hbitmap_meta_byte); > hbitmap_test_add("/hbitmap/meta/word", test_hbitmap_meta_word); > hbitmap_test_add("/hbitmap/meta/sector", test_hbitmap_meta_sector)= ; > + > + hbitmap_test_add("/hbitmap/serialize/granularity", > + test_hbitmap_serialize_granularity); > + hbitmap_test_add("/hbitmap/serialize/basic", > + test_hbitmap_serialize_basic); > + hbitmap_test_add("/hbitmap/serialize/part", > + test_hbitmap_serialize_part); > + hbitmap_test_add("/hbitmap/serialize/zeroes", > + test_hbitmap_serialize_zeroes); > g_test_run(); > =20 > return 0; >=20 --JBb2lD3XOhDIEUhHU863uhtG0XWoaFfth Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEvBAEBCAAZBQJX9SrPEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRD0B9sAYdXPQIru B/9D/L1TrJkoEUZimCnyb3mBvPRQswbV5GZb8QCkANfTWSxIbMEcfRhBSetEBQ3P 2/tvpIrdToExG2Oe6pGPPpg0A62KP5ctGy6DJapTMlKCIlNDRcSPZmiwoYwaQ8wa faFDPvQAsXL8/Z29vo4tRUSGVbKC8jhd3ZFp4x+n7R01v7F/URe6alrOTuY/zzir LiAk8sZvVhg77iIGxrwwplrbnzPwN5UysgC++hsShjU3YJO9RDz1IhRao0lvUSP8 8tDMfpfNWUb97DjiK2klN++kSHVKp4lRluKyIH756mXWP2oIq8oc4Bn8Ov2xiuEL R7tD+6Ga/coO3ur0/UPH7xVg =VwZn -----END PGP SIGNATURE----- --JBb2lD3XOhDIEUhHU863uhtG0XWoaFfth--