| 442 | } |
| 443 | |
| 444 | int main(int argc, char *argv[]) |
| 445 | { |
| 446 | struct io_uring ring; |
| 447 | struct io_uring_params p = { }; |
| 448 | struct test_ctx ctx; |
| 449 | int ret; |
| 450 | int reg_fds[6]; |
| 451 | |
| 452 | if (argc > 1) |
| 453 | return 0; |
| 454 | |
| 455 | ret = io_uring_queue_init_params(8, &ring, &p); |
| 456 | if (ret) { |
| 457 | fprintf(stderr, "ring setup failed\n"); |
| 458 | return 1; |
| 459 | } |
| 460 | if (!(p.features & IORING_FEAT_FAST_POLL)) { |
| 461 | fprintf(stdout, "No splice support, skipping\n"); |
| 462 | return 0; |
| 463 | } |
| 464 | |
| 465 | ret = init_splice_ctx(&ctx); |
| 466 | if (ret) { |
| 467 | fprintf(stderr, "init failed %i %i\n", ret, errno); |
| 468 | return 1; |
| 469 | } |
| 470 | |
| 471 | check_splice_support(&ring, &ctx); |
| 472 | if (!has_splice) |
| 473 | fprintf(stdout, "skip, doesn't support splice()\n"); |
| 474 | check_tee_support(&ring, &ctx); |
| 475 | if (!has_tee) |
| 476 | fprintf(stdout, "skip, doesn't support tee()\n"); |
| 477 | |
| 478 | ret = test_splice(&ring, &ctx); |
| 479 | if (ret) { |
| 480 | fprintf(stderr, "basic splice tests failed\n"); |
| 481 | return ret; |
| 482 | } |
| 483 | |
| 484 | reg_fds[0] = ctx.real_pipe1[0]; |
| 485 | reg_fds[1] = ctx.real_pipe1[1]; |
| 486 | reg_fds[2] = ctx.real_pipe2[0]; |
| 487 | reg_fds[3] = ctx.real_pipe2[1]; |
| 488 | reg_fds[4] = ctx.real_fd_in; |
| 489 | reg_fds[5] = ctx.real_fd_out; |
| 490 | ret = io_uring_register_files(&ring, reg_fds, 6); |
| 491 | if (ret) { |
| 492 | fprintf(stderr, "%s: register ret=%d\n", __FUNCTION__, ret); |
| 493 | return 1; |
| 494 | } |
| 495 | |
| 496 | /* remap fds to registered */ |
| 497 | ctx.pipe1[0] = 0; |
| 498 | ctx.pipe1[1] = 1; |
| 499 | ctx.pipe2[0] = 2; |
| 500 | ctx.pipe2[1] = 3; |
| 501 | ctx.fd_in = 4; |
nothing calls this directly
no test coverage detected