From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6efO-0004A8-4J for qemu-devel@nongnu.org; Mon, 14 Jul 2014 07:43:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X6efG-0005Cb-3r for qemu-devel@nongnu.org; Mon, 14 Jul 2014 07:43:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43368) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6efF-0005CW-Pp for qemu-devel@nongnu.org; Mon, 14 Jul 2014 07:43:25 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6EBhPFq013762 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Jul 2014 07:43:25 -0400 From: Kevin Wolf Date: Mon, 14 Jul 2014 13:42:55 +0200 Message-Id: <1405338192-18850-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1405338192-18850-1-git-send-email-kwolf@redhat.com> References: <1405338192-18850-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL v2 for-2.1 05/22] 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 From: Paolo Bonzini 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 Signed-off-by: Kevin Wolf --- 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