* Test multi timeout req with different count */
| 614 | * Test multi timeout req with different count |
| 615 | */ |
| 616 | static int test_multi_timeout_nr(struct io_uring *ring) |
| 617 | { |
| 618 | struct io_uring_sqe *sqe; |
| 619 | struct io_uring_cqe *cqe; |
| 620 | struct __kernel_timespec ts; |
| 621 | int ret, i; |
| 622 | |
| 623 | msec_to_ts(&ts, TIMEOUT_MSEC); |
| 624 | |
| 625 | /* req_1: timeout req, count = 2 */ |
| 626 | sqe = io_uring_get_sqe(ring); |
| 627 | if (!sqe) { |
| 628 | fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__); |
| 629 | goto err; |
| 630 | } |
| 631 | io_uring_prep_timeout(sqe, &ts, 2, 0); |
| 632 | sqe->user_data = 1; |
| 633 | |
| 634 | /* req_2: timeout req, count = 1 */ |
| 635 | sqe = io_uring_get_sqe(ring); |
| 636 | if (!sqe) { |
| 637 | fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__); |
| 638 | goto err; |
| 639 | } |
| 640 | io_uring_prep_timeout(sqe, &ts, 1, 0); |
| 641 | sqe->user_data = 2; |
| 642 | |
| 643 | /* req_3: nop req */ |
| 644 | sqe = io_uring_get_sqe(ring); |
| 645 | if (!sqe) { |
| 646 | fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__); |
| 647 | goto err; |
| 648 | } |
| 649 | io_uring_prep_nop(sqe); |
| 650 | io_uring_sqe_set_data(sqe, (void *) 1); |
| 651 | |
| 652 | ret = io_uring_submit(ring); |
| 653 | if (ret <= 0) { |
| 654 | fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret); |
| 655 | goto err; |
| 656 | } |
| 657 | |
| 658 | /* |
| 659 | * req_2 (count=1) should return without error and req_1 (count=2) |
| 660 | * should timeout. |
| 661 | */ |
| 662 | for (i = 0; i < 3; i++) { |
| 663 | ret = io_uring_wait_cqe(ring, &cqe); |
| 664 | if (ret < 0) { |
| 665 | fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret); |
| 666 | goto err; |
| 667 | } |
| 668 | |
| 669 | switch (i) { |
| 670 | case 0: |
| 671 | /* Should be nop req */ |
| 672 | if (io_uring_cqe_get_data(cqe) != (void *) 1) { |
| 673 | fprintf(stderr, "%s: nop not seen as 1 or 2\n", __FUNCTION__); |
no test coverage detected