From: Fam Zheng <famz@redhat.com>
To: Alberto Garcia <berto@igalia.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/7] throttle: Add throttle group infrastructure tests
Date: Wed, 1 Apr 2015 18:00:14 +0800 [thread overview]
Message-ID: <20150401100014.GC2777@fam-t430.nay.redhat.com> (raw)
In-Reply-To: <fd5d88e5ee7e0833e4759b62af9e0bf48fd21a95.1427732020.git.berto@igalia.com>
On Mon, 03/30 19:19, Alberto Garcia wrote:
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
> tests/test-throttle.c | 79 ++++++++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 69 insertions(+), 10 deletions(-)
>
> diff --git a/tests/test-throttle.c b/tests/test-throttle.c
> index 458f577..aa0e297 100644
> --- a/tests/test-throttle.c
> +++ b/tests/test-throttle.c
> @@ -1,10 +1,12 @@
> /*
> * Throttle infrastructure tests
> *
> - * Copyright Nodalink, SARL. 2013
> + * Copyright Nodalink, EURL. 2013-2014
> + * Copyright Igalia, S.L. 2015
> *
> * Authors:
> - * Benoît Canet <benoit.canet@irqsave.net>
> + * Benoît Canet <benoit.canet@nodalink.com>
> + * Alberto Garcia <berto@igalia.com>
Could be moved to patch 7.
Fam
> *
> * This work is licensed under the terms of the GNU LGPL, version 2 or later.
> * See the COPYING.LIB file in the top-level directory.
> @@ -15,6 +17,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,23 +503,78 @@ static void test_accounting(void)
> (64.0 / 13)));
> }
>
> +static void test_groups(void)
> +{
> + ThrottleConfig cfg1, cfg2;
> + BlockDriverState *bdrv1, *bdrv2, *bdrv3;
> +
> + bdrv1 = bdrv_new();
> + bdrv2 = bdrv_new();
> + bdrv3 = bdrv_new();
> +
> + g_assert(bdrv1->throttle_state == NULL);
> + g_assert(bdrv2->throttle_state == NULL);
> + g_assert(bdrv3->throttle_state == NULL);
> +
> + throttle_group_register_bs(bdrv1, "bar");
> + throttle_group_register_bs(bdrv2, "foo");
> + throttle_group_register_bs(bdrv3, "bar");
> +
> + g_assert(bdrv1->throttle_state != NULL);
> + g_assert(bdrv2->throttle_state != NULL);
> + g_assert(bdrv3->throttle_state != NULL);
> +
> + g_assert(!strcmp(throttle_group_get_name(bdrv1), "bar"));
> + g_assert(!strcmp(throttle_group_get_name(bdrv2), "foo"));
> + g_assert(bdrv1->throttle_state == bdrv3->throttle_state);
> +
> + /* Setting the config of a group member affects the whole group */
> + memset(&cfg1, 0, sizeof(cfg1));
> + cfg1.buckets[THROTTLE_BPS_READ].avg = 500000;
> + cfg1.buckets[THROTTLE_BPS_WRITE].avg = 285000;
> + cfg1.buckets[THROTTLE_OPS_READ].avg = 20000;
> + cfg1.buckets[THROTTLE_OPS_WRITE].avg = 12000;
> + throttle_group_config(bdrv1, &cfg1);
> +
> + throttle_group_get_config(bdrv1, &cfg1);
> + throttle_group_get_config(bdrv3, &cfg2);
> + g_assert(!memcmp(&cfg1, &cfg2, sizeof(cfg1)));
> +
> + cfg2.buckets[THROTTLE_BPS_READ].avg = 4547;
> + cfg2.buckets[THROTTLE_BPS_WRITE].avg = 1349;
> + cfg2.buckets[THROTTLE_OPS_READ].avg = 123;
> + cfg2.buckets[THROTTLE_OPS_WRITE].avg = 86;
> + throttle_group_config(bdrv3, &cfg1);
> +
> + throttle_group_get_config(bdrv1, &cfg1);
> + throttle_group_get_config(bdrv3, &cfg2);
> + g_assert(!memcmp(&cfg1, &cfg2, sizeof(cfg1)));
> +
> + throttle_group_unregister_bs(bdrv1);
> + throttle_group_unregister_bs(bdrv2);
> + throttle_group_unregister_bs(bdrv3);
> +
> + g_assert(bdrv1->throttle_state == NULL);
> + g_assert(bdrv2->throttle_state == NULL);
> + g_assert(bdrv3->throttle_state == NULL);
> +}
> +
> int main(int argc, char **argv)
> {
> - GSource *src;
> Error *local_error = NULL;
>
> - init_clocks();
> + qemu_init_main_loop(&local_error);
> + ctx = qemu_get_aio_context();
>
> - ctx = aio_context_new(&local_error);
> if (!ctx) {
> error_report("Failed to create AIO Context: '%s'",
> - error_get_pretty(local_error));
> - error_free(local_error);
> + local_error ? error_get_pretty(local_error) :
> + "Failed to initialize the QEMU main loop");
> + if (local_error) {
> + error_free(local_error);
> + }
> exit(1);
> }
> - src = aio_get_g_source(ctx);
> - g_source_attach(src, NULL);
> - g_source_unref(src);
>
> do {} while (g_main_context_iteration(NULL, false));
>
> @@ -533,6 +591,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.4
>
>
next prev parent reply other threads:[~2015-04-01 10:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-30 16:19 [Qemu-devel] [PATCH v6 0/7] Block Throttle Group Support Alberto Garcia
2015-03-30 16:19 ` [Qemu-devel] [PATCH 1/7] throttle: Extract timers from ThrottleState into a separate structure Alberto Garcia
2015-03-30 16:19 ` [Qemu-devel] [PATCH 2/7] throttle: Add throttle group infrastructure Alberto Garcia
2015-04-09 12:28 ` Stefan Hajnoczi
2015-03-30 16:19 ` [Qemu-devel] [PATCH 3/7] throttle: Add throttle group infrastructure tests Alberto Garcia
2015-04-01 10:00 ` Fam Zheng [this message]
2015-04-09 12:30 ` Stefan Hajnoczi
2015-03-30 16:19 ` [Qemu-devel] [PATCH 4/7] throttle: Add throttle group support Alberto Garcia
2015-04-01 14:44 ` Fam Zheng
2015-04-01 15:18 ` Alberto Garcia
2015-04-02 3:26 ` Fam Zheng
2015-04-02 7:36 ` Alberto Garcia
2015-04-09 14:22 ` Stefan Hajnoczi
2015-04-10 7:58 ` Alberto Garcia
2015-04-10 9:52 ` Stefan Hajnoczi
2015-04-10 9:55 ` Alberto Garcia
2015-03-30 16:19 ` [Qemu-devel] [PATCH 5/7] throttle: acquire the ThrottleGroup lock in bdrv_swap() Alberto Garcia
2015-03-30 16:19 ` [Qemu-devel] [PATCH 6/7] throttle: add the name of the ThrottleGroup to BlockDeviceInfo Alberto Garcia
2015-04-01 9:59 ` Fam Zheng
2015-04-01 10:06 ` Alberto Garcia
2015-04-01 14:05 ` Fam Zheng
2015-03-30 16:19 ` [Qemu-devel] [PATCH 7/7] throttle: Update throttle infrastructure copyright Alberto Garcia
-- strict thread matches above, loose matches on Subject: below --
2015-03-30 14:16 [Qemu-devel] [PATCH v5 0/7] Block Throttle Group Support Alberto Garcia
2015-03-30 14:16 ` [Qemu-devel] [PATCH 3/7] throttle: Add throttle group infrastructure tests Alberto Garcia
2015-03-26 17:24 [Qemu-devel] [PATCH v4 0/7] Block Throttle Group Support Alberto Garcia
2015-03-26 17:24 ` [Qemu-devel] [PATCH 3/7] throttle: Add throttle group infrastructure tests Alberto Garcia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150401100014.GC2777@fam-t430.nay.redhat.com \
--to=famz@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).