| 221 | } |
| 222 | |
| 223 | static int test_flag(void) |
| 224 | { |
| 225 | struct io_uring ring; |
| 226 | int ret; |
| 227 | int fd; |
| 228 | struct io_uring_cqe *cqe; |
| 229 | |
| 230 | ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER | |
| 231 | IORING_SETUP_DEFER_TASKRUN | |
| 232 | IORING_SETUP_TASKRUN_FLAG); |
| 233 | CHECK(!ret); |
| 234 | |
| 235 | fd = eventfd(0, EFD_NONBLOCK); |
| 236 | CHECK(fd >= 0); |
| 237 | |
| 238 | io_uring_prep_poll_add(io_uring_get_sqe(&ring), fd, POLLIN); |
| 239 | io_uring_submit(&ring); |
| 240 | CHECK(!can_read(fd)); /* poll should not have completed */ |
| 241 | |
| 242 | eventfd_trigger(fd); |
| 243 | CHECK(can_read(fd)); |
| 244 | |
| 245 | /* should not have processed the poll cqe yet */ |
| 246 | CHECK(io_uring_cq_ready(&ring) == 0); |
| 247 | |
| 248 | /* flag should be set */ |
| 249 | CHECK(IO_URING_READ_ONCE(*ring.sq.kflags) & IORING_SQ_TASKRUN); |
| 250 | |
| 251 | /* Specifically peek, knowing we have only no cqe |
| 252 | * but because the flag is set, liburing should try and get more |
| 253 | */ |
| 254 | ret = io_uring_peek_cqe(&ring, &cqe); |
| 255 | |
| 256 | CHECK(ret == 0 && cqe); |
| 257 | CHECK(!(IO_URING_READ_ONCE(*ring.sq.kflags) & IORING_SQ_TASKRUN)); |
| 258 | |
| 259 | close(fd); |
| 260 | io_uring_queue_exit(&ring); |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | static int test_ring_shutdown(void) |
| 265 | { |
no test coverage detected