1 #include <ccan/pipecmd/pipecmd.h>
2 /* Include the C files directly. */
3 #include <ccan/pipecmd/pipecmd.c>
4 #include <ccan/tap/tap.h>
9 int main(int argc, char *argv[])
15 /* We call ourselves, to test pipe. */
17 if (write(STDOUT_FILENO, buf, sizeof(buf)) != sizeof(buf))
22 /* This is how many tests you plan to run */
24 child = pipecmd(NULL, &outfd, NULL, argv[0], "out", NULL);
27 ok1(read(outfd, buf, sizeof(buf)) == sizeof(buf));
28 ok1(memcmp(buf, "test", sizeof(buf)) == 0);
29 ok1(waitpid(child, &status, 0) == child);
30 ok1(WIFEXITED(status));
31 ok1(WEXITSTATUS(status) == 0);
34 ok1(close(outfd) == 0);
35 ok1(close(outfd) == -1 && errno == EBADF);
36 ok1(close(++outfd) == -1 && errno == EBADF);
37 ok1(close(++outfd) == -1 && errno == EBADF);
38 ok1(close(++outfd) == -1 && errno == EBADF);
39 ok1(close(++outfd) == -1 && errno == EBADF);
40 ok1(close(++outfd) == -1 && errno == EBADF);
42 /* This exits depending on whether all tests passed */