]> git.ozlabs.org Git - ccan/blob - ccan/io/test/run-13-all-idle.c
ccan/io: rewrite.
[ccan] / ccan / io / test / run-13-all-idle.c
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>
6 #include <sys/wait.h>
7 #include <stdio.h>
8 #include <signal.h>
9
10 static struct io_plan *setup_waiter(struct io_conn *conn, int *status)
11 {
12         return io_wait(conn, status, IO_IN, io_close_cb, NULL);
13 }
14
15 int main(void)
16 {
17         int status;
18
19         plan_tests(3);
20
21         if (fork() == 0) {
22                 int fds[2];
23
24                 ok1(pipe(fds) == 0);
25                 io_new_conn(NULL, fds[0], setup_waiter, &status);
26                 io_loop();
27                 exit(1);
28         }
29
30         ok1(wait(&status) != -1);
31         ok1(WIFSIGNALED(status));
32         ok1(WTERMSIG(status) == SIGABRT);
33
34         /* This exits depending on whether all tests passed */
35         return exit_status();
36 }