mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-22 10:50:07 +00:00
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.
This commit is contained in:
parent
25e39b4229
commit
ffd6023885
@ -1,3 +1,9 @@
|
||||
2017-04-26 Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
|
||||
* misc/tst-preadvwritev-common.c (do_prepare): Use libsupport
|
||||
expected arguments.
|
||||
(do_test): Adapt to use libsupport.
|
||||
|
||||
2017-05-01 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
* sysdeps/gnu/netinet/tcp.h (TCP_FASTOPEN_CONNECT): New macro.
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user