qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit.canet@nodalink.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com,
	"Benoît Canet" <benoit.canet@nodalink.com>,
	stefanha@redhat.com
Subject: [Qemu-devel] [RFC V2 3/8] throttle: Add throttle group infrastructure tests
Date: Wed, 13 Aug 2014 16:23:54 +0200	[thread overview]
Message-ID: <1407939839-27483-4-git-send-email-benoit.canet@nodalink.com> (raw)
In-Reply-To: <1407939839-27483-1-git-send-email-benoit.canet@nodalink.com>

Signed-off-by: Benoit Canet <benoit.canet@nodalink.com>
---
 tests/test-throttle.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/tests/test-throttle.c b/tests/test-throttle.c
index 66e4982..50e6655 100644
--- a/tests/test-throttle.c
+++ b/tests/test-throttle.c
@@ -14,6 +14,7 @@
 #include <math.h>
 #include "block/aio.h"
 #include "qemu/throttle.h"
+#include "block/throttle-groups.h"
 
 static AioContext     *ctx;
 static LeakyBucket    bkt;
@@ -499,6 +500,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);
+    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;
@@ -525,6 +575,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.0.rc1

  parent reply	other threads:[~2014-08-13 14:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-13 14:23 [Qemu-devel] [RFC V2 0/8] Throttle group cooperative round robin scheduling Benoît Canet
2014-08-13 14:23 ` [Qemu-devel] [RFC V2 1/8] throttle: Extract timers from ThrottleState into a separate ThrottleTimers structure Benoît Canet
2014-08-13 14:23 ` [Qemu-devel] [RFC V2 2/8] throttle: Add throttle group infrastructure Benoît Canet
2014-08-13 14:23 ` Benoît Canet [this message]
2014-08-13 14:23 ` [Qemu-devel] [RFC V2 4/8] throttle: Prepare to have multiple timers for one ThrottleState Benoît Canet
2014-08-13 14:23 ` [Qemu-devel] [RFC V2 5/8] throttle: Add a way to know if throttle_schedule_timer had armed a timer Benoît Canet
2014-08-13 14:23 ` [Qemu-devel] [RFC V2 6/8] throttle: Add a way to fire one of the timers asap like a bottom half Benoît Canet
2014-08-13 14:23 ` [Qemu-devel] [RFC V2 7/8] throttle: Add throttle group support Benoît Canet
2014-09-02 22:37   ` Eric Blake
2014-08-13 14:23 ` [Qemu-devel] [RFC V2 8/8] throttle: Update throttle infrastructure copyright Benoît Canet
2014-08-20 14:27 ` [Qemu-devel] [RFC V2 0/8] Throttle group cooperative round robin scheduling Benoît Canet
2014-09-01 14:34   ` Benoît Canet

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=1407939839-27483-4-git-send-email-benoit.canet@nodalink.com \
    --to=benoit.canet@nodalink.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@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).