From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkamU-0006QD-R8 for qemu-devel@nongnu.org; Wed, 14 May 2014 11:07:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkamO-0002k7-NV for qemu-devel@nongnu.org; Wed, 14 May 2014 11:07:42 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:35717 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkamO-0002k2-IS for qemu-devel@nongnu.org; Wed, 14 May 2014 11:07:36 -0400 Date: Wed, 14 May 2014 17:08:11 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140514150811.GB5955@irqsave.net> References: <1400077367-23409-1-git-send-email-stefanha@redhat.com> <1400077367-23409-3-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1400077367-23409-3-git-send-email-stefanha@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/3] throttle: add detach/attach test case List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , =?iso-8859-1?Q?Beno=EEt?= Canet , qemu-devel@nongnu.org The Wednesday 14 May 2014 =E0 16:22:46 (+0200), Stefan Hajnoczi wrote : > Add a test case that checks the timer is really removed/added by the > detach/attach functions. >=20 > Cc: Beno=EEt Canet > Signed-off-by: Stefan Hajnoczi > --- > tests/test-throttle.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) >=20 > 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); > } > =20 > +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 o= ps */ > int size, /* size of the operation t= o 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_c= onfig); > g_test_add_func("/throttle/config/is_valid", test_is_valid); > --=20 > 1.9.0 >=20 Reviewed-by: Benoit Canet