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

Function test_one_read

test/buf-ring.c:257–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257static int test_one_read(int fd, int bgid, struct io_uring *ring)
258{
259 int ret;
260 struct io_uring_cqe *cqe;
261 struct io_uring_sqe *sqe;
262
263 sqe = io_uring_get_sqe(ring);
264 if (!sqe) {
265 fprintf(stderr, "get sqe failed\n");
266 return -1;
267 }
268
269 io_uring_prep_read(sqe, fd, NULL, 1, 0);
270 sqe->flags |= IOSQE_BUFFER_SELECT;
271 sqe->buf_group = bgid;
272 ret = io_uring_submit(ring);
273 if (ret <= 0) {
274 fprintf(stderr, "sqe submit failed: %d\n", ret);
275 return -1;
276 }
277
278 ret = io_uring_wait_cqe(ring, &cqe);
279 if (ret < 0) {
280 fprintf(stderr, "wait completion %d\n", ret);
281 return -1;
282 }
283 ret = cqe->res;
284 io_uring_cqe_seen(ring, cqe);
285
286 if (ret == -ENOBUFS)
287 return ret;
288
289 if (ret != 1) {
290 fprintf(stderr, "read result %d\n", ret);
291 return -1;
292 }
293
294 return cqe->flags >> 16;
295}
296
297static int test_running(int bgid, int entries, int loops, int use_mmap)
298{

Callers 1

test_runningFunction · 0.85

Calls 2

io_uring_submitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected