From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZ2pw-0002vS-3O for qemu-devel@nongnu.org; Fri, 20 Mar 2015 15:44:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YZ2ps-0004aK-Ow for qemu-devel@nongnu.org; Fri, 20 Mar 2015 15:44:04 -0400 Message-ID: <550C787E.1070903@redhat.com> Date: Fri, 20 Mar 2015 15:43:58 -0400 From: Max Reitz MIME-Version: 1.0 References: <1426879023-18151-1-git-send-email-jsnow@redhat.com> <1426879023-18151-17-git-send-email-jsnow@redhat.com> In-Reply-To: <1426879023-18151-17-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 16/20] hbitmap: truncate tests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow , qemu-block@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, vsementsov@parallels.com, stefanha@redhat.com On 2015-03-20 at 15:16, John Snow wrote: > The general approach is to set bits close to the boundaries of > where we are truncating and ensure that everything appears to > have gone OK. > > We test growing and shrinking by different amounts: > - Less than the granularity > - Less than the granularity, but across a boundary > - Less than sizeof(unsigned long) > - Less than sizeof(unsigned long), but across a ulong boundary > - More than sizeof(unsigned long) > > Signed-off-by: John Snow > Reviewed-by: Max Reitz > --- > tests/test-hbitmap.c | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 255 insertions(+) > > diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c > index 8c902f2..9f41b5f 100644 > --- a/tests/test-hbitmap.c > +++ b/tests/test-hbitmap.c [snip] > + > +static void hbitmap_test_check_boundary_bits(TestHBitmapData *data) > +{ > + size_t size = MIN(data->size, data->old_size); > + > + if (data->granularity == 0) { > + hbitmap_test_check_get(data); > + hbitmap_test_check(data, 0); > + } else { > + /* If a granularity was set, note that every distinct > + * (bit >> granularity) value that was set will increase > + * the bit pop count by 2^granularity, not just 1. > + * > + * The hbitmap_test_check facility does not currently tolerate > + * non-zero granularities, so test the boundaries and the population > + * count manually. > + */ Thanks! Max