]> git.ozlabs.org Git - ccan/blobdiff - ccan/failtest/test/run-open.c
endian: add constant versions.
[ccan] / ccan / failtest / test / run-open.c
index a81fa259334c70298c0c2ac0ed320e23d556ca72..0166506480d897ea96f4b6ba33a5615109fb28ee 100644 (file)
@@ -1,11 +1,11 @@
+/* Include the C files directly. */
+#include <ccan/failtest/failtest.c>
 #include <stdlib.h>
 #include <setjmp.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <assert.h>
 #include <ccan/tap/tap.h>
-/* Include the C files directly. */
-#include <ccan/failtest/failtest.c>
 
 int main(void)
 {
@@ -14,14 +14,17 @@ int main(void)
        struct stat st;
 
        plan_tests(12);
+       failtest_init(0, NULL);
 
-       pipe(pfd);
+       if (pipe(pfd))
+               abort();
        fd = failtest_open("run-open-scratchpad", "run-open.c", 1,
                           O_RDWR|O_CREAT, 0600);
        if (fd == -1) {
                /* We are the child: write error code for parent to check. */
                err = errno;
-               write(pfd[1], &err, sizeof(err));
+               if (write(pfd[1], &err, sizeof(err)) != sizeof(err))
+                       abort();
                failtest_exit(0);
        }
        /* Check it is read-write. */
@@ -46,12 +49,14 @@ int main(void)
        close(pfd[1]);
 
        /* Two-arg open. */
-       pipe(pfd);
+       if (pipe(pfd) != 0)
+               abort();
        fd = failtest_open("run-open-scratchpad", "run-open.c", 1, O_RDONLY);
        if (fd == -1) {
                /* We are the child: write error code for parent to check. */
                err = errno;
-               write(pfd[1], &err, sizeof(err));
+               if (write(pfd[1], &err, sizeof(err)) != sizeof(err))
+                       abort();
                failtest_exit(0);
        }
        /* Check it is read-only. */