MCPcopy Create free account
hub / github.com/axboe/liburing / main

Function main

test/io_uring_enter.c:177–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177int main(int argc, char **argv)
178{
179 int ret;
180 unsigned int status = 0;
181 struct io_uring ring;
182 struct io_uring_sq *sq = &ring.sq;
183 unsigned ktail, mask, index;
184 unsigned sq_entries;
185 unsigned completed, dropped;
186 struct io_uring_params p;
187
188 if (argc > 1)
189 return T_EXIT_SKIP;
190
191 memset(&p, 0, sizeof(p));
192 ret = t_io_uring_init_sqarray(IORING_MAX_ENTRIES, &ring, &p);
193 if (ret == -ENOMEM)
194 ret = t_io_uring_init_sqarray(IORING_MAX_ENTRIES_FALLBACK,
195 &ring, &p);
196 if (ret < 0) {
197 fprintf(stderr, "queue_init: %s\n", strerror(-ret));
198 exit(T_EXIT_FAIL);
199 }
200 mask = sq->ring_mask;
201
202 /* invalid flags */
203 status |= try_io_uring_enter(ring.ring_fd, 1, 0, ~0U, NULL, -EINVAL);
204
205 /* invalid fd, EBADF */
206 status |= try_io_uring_enter(-1, 0, 0, 0, NULL, -EBADF);
207
208 /* valid, non-ring fd, EOPNOTSUPP */
209 status |= try_io_uring_enter(0, 0, 0, 0, NULL, -EOPNOTSUPP);
210
211 /* to_submit: 0, flags: 0; should get back 0. */
212 status |= try_io_uring_enter(ring.ring_fd, 0, 0, 0, NULL, 0);
213
214 /* fill the sq ring */
215 sq_entries = ring.sq.ring_entries;
216 submit_io(&ring, sq_entries);
217 ret = io_uring_enter(ring.ring_fd, 0, sq_entries,
218 IORING_ENTER_GETEVENTS, NULL);
219 if (ret < 0) {
220 fprintf(stderr, "io_uring_enter: %s\n", strerror(-ret));
221 status = 1;
222 } else {
223 /*
224 * This is a non-IOPOLL ring, which means that io_uring_enter
225 * should not return until min_complete events are available
226 * in the completion queue.
227 */
228 completed = *ring.cq.ktail - *ring.cq.khead;
229 if (completed != sq_entries) {
230 fprintf(stderr, "Submitted %u I/Os, but only got %u completions\n",
231 sq_entries, completed);
232 status = 1;
233 }
234 reap_events(&ring, sq_entries);

Callers

nothing calls this directly

Calls 5

t_io_uring_init_sqarrayFunction · 0.85
try_io_uring_enterFunction · 0.85
submit_ioFunction · 0.85
io_uring_enterFunction · 0.85
reap_eventsFunction · 0.70

Tested by

no test coverage detected