* Create a pipe at specific fixed slots, verify the returned fds match * the requested slots, and verify communication works through them. */
| 22 | * the requested slots, and verify communication works through them. |
| 23 | */ |
| 24 | static int test_specific_slots(int slot) |
| 25 | { |
| 26 | struct io_uring ring; |
| 27 | struct io_uring_sqe *sqe; |
| 28 | struct io_uring_cqe *cqe; |
| 29 | char src[32], dst[32]; |
| 30 | int ret, fds[2]; |
| 31 | int i; |
| 32 | |
| 33 | ret = io_uring_queue_init(8, &ring, 0); |
| 34 | if (ret) { |
| 35 | fprintf(stderr, "queue_init: %d\n", ret); |
| 36 | return 1; |
| 37 | } |
| 38 | |
| 39 | ret = io_uring_register_files_sparse(&ring, 20); |
| 40 | if (ret) { |
| 41 | if (ret == -EINVAL) { |
| 42 | no_pipe = 1; |
| 43 | io_uring_queue_exit(&ring); |
| 44 | return 0; |
| 45 | } |
| 46 | fprintf(stderr, "register_files_sparse: %d\n", ret); |
| 47 | goto fail; |
| 48 | } |
| 49 | |
| 50 | fds[0] = fds[1] = -1; |
| 51 | sqe = io_uring_get_sqe(&ring); |
| 52 | io_uring_prep_pipe_direct(sqe, fds, 0, slot); |
| 53 | io_uring_submit(&ring); |
| 54 | |
| 55 | ret = io_uring_wait_cqe(&ring, &cqe); |
| 56 | if (ret) { |
| 57 | fprintf(stderr, "wait: %d\n", ret); |
| 58 | goto fail; |
| 59 | } |
| 60 | if (cqe->res) { |
| 61 | if (cqe->res == -EINVAL) { |
| 62 | no_pipe = 1; |
| 63 | io_uring_queue_exit(&ring); |
| 64 | return 0; |
| 65 | } |
| 66 | fprintf(stderr, "pipe cqe res: %d\n", cqe->res); |
| 67 | goto fail; |
| 68 | } |
| 69 | io_uring_cqe_seen(&ring, cqe); |
| 70 | |
| 71 | /* Verify returned fds are the correct 0-based slot indices */ |
| 72 | if (fds[0] != slot) { |
| 73 | fprintf(stderr, "fds[0]=%d, expected %d\n", fds[0], slot); |
| 74 | goto fail; |
| 75 | } |
| 76 | if (fds[1] != slot + 1) { |
| 77 | fprintf(stderr, "fds[1]=%d, expected %d\n", fds[1], slot + 1); |
| 78 | goto fail; |
| 79 | } |
| 80 | |
| 81 | /* Verify pipe works through the fixed file slots */ |
no test coverage detected