| 294 | } |
| 295 | |
| 296 | static int test_drain(void) |
| 297 | { |
| 298 | struct io_uring ring; |
| 299 | int ret, i, fd[2]; |
| 300 | struct io_uring_sqe *sqe; |
| 301 | struct io_uring_cqe *cqe; |
| 302 | struct iovec iovecs[128]; |
| 303 | char buff[ARRAY_SIZE(iovecs)]; |
| 304 | |
| 305 | ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER | |
| 306 | IORING_SETUP_DEFER_TASKRUN | |
| 307 | IORING_SETUP_TASKRUN_FLAG); |
| 308 | CHECK(!ret); |
| 309 | |
| 310 | for (i = 0; i < ARRAY_SIZE(iovecs); i++) { |
| 311 | iovecs[i].iov_base = &buff[i]; |
| 312 | iovecs[i].iov_len = 1; |
| 313 | } |
| 314 | |
| 315 | ret = t_create_socket_pair(fd, true); |
| 316 | CHECK(!ret); |
| 317 | |
| 318 | sqe = io_uring_get_sqe(&ring); |
| 319 | io_uring_prep_writev(sqe, fd[1], &iovecs[0], ARRAY_SIZE(iovecs), 0); |
| 320 | sqe->flags |= IOSQE_IO_DRAIN; |
| 321 | io_uring_submit(&ring); |
| 322 | |
| 323 | for (i = 0; i < ARRAY_SIZE(iovecs); i++) |
| 324 | iovecs[i].iov_base = NULL; |
| 325 | |
| 326 | CHECK(io_uring_wait_cqe(&ring, &cqe) == 0); |
| 327 | CHECK(cqe->res == 128); |
| 328 | |
| 329 | close(fd[0]); |
| 330 | close(fd[1]); |
| 331 | io_uring_queue_exit(&ring); |
| 332 | return 0; |
| 333 | } |
| 334 | |
| 335 | int main(int argc, char *argv[]) |
| 336 | { |
no test coverage detected