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

Function test_invalid

test/read-mshot.c:426–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426static int test_invalid(int async)
427{
428 struct io_uring_buf_ring *br;
429 struct io_uring_params p = { };
430 struct io_uring_sqe *sqe;
431 struct io_uring_cqe *cqe;
432 struct io_uring ring;
433 char fname[32] = ".mshot.%d.XXXXXX";
434 int ret, fd;
435 char *buf;
436
437 p.flags = IORING_SETUP_CQSIZE;
438 p.cq_entries = NR_BUFS;
439 ret = io_uring_queue_init_params(1, &ring, &p);
440 if (ret) {
441 fprintf(stderr, "ring setup failed: %d\n", ret);
442 return 1;
443 }
444
445 fd = mkstemp(fname);
446 if (fd < 0) {
447 perror("mkstemp");
448 return 1;
449 }
450 unlink(fname);
451
452 if (posix_memalign((void **) &buf, 4096, BUF_SIZE))
453 return 1;
454
455 br = io_uring_setup_buf_ring(&ring, 1, BUF_BGID, 0, &ret);
456 if (!br) {
457 fprintf(stderr, "Buffer ring register failed %d\n", ret);
458 return 1;
459 }
460
461 io_uring_buf_ring_add(br, buf, BUF_SIZE, 1, BR_MASK, 0);
462 io_uring_buf_ring_advance(br, 1);
463
464 sqe = io_uring_get_sqe(&ring);
465 /* len == 0 means just use the defined provided buffer length */
466 io_uring_prep_read_multishot(sqe, fd, 0, 0, BUF_BGID);
467 if (async)
468 sqe->flags |= IOSQE_ASYNC;
469
470 ret = io_uring_submit(&ring);
471 if (ret != 1) {
472 fprintf(stderr, "submit: %d\n", ret);
473 return 1;
474 }
475
476 ret = io_uring_wait_cqe(&ring, &cqe);
477 if (ret) {
478 fprintf(stderr, "wait cqe failed %d\n", ret);
479 return 1;
480 }
481 if (cqe->flags & IORING_CQE_F_MORE) {
482 fprintf(stderr, "MORE flag set unexpected %d\n", cqe->flags);
483 return 1;

Callers 1

mainFunction · 0.70

Calls 6

io_uring_setup_buf_ringFunction · 0.85
io_uring_submitFunction · 0.85
io_uring_free_buf_ringFunction · 0.85
io_uring_queue_exitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected