run-13-all-idle.c 638 B

123456789101112131415161718192021222324252627282930313233343536
  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. static struct io_plan *start(struct io_conn *conn, void *unused)
  10. {
  11. return io_idle(conn);
  12. }
  13. int main(void)
  14. {
  15. int status;
  16. plan_tests(3);
  17. if (fork() == 0) {
  18. int fds[2];
  19. ok1(pipe(fds) == 0);
  20. io_new_conn(fds[0], start, NULL, NULL);
  21. io_loop();
  22. exit(1);
  23. }
  24. ok1(wait(&status) != -1);
  25. ok1(WIFSIGNALED(status));
  26. ok1(WTERMSIG(status) == SIGABRT);
  27. /* This exits depending on whether all tests passed */
  28. return exit_status();
  29. }