6 #include <ccan/tap/tap.h>
7 /* Include the C files directly. */
8 #include <ccan/failtest/failtest.c>
14 char buf[] = "Hello world!";
18 fd = open("run-write-scratchpad", O_RDWR|O_CREAT, 0600);
19 write(fd, buf, strlen(buf));
20 ok1(lseek(fd, 0, SEEK_CUR) == strlen(buf));
22 p = failtest_malloc(100, "run-write.c", 1);
24 /* We are the child. Do a heap of writes. */
27 for (i = 0; i < strlen(buf)+1; i++)
28 if (failtest_write(fd, "x", 1, "run-write.c", 1) == 1)
33 /* Seek pointer should be left alone! */
34 ok1(lseek(fd, 0, SEEK_CUR) == strlen(buf));
35 /* Length should be restored. */
36 ok1(lseek(fd, 0, SEEK_END) == strlen(buf));
37 lseek(fd, 0, SEEK_SET);
38 ok1(read(fd, buf, strlen(buf)) == strlen("Hello world!"));
39 ok1(strcmp(buf, "Hello world!") == 0);