]> granicus.if.org Git - strace/commitdiff
tests/read-write.c: robustify against os specific issues
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 18 May 2016 09:14:12 +0000 (09:14 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 18 May 2016 09:26:01 +0000 (09:26 +0000)
Do not assume that write syscall fails when only part of the specified
memory buffer is accessible.  With some kernels, one accessible byte
at the end of page is enough for write syscall to return 1.

* tests/read-write.c (main): Tweak the test that can lead to a partial
write.

tests/read-write.c

index 4efe1473cf3c2d9d7a3d7cd05ac88a656e0dbef6..4d1e7302c7b9f197fa0e37de720cecae27ed3aee 100644 (file)
@@ -152,12 +152,11 @@ main(void)
                perror_msg_and_fail("write: expected 0, returned %ld", rc);
        tprintf("write(1, \"\", 0) = 0\n");
 
-       rc = write(1, w, w_len + 1);
+       rc = write(1, efault, 1);
        if (rc != -1)
                perror_msg_and_fail("write: expected -1 EFAULT"
                                    ", returned %ld", rc);
-       tprintf("write(1, %p, %u) = -1 EFAULT (%m)\n",
-               w, w_len + 1);
+       tprintf("write(1, %p, 1) = -1 EFAULT (%m)\n", efault);
 
        rc = write(1, w, w_len);
        if (rc != (int) w_len)