diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2014-07-07 15:18:03 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-07-09 15:50:11 +0200 |
commit | ef508f427b348c7f0ef2bfe7c080fe5fcaee9f6b (patch) | |
tree | d7c2ece80a335884f9556dd36e49fff852271f90 /tests/test-aio.c | |
parent | 87f68d318222563822b5c6b28192215fc4b4e441 (diff) |
test-aio: fix GSource-based timer test
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 <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/test-aio.c')
-rw-r--r-- | tests/test-aio.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/tests/test-aio.c b/tests/test-aio.c index e5f8b55d30..264dab9106 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]); |