summaryrefslogtreecommitdiff
path: root/misc/tst-preadvwritev.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2016-07-04 11:34:35 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2016-07-08 15:41:21 -0300
commit468700675f7f36d55758c36b1ed902250470e8ec (patch)
tree64a677daa16b8653843e48be613a07892533788c /misc/tst-preadvwritev.c
parent6320de95367a6d5a7849d2a2ccdd9189277fc181 (diff)
Fix LO_HI_LONG definition
The p{read,write}v{64} consolidation patch [1] added a wrong guard for LO_HI_LONG definition. It currently uses both '__WORDSIZE == 64' and 'defined __ASSUME_WORDSIZE64_ILP32' to set the value to be passed in one argument, otherwise it will be split in two. However it fails on MIPS64n32 where syscalls n32 uses the compat implementation in the kernel meaning the off_t arguments are passed in two separate registers. GLIBC already defines a macro for such cases (__OFF_T_MATCHES_OFF64_T), so this patch uses it instead. Checked on x86_64, i686, x32, aarch64, armhf, and s390. * sysdeps/unix/sysv/linux/sysdep.h [__WORDSIZE == 64 || __ASSUME_WORDSIZE64_ILP32] (LO_HI_LONG): Remove guards. * misc/tst-preadvwritev-common.c: New file. * misc/tst-preadvwritev.c: Use tst-preadvwritev-common.c. * misc/tst-preadvwritev64.c: Use tst-preadwritev-common.c and add a check for files larger than 2GB. [1] 4751bbe2ad4d1bfa05774e29376d553ecfe563b0
Diffstat (limited to 'misc/tst-preadvwritev.c')
-rw-r--r--misc/tst-preadvwritev.c95
1 files changed, 3 insertions, 92 deletions
diff --git a/misc/tst-preadvwritev.c b/misc/tst-preadvwritev.c
index 08deecca11..fb3f1298a2 100644
--- a/misc/tst-preadvwritev.c
+++ b/misc/tst-preadvwritev.c
@@ -16,99 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <sys/uio.h>
+#include "tst-preadvwritev-common.c"
-/* Allow testing of the 64-bit versions as well. */
-#ifndef PREADV
-# define PREADV preadv
-# define PWRITEV pwritev
-#endif
-
-static void do_prepare (void);
-static int do_test (void);
-#define PREPARE(argc, argv) do_prepare ()
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
-
-static char *temp_filename;
-static int temp_fd;
-
-void
-do_prepare (void)
-{
- temp_fd = create_temp_file ("tst-PREADVwritev.", &temp_filename);
- if (temp_fd == -1)
- {
- printf ("cannot create temporary file: %m\n");
- exit (1);
- }
-}
-
-#define FAIL(str) \
- do { printf ("error: %s (line %d)\n", str, __LINE__); return 1; } while (0)
-
-int
+static int
do_test (void)
{
- struct iovec iov[2];
- ssize_t ret;
-
- char buf1[32];
- char buf2[64];
-
- memset (buf1, 0xf0, sizeof buf1);
- memset (buf2, 0x0f, sizeof buf2);
-
- memset (iov, 0, sizeof iov);
- iov[0].iov_base = buf1;
- iov[0].iov_len = sizeof buf1;
- iov[1].iov_base = buf2;
- iov[1].iov_len = sizeof buf2;
-
- ret = PWRITEV (temp_fd, iov, 2, 0);
- if (ret == -1)
- FAIL ("first PWRITEV returned -1");
- if (ret != (sizeof buf1 + sizeof buf2))
- FAIL ("first PWRITEV returned an unexpected value");
-
- ret = PWRITEV (temp_fd, iov, 2, sizeof buf1 + sizeof buf2);
- if (ret == -1)
- FAIL ("second PWRITEV returned -1");
- if (ret != (sizeof buf1 + sizeof buf2))
- FAIL ("second PWRITEV returned an unexpected value");
-
- char buf3[32];
- char buf4[64];
-
- memset (buf3, 0x0f, sizeof buf3);
- memset (buf4, 0xf0, sizeof buf4);
-
- iov[0].iov_base = buf3;
- iov[0].iov_len = sizeof buf3;
- iov[1].iov_base = buf4;
- iov[1].iov_len = sizeof buf4;
-
- ret = PREADV (temp_fd, iov, 2, 0);
- if (ret == -1)
- FAIL ("first PREADV returned -1");
- if (ret != (sizeof buf3 + sizeof buf4))
- FAIL ("first PREADV returned an unexpected value");
-
- if (memcmp (buf1, buf3, sizeof buf1) != 0)
- FAIL ("first buffer from first PREADV different than expected");
- if (memcmp (buf2, buf4, sizeof buf2) != 0)
- FAIL ("second buffer from first PREADV different than expected");
-
- ret = PREADV (temp_fd, iov, 2, sizeof buf3 + sizeof buf4);
- if (ret == -1)
- FAIL ("second PREADV returned -1");
- if (ret != (sizeof buf3 + sizeof buf4))
- FAIL ("second PREADV returned an unexpected value");
-
- if (memcmp (buf1, buf3, sizeof buf1) != 0)
- FAIL ("first buffer from second PREADV different than expected");
- if (memcmp (buf2, buf4, sizeof buf2) != 0)
- FAIL ("second buffer from second PREADV different than expected");
-
- return 0;
+ return do_test_with_offset (0);
}