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 *read_in(struct io_conn *conn, char *buf)
13 return io_read(conn, buf, 16, io_close_cb, NULL);
16 static struct io_plan *setup_waiter(struct io_conn *conn, char *buf)
18 return io_wait(conn, buf, IO_IN, read_in, buf);
21 static struct io_plan *wake_and_close(struct io_conn *conn, char *buf)
24 return io_close(conn);
27 static struct io_plan *setup_waker(struct io_conn *conn, char *buf)
29 return io_read(conn, buf, 1, wake_and_close, buf);
41 io_new_conn(NULL, fds[0], setup_waiter, buf);
43 io_new_conn(NULL, fds2[0], setup_waker, buf);
46 write(fds[1], "hello there world", 16);
51 write(fds2[1], "", 1);
55 ok1(io_loop() == NULL);
56 ok1(memcmp(buf, "hello there world", 16) == 0);
58 /* This exits depending on whether all tests passed */