From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X48oO-0001VH-GJ for qemu-devel@nongnu.org; Mon, 07 Jul 2014 09:18:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X48oF-0007Hz-FX for qemu-devel@nongnu.org; Mon, 07 Jul 2014 09:18:28 -0400 Received: from mail-we0-x233.google.com ([2a00:1450:400c:c03::233]:58237) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X48oF-0007Hg-7Z for qemu-devel@nongnu.org; Mon, 07 Jul 2014 09:18:19 -0400 Received: by mail-we0-f179.google.com with SMTP id w62so4368996wes.24 for ; Mon, 07 Jul 2014 06:18:18 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 7 Jul 2014 15:18:03 +0200 Message-Id: <1404739084-3783-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1404739084-3783-1-git-send-email-pbonzini@redhat.com> References: <1404739084-3783-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 3/4] test-aio: fix GSource-based timer test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com The current test depends too much on the implementation of the AioContext GSource. Just iterate on the main loop until the callback has been invoked the right number of times. Signed-off-by: Paolo Bonzini --- tests/test-aio.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/test-aio.c b/tests/test-aio.c index e5f8b55..264dab9 100644 --- a/tests/test-aio.c +++ b/tests/test-aio.c @@ -806,17 +806,16 @@ static void test_source_timer_schedule(void) g_usleep(1 * G_USEC_PER_SEC); g_assert_cmpint(data.n, ==, 0); - g_assert(g_main_context_iteration(NULL, false)); + g_assert(g_main_context_iteration(NULL, true)); g_assert_cmpint(data.n, ==, 1); + expiry += data.ns; - /* The comment above was not kidding when it said this wakes up itself */ - do { - g_assert(g_main_context_iteration(NULL, true)); - } while (qemu_clock_get_ns(data.clock_type) <= expiry); - g_usleep(1 * G_USEC_PER_SEC); - g_main_context_iteration(NULL, false); + while (data.n < 2) { + g_main_context_iteration(NULL, true); + } g_assert_cmpint(data.n, ==, 2); + g_assert(qemu_clock_get_ns(data.clock_type) > expiry); aio_set_fd_handler(ctx, pipefd[0], NULL, NULL, NULL); close(pipefd[0]); -- 1.8.3.1