]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/test/run-01-start-finish.c
io: add io_conn_fd()
[ccan] / ccan / io / test / run-01-start-finish.c
index 297dbc6f9bd9a6ccb15d7af96fb3c49369099e90..d8a24a52fe42b35e1ddf3a740b3d31d151f8165c 100644 (file)
@@ -9,10 +9,12 @@
 #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());
 }
@@ -21,8 +23,8 @@ static void init_conn(int fd, int *state)
 {
        ok1(*state == 0);
        (*state)++;
-       io_set_finish(io_new_conn(fd, io_close(NULL, NULL)), finish_ok, state);
-
+       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)
@@ -65,7 +67,7 @@ int main(void)
        int fd;
 
        /* This is how many tests you plan to run */
-       plan_tests(9);
+       plan_tests(10);
        fd = make_listen_fd(PORT, &addrinfo);
        ok1(fd >= 0);
        l = io_new_listener(fd, init_conn, &state);