7 #include "../../memcheck.h"
9 int main(int argc
, char **argv
)
15 fd_in
= open("copy_file_range_source", O_CREAT
| O_RDWR
, 0644);
17 perror("open copy_file_range_source");
21 if (write(fd_in
, "foo bar\n", 8) != 8) {
22 perror("writing to the copy_file_range_source");
25 lseek(fd_in
, 0, SEEK_SET
);
27 if (fstat(fd_in
, &stat
) == -1) {
34 fd_out
= open("copy_file_range_dest", O_CREAT
| O_WRONLY
| O_TRUNC
, 0644);
36 perror("open copy_file_range_dest");
40 /* Check copy_file_range called with the correct arguments works. */
42 ret
= copy_file_range(fd_in
, NULL
, fd_out
, NULL
, len
, 0);
44 perror("copy_file_range");
51 /* Check valgrind will produce expected warnings for the
52 various wrong arguments. */
54 void *t
= 0; VALGRIND_MAKE_MEM_UNDEFINED (&t
, sizeof (void *));
55 void *z
= (void *) -1;
57 ret
= copy_file_range(fd_in
, t
, fd_out
, NULL
, len
, 0);
58 ret
= copy_file_range(fd_in
, NULL
, fd_out
, z
, len
, 0);
59 ret
= copy_file_range(- 1, NULL
, - 1, NULL
, len
, 0);
64 unlink("copy_file_range_source");
65 unlink("copy_file_range_dest");