]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/test/run-13-all-idle.c
ccan/io: check for all idle.
[ccan] / ccan / io / test / run-13-all-idle.c
diff --git a/ccan/io/test/run-13-all-idle.c b/ccan/io/test/run-13-all-idle.c
new file mode 100644 (file)
index 0000000..b6a52a5
--- /dev/null
@@ -0,0 +1,36 @@
+#include <ccan/io/io.h>
+/* Include the C files directly. */
+#include <ccan/io/poll.c>
+#include <ccan/io/io.c>
+#include <ccan/tap/tap.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <signal.h>
+
+static struct io_op *start(struct io_conn *conn, void *unused)
+{
+       return io_idle(conn);
+}
+
+int main(void)
+{
+       int status;
+
+       plan_tests(3);
+
+       if (fork() == 0) {
+               int fds[2];
+
+               ok1(pipe(fds) == 0);
+               io_new_conn(fds[0], start, NULL, NULL);
+               io_loop();
+               exit(1);
+       }
+
+       ok1(wait(&status) != -1);
+       ok1(WIFSIGNALED(status));
+       ok1(WTERMSIG(status) == SIGABRT);
+
+       /* This exits depending on whether all tests passed */
+       return exit_status();
+}