diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2017-04-21 18:45:27 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2017-05-01 15:41:45 -0300 |
commit | ffd6023885e71d026f18a8aec5b6610582e44150 (patch) | |
tree | 5853c712c01e5837c8b4cdca2a8eff46eaf90f81 /misc | |
parent | 25e39b4229fb365a605dc4c8f5d6426a77bc08a6 (diff) | |
download | glibc-ffd6023885e71d026f18a8aec5b6610582e44150.zip glibc-ffd6023885e71d026f18a8aec5b6610582e44150.tar.gz glibc-ffd6023885e71d026f18a8aec5b6610582e44150.tar.bz2 |
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.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/tst-preadvwritev-common.c | 49 |
1 files changed, 24 insertions, 25 deletions
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 <http://www.gnu.org/licenses/>. */ +#include <stdio.h> +#include <stdint.h> +#include <string.h> #include <sys/uio.h> #include <sys/stat.h> -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 <support/check.h> +#include <support/temp_file.h> 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 <support/test-driver.c> |