| 1 |
/* COVERAGE: writev */ |
| 2 |
#define _BSD_SOURCE |
| 3 |
#define _DEFAULT_SOURCE |
| 4 |
#include <sys/types.h> |
| 5 |
#include <sys/stat.h> |
| 6 |
#include <fcntl.h> |
| 7 |
#include <stdlib.h> |
| 8 |
#include <unistd.h> |
| 9 |
#include <linux/unistd.h> |
| 10 |
#include <sys/uio.h> |
| 11 |
#include <string.h> |
| 12 |
#include <sys/mman.h> |
| 13 |
|
| 14 |
int main() |
| 15 |
{ |
| 16 |
int fd; |
| 17 |
struct iovec wr_iovec[3]; |
| 18 |
char buf[64]; |
| 19 |
|
| 20 |
mlockall(MCL_CURRENT); |
| 21 |
|
| 22 |
fd = open("foobar1", O_WRONLY|O_CREAT, 0666); |
| 23 |
//staptest// [[[[open (!!!!openat (AT_FDCWD, ]]]]"foobar1", O_WRONLY|O_CREAT[[[[.O_LARGEFILE]]]]?, 0666) = NNNN |
| 24 |
|
| 25 |
memset(buf, (int)'B', sizeof(buf)); |
| 26 |
wr_iovec[0].iov_base = buf; |
| 27 |
wr_iovec[0].iov_len = -1; |
| 28 |
wr_iovec[1].iov_base = NULL; |
| 29 |
wr_iovec[1].iov_len = 0; |
| 30 |
wr_iovec[2].iov_base = NULL; |
| 31 |
wr_iovec[2].iov_len = 0; |
| 32 |
writev(fd, wr_iovec, 1); |
| 33 |
//staptest// writev (NNNN, XXXX, 1) = -NNNN (EINVAL) |
| 34 |
|
| 35 |
writev(-1, wr_iovec, 1); |
| 36 |
//staptest// writev (-1, XXXX, 1) = -NNNN (EBADF) |
| 37 |
|
| 38 |
writev(fd, wr_iovec, -1); |
| 39 |
//staptest// writev (NNNN, XXXX, -1) = -NNNN (EINVAL) |
| 40 |
|
| 41 |
writev(fd, wr_iovec, 0); |
| 42 |
//staptest// writev (NNNN, XXXX, 0) = 0 |
| 43 |
|
| 44 |
wr_iovec[0].iov_base = buf; |
| 45 |
wr_iovec[0].iov_len = sizeof(buf); |
| 46 |
wr_iovec[1].iov_base = buf; |
| 47 |
wr_iovec[1].iov_len = 0; |
| 48 |
wr_iovec[2].iov_base = NULL; |
| 49 |
wr_iovec[2].iov_len = 0; |
| 50 |
writev(fd, wr_iovec, 3); |
| 51 |
//staptest// writev (NNNN, XXXX, 3) = 64 |
| 52 |
|
| 53 |
close (fd); |
| 54 |
//staptest// close (NNNN) = 0 |
| 55 |
|
| 56 |
return 0; |
| 57 |
} |