| 14 | } |
| 15 | |
| 16 | int main(int argc, char *argv[]) |
| 17 | { |
| 18 | struct io_uring_sqe *sqe; |
| 19 | struct io_uring_cqe *cqe; |
| 20 | struct io_uring_params p; |
| 21 | struct io_uring ring; |
| 22 | int ret, data; |
| 23 | |
| 24 | if (argc > 1) |
| 25 | return T_EXIT_SKIP; |
| 26 | |
| 27 | signal(SIGALRM, sig_alrm); |
| 28 | |
| 29 | memset(&p, 0, sizeof(p)); |
| 30 | p.sq_thread_idle = 100; |
| 31 | p.flags = IORING_SETUP_SQPOLL; |
| 32 | ret = t_create_ring_params(4, &ring, &p); |
| 33 | if (ret == T_SETUP_SKIP) |
| 34 | return T_EXIT_SKIP; |
| 35 | else if (ret < 0) |
| 36 | return T_EXIT_FAIL; |
| 37 | |
| 38 | /* make sure sq thread is sleeping at this point */ |
| 39 | usleep(150000); |
| 40 | alarm(1); |
| 41 | |
| 42 | sqe = io_uring_get_sqe(&ring); |
| 43 | if (!sqe) { |
| 44 | fprintf(stderr, "sqe get failed\n"); |
| 45 | return T_EXIT_FAIL; |
| 46 | } |
| 47 | |
| 48 | io_uring_prep_nop(sqe); |
| 49 | io_uring_sqe_set_data(sqe, (void *) (unsigned long) 42); |
| 50 | io_uring_submit_and_wait(&ring, 1); |
| 51 | |
| 52 | ret = io_uring_peek_cqe(&ring, &cqe); |
| 53 | if (ret) { |
| 54 | fprintf(stderr, "cqe get failed\n"); |
| 55 | return 1; |
| 56 | } |
| 57 | |
| 58 | data = (unsigned long) io_uring_cqe_get_data(cqe); |
| 59 | if (data != 42) { |
| 60 | fprintf(stderr, "invalid data: %d\n", data); |
| 61 | return T_EXIT_FAIL; |
| 62 | } |
| 63 | |
| 64 | return T_EXIT_PASS; |
| 65 | } |
nothing calls this directly
no test coverage detected