]> git.ozlabs.org Git - ccan/blobdiff - ccan/read_write_all/test/run-write_all.c
ccanlint: timeout, and implement -t option for quicker tests.
[ccan] / ccan / read_write_all / test / run-write_all.c
index fbfa1f99aebcbca18b37fe580fa05b3a388ff432..50bd729c78d7590d3d362ec9a7d39e41a10254e0 100644 (file)
@@ -1,8 +1,8 @@
 /* FIXME: Do something tricky to ensure we really do loop in write_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>
@@ -37,6 +37,7 @@ int main(int argc, char *argv[])
        child = fork();
 
        if (!child) {
+               close(p2c[1]);
                /* Make sure they started writing. */
                if (read(p2c[0], buffer, 1) != 1)
                        exit(1);
@@ -45,7 +46,7 @@ int main(int argc, char *argv[])
                if (!read_all(p2c[0], buffer+1, sizeof(buffer)-1))
                        exit(3);
                if (memchr(buffer, 0, sizeof(buffer))) {
-                       fprintf(stderr, "buffer has 0 at offset %i\n",
+                       fprintf(stderr, "buffer has 0 at offset %ti\n",
                                memchr(buffer, 0, sizeof(buffer)) - (void *)buffer);
                        exit(4);
                }
@@ -54,6 +55,7 @@ int main(int argc, char *argv[])
        if (child == -1)
                err(1, "forking");
 
+       close(p2c[0]);
        memset(buffer, 0xff, sizeof(buffer));
        signal(SIGUSR1, got_signal);
        ok1(write_all(p2c[1], buffer, sizeof(buffer)));