[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v1 3/8] throttle: Add throttle group infrastruct
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH v1 3/8] throttle: Add throttle group infrastructure tests |
Date: |
Wed, 8 Oct 2014 14:20:22 +0800 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Tue, 10/07 15:24, Benoît Canet wrote:
> Signed-off-by: Benoit Canet <address@hidden>
> ---
> tests/test-throttle.c | 51
> +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
>
> diff --git a/tests/test-throttle.c b/tests/test-throttle.c
> index 3e52df3..ecb5504 100644
> --- a/tests/test-throttle.c
> +++ b/tests/test-throttle.c
> @@ -15,6 +15,7 @@
> #include "block/aio.h"
> #include "qemu/throttle.h"
> #include "qemu/error-report.h"
> +#include "block/throttle-groups.h"
>
> static AioContext *ctx;
> static LeakyBucket bkt;
> @@ -500,6 +501,55 @@ static void test_accounting(void)
> (64.0 / 13)));
> }
>
> +static void test_groups(void)
> +{
> + bool removed;
> +
> + ThrottleState *ts_foo, *ts_bar, *tmp;
> +
> + ts_bar = throttle_group_incref("bar");
> + throttle_group_set_token(ts_bar, (BlockDriverState *) 0x5, false);
Why do you have the magic numbers cast to pointers instead of allocated objects
with bdrv_new?
Fam
> + ts_foo = throttle_group_incref("foo");
> +
> + tmp = throttle_group_incref("foo");
> + throttle_group_set_token(tmp, (BlockDriverState *) 0x7, true);
> + g_assert(tmp == ts_foo);
> +
> + tmp = throttle_group_incref("bar");
> + g_assert(tmp == ts_bar);
> +
> + tmp = throttle_group_incref("bar");
> + g_assert(tmp == ts_bar);
> +
> + g_assert((int64_t) throttle_group_token(ts_bar, false) == 0x5);
> + g_assert((int64_t) throttle_group_token(ts_foo, true) == 0x7);
> +
> + removed = throttle_group_unref(ts_foo);
> + g_assert(removed);
> + removed = throttle_group_unref(ts_bar);
> + g_assert(removed);
> +
> + g_assert((int64_t) throttle_group_token(ts_foo, true) == 0x7);
> +
> + removed = throttle_group_unref(ts_foo);
> + g_assert(removed);
> + removed = throttle_group_unref(ts_bar);
> + g_assert(removed);
> +
> + /* "foo" group should be destroyed when reaching this */
> + removed = throttle_group_unref(ts_foo);
> + g_assert(!removed);
> +
> + g_assert((int64_t) throttle_group_token(ts_bar, false) == 0x5);
> +
> + removed = throttle_group_unref(ts_bar);
> + g_assert(removed);
> +
> + /* "bar" group should be destroyed when reaching this */
> + removed = throttle_group_unref(ts_bar);
> + g_assert(!removed);
> +}
> +
> int main(int argc, char **argv)
> {
> GSource *src;
> @@ -533,6 +583,7 @@ int main(int argc, char **argv)
> g_test_add_func("/throttle/config/is_valid", test_is_valid);
> g_test_add_func("/throttle/config_functions", test_config_functions);
> g_test_add_func("/throttle/accounting", test_accounting);
> + g_test_add_func("/throttle/groups", test_groups);
> return g_test_run();
> }
>
> --
> 2.1.1
>
- [Qemu-devel] [PATCH v1 7/8] throttle: Add throttle group support, (continued)
[Qemu-devel] [PATCH v1 8/8] throttle: Update throttle infrastructure copyright, Benoît Canet, 2014/10/07
[Qemu-devel] [PATCH v1 1/8] throttle: Extract timers from ThrottleState into a separate ThrottleTimers structure, Benoît Canet, 2014/10/07
[Qemu-devel] [PATCH v1 3/8] throttle: Add throttle group infrastructure tests, Benoît Canet, 2014/10/07
- Re: [Qemu-devel] [PATCH v1 3/8] throttle: Add throttle group infrastructure tests,
Fam Zheng <=
[Qemu-devel] [PATCH v1 4/8] throttle: Prepare to have multiple timers for one ThrottleState, Benoît Canet, 2014/10/07