]> git.ozlabs.org Git - ccan/blobdiff - ccan/read_write_all/test/run-read_all.c
ccanlint: timeout, and implement -t option for quicker tests.
[ccan] / ccan / read_write_all / test / run-read_all.c
index 2790b64d5ce5c59ea57f5029cc7b6453a7f45a7a..ee6a980032beba1776cfb9e8752437e19bbd1faa 100644 (file)
@@ -1,8 +1,8 @@
 /* FIXME: Do something tricky to ensure we really do loop in read_all. */
 
-#include "read_write_all/read_write_all.h"
-#include "read_write_all/read_write_all.c"
-#include "tap/tap.h"
+#include <ccan/read_write_all/read_write_all.h>
+#include <ccan/read_write_all/read_write_all.c>
+#include <ccan/tap/tap.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <signal.h>
@@ -39,6 +39,8 @@ int main(int argc, char *argv[])
        child = fork();
 
        if (!child) {
+               close(p2c[1]);
+               close(c2p[0]);
                /* Child.  Make sure parent ready, then write in two parts. */
                if (read(p2c[0], &c, 1) != 1)
                        exit(1);
@@ -50,13 +52,15 @@ int main(int argc, char *argv[])
                /* Make sure they get signal. */
                if (read(p2c[0], &c, 1) != 1)
                        exit(4);
-               if (write(c2p[1], buffer, PIPE_BUF) != PIPE_BUF)
+               if (write(c2p[1], buffer, BUFSZ) != BUFSZ)
                        exit(5);
                exit(0);
        }
        if (child == -1)
                err(1, "forking");
 
+       close(p2c[0]);
+       close(c2p[1]);
        signal(SIGUSR1, got_signal);
        ok1(write(p2c[1], &c, 1) == 1);
        ok1(read_all(c2p[0], buffer, sizeof(buffer)));