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 /* Should be looking to read from one fd. */
12 static int mypoll(struct pollfd *fds, nfds_t nfds, int timeout)
16 ok1(fds[0].events & POLLIN);
17 ok1(!(fds[0].events & POLLOUT));
19 /* Pretend it's readable. */
20 fds[0].revents = POLLIN;
24 static int check_cant_read(int fd, struct io_plan_arg *arg)
27 ssize_t ret = read(fd, &c, 1);
29 ok1(errno == EAGAIN || errno == EWOULDBLOCK);
35 static struct io_plan *setup_conn(struct io_conn *conn, void *unused)
37 /* Need to get this to mark it IO_POLLING */
38 io_plan_arg(conn, IO_IN);
39 return io_set_plan(conn, IO_IN, check_cant_read, io_close_cb, NULL);
49 ok1(io_poll_override(mypoll) == poll);
51 io_new_conn(NULL, fds[0], setup_conn, NULL);
52 ok1(io_loop(NULL, NULL) == NULL);
55 /* This exits depending on whether all tests passed */