qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Benoît Canet" <benoit.canet@irqsave.net>,
	"Benoît Canet" <benoit@irqsave.net>,
	"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 2/3] throttle: add detach/attach test case
Date: Wed, 14 May 2014 16:22:46 +0200	[thread overview]
Message-ID: <1400077367-23409-3-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1400077367-23409-1-git-send-email-stefanha@redhat.com>

Add a test case that checks the timer is really removed/added by the
detach/attach functions.

Cc: Benoît Canet <benoit.canet@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 tests/test-throttle.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/test-throttle.c b/tests/test-throttle.c
index 5fa5000..3de6ab8 100644
--- a/tests/test-throttle.c
+++ b/tests/test-throttle.c
@@ -338,6 +338,29 @@ static void test_have_timer(void)
     throttle_destroy(&ts);
 }
 
+static void test_detach_attach(void)
+{
+    /* zero the structure */
+    memset(&ts, 0, sizeof(ts));
+
+    /* init the structure */
+    throttle_init(&ts, ctx, QEMU_CLOCK_VIRTUAL,
+                  read_timer_cb, write_timer_cb, &ts);
+
+    /* timer set by init should return true */
+    g_assert(throttle_have_timer(&ts));
+
+    /* timer should no longer exist after detaching */
+    throttle_detach_aio_context(&ts);
+    g_assert(!throttle_have_timer(&ts));
+
+    /* timer should exist again after attaching */
+    throttle_attach_aio_context(&ts, ctx);
+    g_assert(throttle_have_timer(&ts));
+
+    throttle_destroy(&ts);
+}
+
 static bool do_test_accounting(bool is_ops, /* are we testing bps or ops */
                 int size,                   /* size of the operation to do */
                 double avg,                 /* io limit */
@@ -486,6 +509,7 @@ int main(int argc, char **argv)
     g_test_add_func("/throttle/init",               test_init);
     g_test_add_func("/throttle/destroy",            test_destroy);
     g_test_add_func("/throttle/have_timer",         test_have_timer);
+    g_test_add_func("/throttle/detach_attach",      test_detach_attach);
     g_test_add_func("/throttle/config/enabled",     test_enabled);
     g_test_add_func("/throttle/config/conflicting", test_conflicting_config);
     g_test_add_func("/throttle/config/is_valid",    test_is_valid);
-- 
1.9.0

  parent reply	other threads:[~2014-05-14 14:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-14 14:22 [Qemu-devel] [PATCH 0/3] throttle: use AioContext for dataplane support Stefan Hajnoczi
2014-05-14 14:22 ` [Qemu-devel] [PATCH 1/3] throttle: add throttle_detach/attach_aio_context() Stefan Hajnoczi
2014-05-14 15:05   ` Benoît Canet
2014-05-15  7:57     ` Stefan Hajnoczi
2014-05-15 11:25   ` Benoît Canet
2014-05-14 14:22 ` Stefan Hajnoczi [this message]
2014-05-14 15:08   ` [Qemu-devel] [PATCH 2/3] throttle: add detach/attach test case Benoît Canet
2014-05-14 14:22 ` [Qemu-devel] [PATCH 3/3] blockdev: acquire AioContext in block_set_io_throttle Stefan Hajnoczi
2014-05-14 15:11   ` Benoît Canet
2014-05-14 15:14 ` [Qemu-devel] [PATCH 0/3] throttle: use AioContext for dataplane support Benoît Canet
2014-05-14 17:40 ` Benoît Canet
2014-05-15  7:46   ` Stefan Hajnoczi
2014-06-03 13:44 ` Stefan Hajnoczi

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=1400077367-23409-3-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=benoit.canet@irqsave.net \
    --cc=benoit@irqsave.net \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).