]> git.ozlabs.org Git - ccan/commitdiff
failtest: don't insist parents and children write the same thing to files.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 15 Feb 2011 12:55:03 +0000 (23:25 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 15 Feb 2011 12:55:03 +0000 (23:25 +1030)
We insist they write the same things to pipes, since we can't "undo" them,
but strictly speaking we don't care if they write different things into
files.

Note: it may indicate a bug if they do...

ccan/failtest/failtest.c

index 56a1ad1872f9f584b9fda6bbf9f21d10e6f3c0b3..9102ba0a88b884591ef766bdfa9582e4de72d424 100644 (file)
@@ -663,8 +663,9 @@ ssize_t failtest_pwrite(int fd, const void *buf, size_t count, off_t off,
        call.off = off;
        p = add_history(FAILTEST_WRITE, file, line, &call);
 
        call.off = off;
        p = add_history(FAILTEST_WRITE, file, line, &call);
 
-       /* If we're a child, tell parent about write. */
-       if (control_fd != -1) {
+       /* If we're a child, we need to make sure we write the same thing
+        * to non-files as the parent does, so tell it. */
+       if (control_fd != -1 && off == (off_t)-1) {
                enum info_type type = WRITE;
 
                write_all(control_fd, &type, sizeof(type));
                enum info_type type = WRITE;
 
                write_all(control_fd, &type, sizeof(type));
@@ -678,7 +679,7 @@ ssize_t failtest_pwrite(int fd, const void *buf, size_t count, off_t off,
                p->error = EIO;
        } else {
                /* FIXME: We assume same write order in parent and child */
                p->error = EIO;
        } else {
                /* FIXME: We assume same write order in parent and child */
-               if (child_writes_num != 0) {
+               if (off == (off_t)-1 && child_writes_num != 0) {
                        if (child_writes[0].fd != fd)
                                errx(1, "Child wrote to fd %u, not %u?",
                                     child_writes[0].fd, fd);
                        if (child_writes[0].fd != fd)
                                errx(1, "Child wrote to fd %u, not %u?",
                                     child_writes[0].fd, fd);