| 103 | } |
| 104 | |
| 105 | static int test_reuse(int argc, char *argv[], int split, int async) |
| 106 | { |
| 107 | struct thread_data data; |
| 108 | struct io_uring_params p = { }; |
| 109 | int fd1, fd2, ret, i; |
| 110 | struct timeval tv; |
| 111 | pthread_t thread; |
| 112 | char *fname1 = ".reuse.1"; |
| 113 | int do_unlink = 1; |
| 114 | void *tret; |
| 115 | |
| 116 | ret = io_uring_queue_init_params(32, &ring, &p); |
| 117 | if (ret) { |
| 118 | fprintf(stderr, "io_uring_queue_init: %d\n", ret); |
| 119 | return 1; |
| 120 | } |
| 121 | |
| 122 | if (!(p.features & IORING_FEAT_SUBMIT_STABLE)) { |
| 123 | fprintf(stdout, "FEAT_SUBMIT_STABLE not there, skipping\n"); |
| 124 | io_uring_queue_exit(&ring); |
| 125 | no_stable = 1; |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | if (argc > 1) { |
| 130 | fname1 = argv[1]; |
| 131 | do_unlink = 0; |
| 132 | } else { |
| 133 | t_create_file(fname1, FILE_SIZE); |
| 134 | } |
| 135 | |
| 136 | fd1 = open(fname1, O_RDONLY); |
| 137 | if (do_unlink) |
| 138 | unlink(fname1); |
| 139 | if (fd1 < 0) { |
| 140 | if (errno == EPERM || errno == EACCES) |
| 141 | return T_EXIT_SKIP; |
| 142 | perror("open fname1"); |
| 143 | goto err; |
| 144 | } |
| 145 | |
| 146 | t_create_file(".reuse.2", FILE_SIZE); |
| 147 | fd2 = open(".reuse.2", O_RDONLY); |
| 148 | unlink(".reuse.2"); |
| 149 | if (fd2 < 0) { |
| 150 | perror("open .reuse.2"); |
| 151 | goto err; |
| 152 | } |
| 153 | |
| 154 | data.fd1 = fd1; |
| 155 | data.fd2 = fd2; |
| 156 | data.do_exit = 0; |
| 157 | pthread_create(&thread, NULL, flusher, &data); |
| 158 | usleep(10000); |
| 159 | |
| 160 | gettimeofday(&tv, NULL); |
| 161 | for (i = 0; i < 1000; i++) { |
| 162 | ret = prep(fd1, str1, split, async); |
no test coverage detected