X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ffailtest%2Ftest%2Frun-open.c;h=b2a5aab145b5ac814b1ed962ee763c61a478954f;hp=3ac93aebb12af7ebec51fedc0e388c8773bcac40;hb=57cc9494b0daacd23372cdbdefcd31fe9320c836;hpb=e8f0484b7808efe03dbb573563b336d533487e29 diff --git a/ccan/failtest/test/run-open.c b/ccan/failtest/test/run-open.c index 3ac93aeb..b2a5aab1 100644 --- a/ccan/failtest/test/run-open.c +++ b/ccan/failtest/test/run-open.c @@ -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. */ @@ -41,17 +44,19 @@ int main(void) ok1(err == EACCES); /* Clean up. */ - failtest_close(fd); + failtest_close(fd, "run-open.c", 1); close(pfd[0]); 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. */ @@ -59,7 +64,7 @@ int main(void) ok1(read(fd, buf, strlen("Hello world!")) == strlen("Hello world!")); ok1(strcmp(buf, "Hello world!") == 0); /* Clean up. */ - failtest_close(fd); + failtest_close(fd, "run-open.c", 1); close(pfd[0]); close(pfd[1]);