| 150 | } |
| 151 | |
| 152 | static int __test_nop(struct io_uring *ring, int nr_nops, int min_t, int max_t, |
| 153 | unsigned long long_wait, const char *name) |
| 154 | { |
| 155 | struct __kernel_timespec ts; |
| 156 | struct io_uring_cqe *cqe; |
| 157 | struct timeval tv; |
| 158 | int i, ret; |
| 159 | |
| 160 | for (i = 0; i < nr_nops; i++) { |
| 161 | struct io_uring_sqe *sqe; |
| 162 | |
| 163 | sqe = io_uring_get_sqe(ring); |
| 164 | io_uring_prep_nop(sqe); |
| 165 | } |
| 166 | |
| 167 | if (nr_nops) |
| 168 | io_uring_submit(ring); |
| 169 | |
| 170 | ts.tv_sec = 0; |
| 171 | ts.tv_nsec = long_wait * 1000; |
| 172 | gettimeofday(&tv, NULL); |
| 173 | ret = io_uring_wait_cqes_min_timeout(ring, &cqe, 4, &ts, 50000, NULL); |
| 174 | io_uring_cq_advance(ring, nr_nops); |
| 175 | if (nr_nops) { |
| 176 | if (ret) { |
| 177 | fprintf(stderr, "wait_cqes: %d\n", ret); |
| 178 | return T_EXIT_FAIL; |
| 179 | } |
| 180 | } else { |
| 181 | if (ret != -ETIME) { |
| 182 | fprintf(stderr, "wait_cqes: %d\n", ret); |
| 183 | return T_EXIT_FAIL; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | return time_pass(&tv, min_t, max_t, name); |
| 188 | } |
| 189 | |
| 190 | /* |
| 191 | * Test doing min_wait for N events, where N/2 events are already available |