| 43 | } |
| 44 | |
| 45 | static int test(bool defer_taskrun) |
| 46 | { |
| 47 | struct io_uring_cqe *cqe; |
| 48 | struct io_uring_sqe *sqe; |
| 49 | struct io_uring ring; |
| 50 | int pipe1[2]; |
| 51 | int ret, i; |
| 52 | |
| 53 | if (pipe(pipe1) != 0) { |
| 54 | perror("pipe"); |
| 55 | return T_EXIT_FAIL; |
| 56 | } |
| 57 | |
| 58 | struct io_uring_params params = { |
| 59 | /* cheat using SINGLE_ISSUER existence to know if this behaviour |
| 60 | * is updated |
| 61 | */ |
| 62 | .flags = IORING_SETUP_CQSIZE | IORING_SETUP_SINGLE_ISSUER, |
| 63 | .cq_entries = 2 |
| 64 | }; |
| 65 | |
| 66 | if (defer_taskrun) |
| 67 | params.flags |= IORING_SETUP_SINGLE_ISSUER | |
| 68 | IORING_SETUP_DEFER_TASKRUN; |
| 69 | |
| 70 | ret = io_uring_queue_init_params(2, &ring, ¶ms); |
| 71 | if (ret) |
| 72 | return T_EXIT_SKIP; |
| 73 | |
| 74 | sqe = io_uring_get_sqe(&ring); |
| 75 | if (!sqe) { |
| 76 | fprintf(stderr, "get sqe failed\n"); |
| 77 | return T_EXIT_FAIL; |
| 78 | } |
| 79 | io_uring_prep_poll_multishot(sqe, pipe1[0], POLLIN); |
| 80 | io_uring_sqe_set_data64(sqe, 1); |
| 81 | |
| 82 | if (io_uring_cq_ready(&ring)) { |
| 83 | fprintf(stderr, "unexpected cqe\n"); |
| 84 | return T_EXIT_FAIL; |
| 85 | } |
| 86 | |
| 87 | for (i = 0; i < 2; i++) { |
| 88 | sqe = io_uring_get_sqe(&ring); |
| 89 | io_uring_prep_nop(sqe); |
| 90 | io_uring_sqe_set_data64(sqe, 2); |
| 91 | io_uring_submit(&ring); |
| 92 | } |
| 93 | |
| 94 | do { |
| 95 | errno = 0; |
| 96 | ret = write(pipe1[1], "foo", 3); |
| 97 | } while (ret == -1 && errno == EINTR); |
| 98 | |
| 99 | if (ret <= 0) { |
| 100 | fprintf(stderr, "write failed: %d\n", errno); |
| 101 | return T_EXIT_FAIL; |
| 102 | } |
no test coverage detected