1 #include <ccan/io/io.h>
2 /* Include the C files directly. */
3 #include <ccan/io/poll.c>
4 #include <ccan/io/io.c>
5 #include <ccan/tap/tap.h>
11 static struct io_plan timeout_wakeup(struct io_conn *conn, char *buf)
13 /* This kills the dummy connection. */
15 return io_read(buf, 16, io_close_cb, NULL);
18 static struct io_plan never(struct io_conn *conn, void *unused)
33 /* Write then close. */
34 io_new_conn(fds[1], io_write("hello there world", 16,
36 conn = io_new_conn(fds[0], io_wait(buf, never, NULL));
38 /* To avoid assert(num_waiting) */
40 io_new_conn(fds2[0], io_read(buf, 16, io_close_cb, NULL));
42 /* After half a second, it will read. */
43 io_timeout(conn, time_from_msec(500), timeout_wakeup, buf);
45 ok1(io_loop() == NULL);
46 ok1(memcmp(buf, "hello there world", 16) == 0);
48 /* This exits depending on whether all tests passed */