]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/test/run-01-start-finish.c
io: change io_idle() to io_wait()
[ccan] / ccan / io / test / run-01-start-finish.c
index b5114abeafcceabe3b26d88581336e63b89ee582..3ee659471847d73addc4c4e57b26e3eb6d2086c5 100644 (file)
@@ -6,19 +6,25 @@
 #include <sys/wait.h>
 #include <stdio.h>
 
+#ifndef PORT
+#define PORT "65001"
+#endif
+static int expected_fd;
+
 static void finish_ok(struct io_conn *conn, int *state)
 {
        ok1(*state == 1);
+       ok1(io_conn_fd(conn) == expected_fd);
        (*state)++;
-       io_break(state + 1, io_idle());
+       io_break(state + 1, io_never());
 }
 
 static void init_conn(int fd, int *state)
 {
        ok1(*state == 0);
        (*state)++;
-       if (!io_new_conn(fd, io_close(NULL, NULL), finish_ok, state))
-               abort();
+       expected_fd = fd;
+       io_set_finish(io_new_conn(fd, io_close()), finish_ok, state);
 }
 
 static int make_listen_fd(const char *port, struct addrinfo **info)
@@ -61,8 +67,8 @@ int main(void)
        int fd;
 
        /* This is how many tests you plan to run */
-       plan_tests(9);
-       fd = make_listen_fd("65001", &addrinfo);
+       plan_tests(10);
+       fd = make_listen_fd(PORT, &addrinfo);
        ok1(fd >= 0);
        l = io_new_listener(fd, init_conn, &state);
        ok1(l);