| 39 | } |
| 40 | |
| 41 | int main(void) |
| 42 | { |
| 43 | int sv[2]; |
| 44 | int pid, wstatus; |
| 45 | |
| 46 | plan_tests(17); |
| 47 | ok1(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0); |
| 48 | |
| 49 | pid = fork(); |
| 50 | if (pid == 0) { |
| 51 | close(sv[1]); |
| 52 | child(sv[0]); |
| 53 | } |
| 54 | |
| 55 | parent(sv[1]); |
| 56 | ok1(waitpid(pid, &wstatus, 0) == pid); |
| 57 | ok1(WIFEXITED(wstatus)); |
| 58 | ok1(WEXITSTATUS(wstatus) == 0); |
| 59 | |
| 60 | pid = fork(); |
| 61 | if (pid == 0) { |
| 62 | close(sv[1]); |
| 63 | child_nofd(sv[0]); |
| 64 | } |
| 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); |
| 70 | |
| 71 | pid = fork(); |
| 72 | if (pid == 0) { |
| 73 | close(sv[1]); |
| 74 | child_nofd(sv[0]); |
| 75 | } |
| 76 | /* Don't write anything. */ |
| 77 | close(sv[1]); |
| 78 | ok1(waitpid(pid, &wstatus, 0) == pid); |
| 79 | ok1(WIFEXITED(wstatus)); |
| 80 | ok1(WEXITSTATUS(wstatus) == 0); |
| 81 | |
| 82 | close(sv[0]); |
| 83 | /* Test fdpass_recv from invalid fd. */ |
| 84 | ok1(fdpass_recv(sv[0]) == -1 && errno == EBADF); |
| 85 | |
| 86 | /* This exits depending on whether all tests passed */ |
| 87 | return exit_status(); |
| 88 | } |
nothing calls this directly
no test coverage detected