]> granicus.if.org Git - strace/blob - tests/uio.c
Update copyright headers
[strace] / tests / uio.c
1 /*
2  * Copyright (c) 2014-2016 Dmitry V. Levin <ldv@altlinux.org>
3  * Copyright (c) 2014-2018 The strace developers.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8
9 #include "tests.h"
10
11 #if defined(HAVE_PREADV) && defined(HAVE_PWRITEV)
12
13 # include <fcntl.h>
14 # include <unistd.h>
15 # include <sys/uio.h>
16 # include <assert.h>
17
18 int
19 main(void)
20 {
21         const off_t offset = 0xdefaceddeadbeefLL;
22         char buf[4];
23         struct iovec iov = { buf, sizeof(buf) };
24
25         (void) close(0);
26         assert(open("/dev/zero", O_RDONLY) == 0);
27         assert(pread(0, buf, sizeof(buf), offset) == 4);
28         assert(preadv(0, &iov, 1, offset) == 4);
29         assert(!close(0));
30
31         assert(open("/dev/null", O_WRONLY) == 0);
32         assert(pwrite(0, buf, sizeof(buf), offset) == 4);
33         assert(pwritev(0, &iov, 1, offset) == 4);
34         assert(!close(0));
35
36         return 0;
37 }
38
39 #else
40
41 SKIP_MAIN_UNDEFINED("HAVE_PREADV && HAVE_PWRITEV")
42
43 #endif