Lines Matching full:fd
23 static void test_file_read_write(int fd) in test_file_read_write() argument
27 TEST_ASSERT(read(fd, buf, sizeof(buf)) < 0, in test_file_read_write()
28 "read on a guest_mem fd should fail"); in test_file_read_write()
29 TEST_ASSERT(write(fd, buf, sizeof(buf)) < 0, in test_file_read_write()
30 "write on a guest_mem fd should fail"); in test_file_read_write()
31 TEST_ASSERT(pread(fd, buf, sizeof(buf), 0) < 0, in test_file_read_write()
32 "pread on a guest_mem fd should fail"); in test_file_read_write()
33 TEST_ASSERT(pwrite(fd, buf, sizeof(buf), 0) < 0, in test_file_read_write()
34 "pwrite on a guest_mem fd should fail"); in test_file_read_write()
37 static void test_mmap(int fd, size_t page_size) in test_mmap() argument
41 mem = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); in test_mmap()
45 static void test_file_size(int fd, size_t page_size, size_t total_size) in test_file_size() argument
50 ret = fstat(fd, &sb); in test_file_size()
56 static void test_fallocate(int fd, size_t page_size, size_t total_size) in test_fallocate() argument
60 ret = fallocate(fd, FALLOC_FL_KEEP_SIZE, 0, total_size); in test_fallocate()
63 ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, in test_fallocate()
67 ret = fallocate(fd, FALLOC_FL_KEEP_SIZE, total_size, page_size); in test_fallocate()
70 ret = fallocate(fd, FALLOC_FL_KEEP_SIZE, total_size + page_size, page_size); in test_fallocate()
73 ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, in test_fallocate()
77 ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, in test_fallocate()
81 ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, in test_fallocate()
85 ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, in test_fallocate()
89 ret = fallocate(fd, FALLOC_FL_KEEP_SIZE, page_size, page_size); in test_fallocate()
93 static void test_invalid_punch_hole(int fd, size_t page_size, size_t total_size) in test_invalid_punch_hole() argument
115 ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, in test_invalid_punch_hole()
128 int fd; in test_create_guest_memfd_invalid() local
131 fd = __vm_create_guest_memfd(vm, size, 0); in test_create_guest_memfd_invalid()
132 TEST_ASSERT(fd == -1 && errno == EINVAL, in test_create_guest_memfd_invalid()
138 fd = __vm_create_guest_memfd(vm, page_size, flag); in test_create_guest_memfd_invalid()
139 TEST_ASSERT(fd == -1 && errno == EINVAL, in test_create_guest_memfd_invalid()
177 int fd; in main() local
190 fd = vm_create_guest_memfd(vm, total_size, 0); in main()
192 test_file_read_write(fd); in main()
193 test_mmap(fd, page_size); in main()
194 test_file_size(fd, page_size, total_size); in main()
195 test_fallocate(fd, page_size, total_size); in main()
196 test_invalid_punch_hole(fd, page_size, total_size); in main()
198 close(fd); in main()