aboutsummaryrefslogtreecommitdiff
path: root/tests/test-aio.c
diff options
context:
space:
mode:
authorAlex Bligh <alex@alex.org.uk>2013-08-29 17:48:16 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2013-09-06 15:25:08 +0200
commita94a3fac19c37c093203e9e01c3a54e92e1dc701 (patch)
tree8a348580d81e0b6bcf800c73d3e3f683de7930a1 /tests/test-aio.c
parent68dc036488dfea170627a55e6ee3dfd7f2c2063e (diff)
downloadqemu-a94a3fac19c37c093203e9e01c3a54e92e1dc701.zip
qemu-a94a3fac19c37c093203e9e01c3a54e92e1dc701.tar.gz
qemu-a94a3fac19c37c093203e9e01c3a54e92e1dc701.tar.bz2
aio / timers: fix build of test/test-aio.c on non-linux platforms
tests/test-aio.c used pipe2 which is Linux only. Use qemu_pipe and qemu_set_nonblock for portabillity. Addition of O_CLOEXEC is a harmless bonus. Signed-off-by: Alex Bligh <alex@alex.org.uk> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/test-aio.c')
-rw-r--r--tests/test-aio.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/test-aio.c b/tests/test-aio.c
index 532a1de..c4fe0fc 100644
--- a/tests/test-aio.c
+++ b/tests/test-aio.c
@@ -13,6 +13,7 @@
#include <glib.h>
#include "block/aio.h"
#include "qemu/timer.h"
+#include "qemu/sockets.h"
AioContext *ctx;
@@ -375,7 +376,10 @@ static void test_timer_schedule(void)
/* aio_poll will not block to wait for timers to complete unless it has
* an fd to wait on. Fixing this breaks other tests. So create a dummy one.
*/
- g_assert(!pipe2(pipefd, O_NONBLOCK));
+ g_assert(!qemu_pipe(pipefd));
+ qemu_set_nonblock(pipefd[0]);
+ qemu_set_nonblock(pipefd[1]);
+
aio_set_fd_handler(ctx, pipefd[0],
dummy_io_handler_read, NULL, NULL);
aio_poll(ctx, false);
@@ -716,7 +720,10 @@ static void test_source_timer_schedule(void)
/* aio_poll will not block to wait for timers to complete unless it has
* an fd to wait on. Fixing this breaks other tests. So create a dummy one.
*/
- g_assert(!pipe2(pipefd, O_NONBLOCK));
+ g_assert(!qemu_pipe(pipefd));
+ qemu_set_nonblock(pipefd[0]);
+ qemu_set_nonblock(pipefd[1]);
+
aio_set_fd_handler(ctx, pipefd[0],
dummy_io_handler_read, NULL, NULL);
do {} while (g_main_context_iteration(NULL, false));