qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v9 09/10] tests: Add test code for hbitmap seria


From: Max Reitz
Subject: Re: [Qemu-block] [PATCH v9 09/10] tests: Add test code for hbitmap serialization
Date: Wed, 5 Oct 2016 18:31:11 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

On 05.10.2016 00:52, John Snow wrote:
> From: Fam Zheng <address@hidden>
> 
> Signed-off-by: Fam Zheng <address@hidden>
> [Fixed minor constant issue. --js]
> Signed-off-by: John Snow <address@hidden>
> 
> Signed-off-by: John Snow <address@hidden>
> ---
>  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

[Prev in Thread] Current Thread [Next in Thread]