| 118 | } |
| 119 | |
| 120 | static int test(void) |
| 121 | { |
| 122 | struct io_uring ring; |
| 123 | struct io_uring_buf_ring *br = NULL; |
| 124 | struct io_uring_cqe *cqe; |
| 125 | struct io_uring_sqe *sqe; |
| 126 | struct msghdr msg; |
| 127 | struct sockaddr_in name; |
| 128 | size_t expected_payload = NR_LARGE * LARGE_SZ + NR_SMALL * SMALL_SZ; |
| 129 | uint8_t stream[NR_LARGE * LARGE_SZ + NR_SMALL * SMALL_SZ]; |
| 130 | size_t bid_offset[NR_BUFS] = { 0 }; |
| 131 | size_t stream_cursor = 0; |
| 132 | size_t sent_offset = 0; |
| 133 | void *buf_mem = NULL; |
| 134 | int ret, fds[2]; |
| 135 | int i, seen_bids = 0; |
| 136 | int last_bid = -1; |
| 137 | int ret_val = T_EXIT_FAIL; |
| 138 | |
| 139 | for (i = 0; i < (int) expected_payload; i++) |
| 140 | stream[i] = (uint8_t)(i & 0xff); |
| 141 | |
| 142 | ret = io_uring_queue_init(QD, &ring, 0); |
| 143 | if (ret) { |
| 144 | fprintf(stderr, "queue_init: %d\n", ret); |
| 145 | return T_EXIT_FAIL; |
| 146 | } |
| 147 | |
| 148 | if (setup_buf_ring(&ring, &buf_mem, &br)) |
| 149 | goto out; |
| 150 | if (no_buf_ring) { |
| 151 | ret_val = T_EXIT_SKIP; |
| 152 | goto out; |
| 153 | } |
| 154 | |
| 155 | ret = t_create_socket_pair(fds, true); |
| 156 | if (ret) { |
| 157 | fprintf(stderr, "socket_pair: %d\n", ret); |
| 158 | goto out; |
| 159 | } |
| 160 | |
| 161 | memset(&msg, 0, sizeof(msg)); |
| 162 | msg.msg_name = &name; |
| 163 | msg.msg_namelen = sizeof(name); |
| 164 | |
| 165 | sqe = io_uring_get_sqe(&ring); |
| 166 | io_uring_prep_recvmsg_multishot(sqe, fds[0], &msg, 0); |
| 167 | sqe->flags |= IOSQE_BUFFER_SELECT; |
| 168 | sqe->buf_group = BGID; |
| 169 | sqe->user_data = 1; |
| 170 | |
| 171 | ret = io_uring_submit(&ring); |
| 172 | if (ret != 1) { |
| 173 | fprintf(stderr, "submit: %d\n", ret); |
| 174 | goto out_close; |
| 175 | } |
| 176 | |
| 177 | for (i = 0; i < NR_SENDS; i++) { |
no test coverage detected