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

Function test_fixed_read_write

test/file-register.c:434–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434static int test_fixed_read_write(struct io_uring *ring, int index)
435{
436 struct io_uring_sqe *sqe;
437 struct io_uring_cqe *cqe;
438 struct iovec iov[2];
439 int ret;
440
441 iov[0].iov_base = t_malloc(4096);
442 iov[0].iov_len = 4096;
443 memset(iov[0].iov_base, 0x5a, 4096);
444
445 iov[1].iov_base = t_malloc(4096);
446 iov[1].iov_len = 4096;
447
448 sqe = io_uring_get_sqe(ring);
449 if (!sqe) {
450 fprintf(stderr, "%s: failed to get sqe\n", __FUNCTION__);
451 return 1;
452 }
453 io_uring_prep_writev(sqe, index, &iov[0], 1, 0);
454 sqe->flags |= IOSQE_FIXED_FILE;
455 sqe->user_data = 1;
456
457 ret = io_uring_submit(ring);
458 if (ret != 1) {
459 fprintf(stderr, "%s: got %d, wanted 1\n", __FUNCTION__, ret);
460 return 1;
461 }
462
463 ret = io_uring_wait_cqe(ring, &cqe);
464 if (ret < 0) {
465 fprintf(stderr, "%s: io_uring_wait_cqe=%d\n", __FUNCTION__, ret);
466 return 1;
467 }
468 if (cqe->res != 4096) {
469 fprintf(stderr, "%s: write cqe->res=%d\n", __FUNCTION__, cqe->res);
470 return 1;
471 }
472 io_uring_cqe_seen(ring, cqe);
473
474 sqe = io_uring_get_sqe(ring);
475 if (!sqe) {
476 fprintf(stderr, "%s: failed to get sqe\n", __FUNCTION__);
477 return 1;
478 }
479 io_uring_prep_readv(sqe, index, &iov[1], 1, 0);
480 sqe->flags |= IOSQE_FIXED_FILE;
481 sqe->user_data = 2;
482
483 ret = io_uring_submit(ring);
484 if (ret != 1) {
485 fprintf(stderr, "%s: got %d, wanted 1\n", __FUNCTION__, ret);
486 return 1;
487 }
488
489 ret = io_uring_wait_cqe(ring, &cqe);
490 if (ret < 0) {
491 fprintf(stderr, "%s: io_uring_wait_cqe=%d\n", __FUNCTION__, ret);

Callers 2

test_hugeFunction · 0.85
test_skipFunction · 0.85

Calls 3

t_mallocFunction · 0.85
io_uring_submitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected