strace/tests/uio.c
Dmitry V. Levin f4d6a0d4e1 tests: fix false uio.test failures
* tests/uio.c (main): Use descriptor number 0 in pread/pwrite
and preadv/pwritev syscalls.
* tests/uio.expected: Update regexps.

Reported-by: Lennart Sorensen <lsorense@csclub.uwaterloo.ca>
2015-10-08 22:41:40 +00:00

33 lines
664 B
C

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <fcntl.h>
#include <unistd.h>
#include <sys/uio.h>
#include <assert.h>
int
main(void)
{
#if defined(HAVE_PREADV) && defined(HAVE_PWRITEV)
const off_t offset = 0xdefaceddeadbeefLL;
char buf[4];
struct iovec iov = { buf, sizeof buf };
(void) close(0);
assert(open("/dev/zero", O_RDONLY) == 0);
assert(pread(0, buf, sizeof buf, offset) == 4);
assert(preadv(0, &iov, 1, offset) == 4);
assert(!close(0));
assert(open("/dev/null", O_WRONLY) == 0);
assert(pwrite(0, buf, sizeof buf, offset) == 4);
assert(pwritev(0, &iov, 1, offset) == 4);
assert(!close(0));
return 0;
#else
return 77;
#endif
}