| 23 | } while (0) |
| 24 | |
| 25 | static int pipe_bug(void) |
| 26 | { |
| 27 | struct io_uring ring; |
| 28 | struct io_uring_sqe *sqe; |
| 29 | struct io_uring_cqe *cqe; |
| 30 | char buf[1024]; |
| 31 | int ret, fds[2]; |
| 32 | struct __kernel_timespec to = { |
| 33 | .tv_sec = 1 |
| 34 | }; |
| 35 | |
| 36 | ret = io_uring_queue_init(8, &ring, 0); |
| 37 | /* can hit -ENOMEM due to repeated ring creation and teardowns */ |
| 38 | if (ret == -ENOMEM) { |
| 39 | usleep(1000); |
| 40 | return 0; |
| 41 | } else if (ret) { |
| 42 | fprintf(stderr, "ring_init: %d\n", ret); |
| 43 | return 1; |
| 44 | } |
| 45 | |
| 46 | CHECK(pipe(fds) == 0); |
| 47 | |
| 48 | /* WRITE */ |
| 49 | sqe = io_uring_get_sqe(&ring); |
| 50 | CHECK(sqe); |
| 51 | io_uring_prep_write(sqe, fds[1], "foobar", strlen("foobar"), 0); /* or -1 */ |
| 52 | CHECK(io_uring_submit(&ring) == 1); |
| 53 | CHECK(io_uring_wait_cqe(&ring, &cqe) == 0); |
| 54 | |
| 55 | io_uring_cqe_seen(&ring, cqe); |
| 56 | |
| 57 | /* CLOSE */ |
| 58 | sqe = io_uring_get_sqe(&ring); |
| 59 | CHECK(sqe); |
| 60 | io_uring_prep_close(sqe, fds[1]); |
| 61 | CHECK(io_uring_submit(&ring) == 1); |
| 62 | CHECK(io_uring_wait_cqe_timeout(&ring, &cqe, &to) == 0); |
| 63 | io_uring_cqe_seen(&ring, cqe); |
| 64 | |
| 65 | /* READ */ |
| 66 | sqe = io_uring_get_sqe(&ring); |
| 67 | CHECK(sqe); |
| 68 | io_uring_prep_read(sqe, fds[0], buf, sizeof(buf), 0); /* or -1 */ |
| 69 | CHECK(io_uring_submit(&ring) == 1); |
| 70 | CHECK(io_uring_wait_cqe_timeout(&ring, &cqe, &to) == 0); |
| 71 | io_uring_cqe_seen(&ring, cqe); |
| 72 | memset(buf, 0, sizeof(buf)); |
| 73 | |
| 74 | /* READ */ |
| 75 | sqe = io_uring_get_sqe(&ring); |
| 76 | CHECK(sqe); |
| 77 | io_uring_prep_read(sqe, fds[0], buf, sizeof(buf), 0); /* or -1 */ |
| 78 | CHECK(io_uring_submit(&ring) == 1); |
| 79 | CHECK(io_uring_wait_cqe_timeout(&ring, &cqe, &to) == 0); |
| 80 | io_uring_cqe_seen(&ring, cqe); |
| 81 | |
| 82 | close(fds[0]); |
no test coverage detected