| 1 |
/* COVERAGE: read write */ |
| 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 <sys/syscall.h> |
| 12 |
#include <sys/mman.h> |
| 13 |
|
| 14 |
#define STRING1 "red" |
| 15 |
#define STRING2 "green" |
| 16 |
#define STRING3 "blue" |
| 17 |
int main() |
| 18 |
{ |
| 19 |
int fd; |
| 20 |
loff_t res; |
| 21 |
char buf[64], buf1[32], buf2[32], buf3[32]; |
| 22 |
|
| 23 |
mlockall(MCL_CURRENT); |
| 24 |
|
| 25 |
fd = open("foobar1", O_WRONLY|O_CREAT, 0666); |
| 26 |
//staptest// [[[[open (!!!!openat (AT_FDCWD, ]]]]"foobar1", O_WRONLY|O_CREAT[[[[.O_LARGEFILE]]]]?, 0666) = NNNN |
| 27 |
|
| 28 |
write(fd, "Hello world", 11); |
| 29 |
//staptest// write (NNNN, "Hello world", 11) = 11 |
| 30 |
|
| 31 |
write(fd, "Hello world abcdefghijklmnopqrstuvwxyz 01234567890123456789", 59); |
| 32 |
//staptest// write (NNNN, "Hello world abcdefghijklmnopqrstuvwxyz 012345"..., 59) = 59 |
| 33 |
|
| 34 |
write(-1, "Hello world", 11); |
| 35 |
//staptest// write (-1, "Hello world", 11) = NNNN |
| 36 |
|
| 37 |
write(fd, (void *)-1, 11); |
| 38 |
#ifdef __s390__ |
| 39 |
//staptest// write (NNNN, 0x[7]?[f]+, 11) = NNNN |
| 40 |
#else |
| 41 |
//staptest// write (NNNN, 0x[f]+, 11) = NNNN |
| 42 |
#endif |
| 43 |
|
| 44 |
/* We need to be careful when writing -1 bytes. */ |
| 45 |
write(-1, NULL, -1); |
| 46 |
#if __WORDSIZE == 64 |
| 47 |
//staptest// write (-1, *0x0, 18446744073709551615) = -NNNN |
| 48 |
#else |
| 49 |
//staptest// write (-1, *0x0, 4294967295) = -NNNN |
| 50 |
#endif |
| 51 |
|
| 52 |
close (fd); |
| 53 |
//staptest// close (NNNN) = 0 |
| 54 |
|
| 55 |
fd = open("foobar1", O_RDONLY); |
| 56 |
//staptest// [[[[open (!!!!openat (AT_FDCWD, ]]]]"foobar1", O_RDONLY[[[[.O_LARGEFILE]]]]?) = NNNN |
| 57 |
|
| 58 |
read(fd, buf, 11); |
| 59 |
//staptest// read (NNNN, XXXX, 11) = 11 |
| 60 |
|
| 61 |
read(fd, buf, 50); |
| 62 |
//staptest// read (NNNN, XXXX, 50) = 50 |
| 63 |
|
| 64 |
read(-1, buf, 50); |
| 65 |
//staptest// read (-1, XXXX, 50) = NNNN |
| 66 |
|
| 67 |
read(fd, (void *)-1, 50); |
| 68 |
#ifdef __s390__ |
| 69 |
//staptest// read (NNNN, 0x[7]?[f]+, 50) = NNNN |
| 70 |
#else |
| 71 |
//staptest// read (NNNN, 0x[f]+, 50) = NNNN |
| 72 |
#endif |
| 73 |
|
| 74 |
/* We need to be careful when reading -1 bytes. */ |
| 75 |
read(-1, NULL, -1); |
| 76 |
#if __WORDSIZE == 64 |
| 77 |
//staptest// read (-1, 0x0, 18446744073709551615) = -NNNN |
| 78 |
#else |
| 79 |
//staptest// read (-1, 0x0, 4294967295) = -NNNN |
| 80 |
#endif |
| 81 |
|
| 82 |
close (fd); |
| 83 |
//staptest// close (NNNN) = 0 |
| 84 |
|
| 85 |
return 0; |
| 86 |
} |