1 #include <ccan/fdpass/fdpass.h>
2 /* Include the C files directly. */
3 #include <ccan/fdpass/fdpass.c>
4 #include <ccan/tap/tap.h>
14 static void child(int sockfd)
17 int newfd = fdpass_recv(sockfd);
19 assert(read(newfd, &c, 1) == 1);
24 static void child_nofd(int sockfd)
26 assert(fdpass_recv(sockfd) == -1);
30 static void parent(int sockfd)
35 ok1(fdpass_send(sockfd, pfds[0]));
36 ok1(close(pfds[0]) == 0);
37 ok1(write(pfds[1], "\x77", 1) == 1);
38 ok1(close(pfds[1]) == 0);
47 ok1(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
56 ok1(waitpid(pid, &wstatus, 0) == pid);
57 ok1(WIFEXITED(wstatus));
58 ok1(WEXITSTATUS(wstatus) == 0);
65 /* Don't write an fd. */
66 ok1(write(sv[1], "1", 1) == 1);
67 ok1(waitpid(pid, &wstatus, 0) == pid);
68 ok1(WIFEXITED(wstatus));
69 ok1(WEXITSTATUS(wstatus) == 0);
76 /* Don't write anything. */
78 ok1(waitpid(pid, &wstatus, 0) == pid);
79 ok1(WIFEXITED(wstatus));
80 ok1(WEXITSTATUS(wstatus) == 0);
83 /* Test fdpass_recv from invalid fd. */
84 ok1(fdpass_recv(sv[0]) == -1 && errno == EBADF);
86 /* This exits depending on whether all tests passed */