From a8e820586ece77fe5430ca089b255f735a92cb6b Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 18 May 2016 09:14:12 +0000 Subject: [PATCH] tests/read-write.c: robustify against os specific issues 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 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/read-write.c b/tests/read-write.c index 4efe1473..4d1e7302 100644 --- a/tests/read-write.c +++ b/tests/read-write.c @@ -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) -- 2.50.1