blob: aac123a63f4e93d1ea5c355c1236188f30bf3f23 [file] [log] [blame]
Mike Frysinger97ca0272014-08-11 02:52:08 -04001#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
Dmitry V. Levincc3d5912014-04-16 23:28:29 +00004#include <fcntl.h>
5#include <unistd.h>
6#include <sys/uio.h>
7#include <assert.h>
8
9int
10main(void)
11{
Mike Frysinger97ca0272014-08-11 02:52:08 -040012#if defined(HAVE_PREADV) && defined(HAVE_PWRITEV)
Dmitry V. Levincc3d5912014-04-16 23:28:29 +000013 const off_t offset = 0xdefaceddeadbeefLL;
14 int fd;
15 char buf[4];
16 struct iovec iov = { buf, sizeof buf };
17
18 assert((fd = open("/dev/zero", O_RDONLY)) >= 0);
19 assert(pread(fd, buf, sizeof buf, offset) == 4);
20 assert(preadv(fd, &iov, 1, offset) == 4);
21 assert(!close(fd));
22
23 assert((fd = open("/dev/null", O_WRONLY)) >= 0);
24 assert(pwrite(fd, buf, sizeof buf, offset) == 4);
25 assert(pwritev(fd, &iov, 1, offset) == 4);
26 assert(!close(fd));
27
28 return 0;
Mike Frysinger97ca0272014-08-11 02:52:08 -040029#else
30 return 77;
31#endif
Dmitry V. Levincc3d5912014-04-16 23:28:29 +000032}