| 366 | } |
| 367 | |
| 368 | static int test(int flags) |
| 369 | { |
| 370 | struct io_uring ring; |
| 371 | int ret; |
| 372 | |
| 373 | ret = io_uring_queue_init(8, &ring, flags); |
| 374 | if (ret == -EINVAL) |
| 375 | return T_EXIT_SKIP; |
| 376 | if (ret) { |
| 377 | fprintf(stderr, "io_uring_queue_init() = %d\n", ret); |
| 378 | return T_EXIT_FAIL; |
| 379 | } |
| 380 | |
| 381 | srand(getpid()); |
| 382 | use_port = (rand() % 61440) + 4096; |
| 383 | use_port = htons(use_port); |
| 384 | use_addr = inet_addr("127.0.0.1"); |
| 385 | |
| 386 | ret = test_connect_with_no_peer(&ring); |
| 387 | if (ret == -1) { |
| 388 | fprintf(stderr, "test_connect_with_no_peer(): failed\n"); |
| 389 | return T_EXIT_FAIL; |
| 390 | } |
| 391 | if (no_connect) |
| 392 | return T_EXIT_SKIP; |
| 393 | |
| 394 | ret = test_connect(&ring, 0); |
| 395 | if (ret == -1) { |
| 396 | fprintf(stderr, "test_connect(): failed\n"); |
| 397 | return T_EXIT_FAIL; |
| 398 | } |
| 399 | |
| 400 | ret = test_connect(&ring, 1); |
| 401 | if (ret == -1) { |
| 402 | fprintf(stderr, "test_connect(): failed\n"); |
| 403 | return T_EXIT_FAIL; |
| 404 | } |
| 405 | |
| 406 | ret = test_connect_timeout(&ring); |
| 407 | if (ret == -1) { |
| 408 | fprintf(stderr, "test_connect_timeout(): failed\n"); |
| 409 | return T_EXIT_FAIL; |
| 410 | } |
| 411 | |
| 412 | io_uring_queue_exit(&ring); |
| 413 | return T_EXIT_PASS; |
| 414 | } |
| 415 | |
| 416 | int main(int argc, char *argv[]) |
| 417 | { |
no test coverage detected