| 700 | } |
| 701 | |
| 702 | static int test_rem_buf_single(int to_rem) |
| 703 | { |
| 704 | struct io_uring_sqe *sqe; |
| 705 | struct io_uring_cqe *cqe; |
| 706 | struct io_uring ring; |
| 707 | int ret, expected; |
| 708 | int bgid = 1; |
| 709 | |
| 710 | if (no_buf_select) |
| 711 | return 0; |
| 712 | |
| 713 | ret = io_uring_queue_init(64, &ring, 0); |
| 714 | if (ret) { |
| 715 | fprintf(stderr, "ring create failed: %d\n", ret); |
| 716 | return 1; |
| 717 | } |
| 718 | |
| 719 | ret = provide_buffers_iovec(&ring, bgid); |
| 720 | if (ret) |
| 721 | return ret; |
| 722 | |
| 723 | expected = (to_rem > BUFFERS) ? BUFFERS : to_rem; |
| 724 | |
| 725 | sqe = io_uring_get_sqe(&ring); |
| 726 | io_uring_prep_remove_buffers(sqe, to_rem, bgid); |
| 727 | |
| 728 | ret = io_uring_submit(&ring); |
| 729 | if (ret != 1) { |
| 730 | fprintf(stderr, "submit: %d\n", ret); |
| 731 | return -1; |
| 732 | } |
| 733 | |
| 734 | ret = io_uring_wait_cqe(&ring, &cqe); |
| 735 | if (ret) { |
| 736 | fprintf(stderr, "wait_cqe=%d\n", ret); |
| 737 | return 1; |
| 738 | } |
| 739 | if (cqe->res != expected) { |
| 740 | fprintf(stderr, "cqe->res=%d, expected=%d\n", cqe->res, expected); |
| 741 | return 1; |
| 742 | } |
| 743 | io_uring_cqe_seen(&ring, cqe); |
| 744 | |
| 745 | io_uring_queue_exit(&ring); |
| 746 | return ret; |
| 747 | } |
| 748 | |
| 749 | static int test_io_link(const char *file) |
| 750 | { |
no test coverage detected