On 05.10.2016 00:52, John Snow wrote:
> From: Fam Zheng <f...@redhat.com>
> 
> Signed-off-by: Fam Zheng <f...@redhat.com>
> [Fixed minor constant issue. --js]
> Signed-off-by: John Snow <js...@redhat.com>
> 
> Signed-off-by: John Snow <js...@redhat.com>
> ---
>  tests/test-hbitmap.c | 155 
> +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 155 insertions(+)
> 
> 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[] = { 0, L1, L2, L3 - L1};
> +    int num_positions = sizeof(positions) / sizeof(positions[0]);
> +
> +    hbitmap_test_init(data, L3, 0);
> +
> +    for (i = 0; i < num_positions; i++) {
> +        hbitmap_set(data->hb, positions[i], L1);
> +    }
> +
> +    for (i = 0; i < num_positions; i++) {
> +        hbitmap_deserialize_zeroes(data->hb, positions[i], L1, true);

This tries to deserialize L1 (= 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 = hbitmap_iter_next(&iter);
> +        if (i == num_positions - 1) {
> +            g_assert_cmpint(next, ==, -1);
> +        } else {
> +            g_assert_cmpint(next, ==, 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();
>  
>      return 0;
> 


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to