From ffd6023885e71d026f18a8aec5b6610582e44150 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 21 Apr 2017 18:45:27 -0300 Subject: [PATCH] posix: Using libsupport for p{write,read}v tests Checked on x86_64-linux-gnu. * misc/tst-preadvwritev-common.c (do_prepare): Use libsupport expected arguments. (do_test): Adapt to use libsupport. --- ChangeLog | 6 ++++++ misc/tst-preadvwritev-common.c | 49 +++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index ffeb532..599c225 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017-04-26 Adhemerval Zanella + + * misc/tst-preadvwritev-common.c (do_prepare): Use libsupport + expected arguments. + (do_test): Adapt to use libsupport. + 2017-05-01 Joseph Myers * sysdeps/gnu/netinet/tcp.h (TCP_FASTOPEN_CONNECT): New macro. diff --git a/misc/tst-preadvwritev-common.c b/misc/tst-preadvwritev-common.c index 2943312..5540dfb 100644 --- a/misc/tst-preadvwritev-common.c +++ b/misc/tst-preadvwritev-common.c @@ -16,31 +16,28 @@ License along with the GNU C Library; if not, see . */ +#include +#include +#include #include #include -static void do_prepare (void); -#define PREPARE(argc, argv) do_prepare () -static int do_test (void); -#define TEST_FUNCTION do_test () -#include "test-skeleton.c" +#include +#include static char *temp_filename; static int temp_fd; +static int do_test (void); + static void -do_prepare (void) +do_prepare (int argc, char **argv) { temp_fd = create_temp_file ("tst-preadvwritev.", &temp_filename); if (temp_fd == -1) - { - printf ("cannot create temporary file: %m\n"); - exit (1); - } + FAIL_EXIT1 ("cannot create temporary file"); } - -#define FAIL(str) \ - do { printf ("error: %s (line %d)\n", str, __LINE__); return 1; } while (0) +#define PREPARE do_prepare static int do_test_with_offset (off_t offset) @@ -63,15 +60,15 @@ do_test_with_offset (off_t offset) ret = pwritev (temp_fd, iov, 2, offset); if (ret == -1) - FAIL ("first pwritev returned -1"); + FAIL_RET ("first pwritev returned -1"); if (ret != (sizeof buf1 + sizeof buf2)) - FAIL ("first pwritev returned an unexpected value"); + FAIL_RET ("first pwritev returned an unexpected value"); ret = pwritev (temp_fd, iov, 2, sizeof buf1 + sizeof buf2 + offset); if (ret == -1) - FAIL ("second pwritev returned -1"); + FAIL_RET ("second pwritev returned -1"); if (ret != (sizeof buf1 + sizeof buf2)) - FAIL ("second pwritev returned an unexpected value"); + FAIL_RET ("second pwritev returned an unexpected value"); char buf3[32]; char buf4[64]; @@ -87,26 +84,28 @@ do_test_with_offset (off_t offset) /* Now read two buffer with 32 and 64 bytes respectively. */ ret = preadv (temp_fd, iov, 2, offset); if (ret == -1) - FAIL ("first preadv returned -1"); + FAIL_RET ("first preadv returned -1"); if (ret != (sizeof buf3 + sizeof buf4)) - FAIL ("first preadv returned an unexpected value"); + FAIL_RET ("first preadv returned an unexpected value"); if (memcmp (buf1, buf3, sizeof buf1) != 0) - FAIL ("first buffer from first preadv different than expected"); + FAIL_RET ("first buffer from first preadv different than expected"); if (memcmp (buf2, buf4, sizeof buf2) != 0) - FAIL ("second buffer from first preadv different than expected"); + FAIL_RET ("second buffer from first preadv different than expected"); ret = preadv (temp_fd, iov, 2, sizeof buf3 + sizeof buf4 + offset); if (ret == -1) - FAIL ("second preadv returned -1"); + FAIL_RET ("second preadv returned -1"); if (ret != (sizeof buf3 + sizeof buf4)) - FAIL ("second preadv returned an unexpected value"); + FAIL_RET ("second preadv returned an unexpected value"); /* And compare the buffers read and written to check if there are equal. */ if (memcmp (buf1, buf3, sizeof buf1) != 0) - FAIL ("first buffer from second preadv different than expected"); + FAIL_RET ("first buffer from second preadv different than expected"); if (memcmp (buf2, buf4, sizeof buf2) != 0) - FAIL ("second buffer from second preadv different than expected"); + FAIL_RET ("second buffer from second preadv different than expected"); return 0; } + +#include -- 2.7.4