| 619 | } |
| 620 | |
| 621 | static int run_tests(int is_udp) |
| 622 | { |
| 623 | int ret, eagain_hit; |
| 624 | |
| 625 | nr_msgs = NR_MIN_MSGS; |
| 626 | |
| 627 | /* test basic send bundle first */ |
| 628 | ret = test(0, 0, NULL, 0, 0); |
| 629 | if (ret) { |
| 630 | fprintf(stderr, "test a failed\n"); |
| 631 | return T_EXIT_FAIL; |
| 632 | } |
| 633 | if (no_send_mshot) |
| 634 | return T_EXIT_SKIP; |
| 635 | |
| 636 | /* test recv bundle */ |
| 637 | ret = test(0, 0, NULL, 0, 1); |
| 638 | if (ret) { |
| 639 | fprintf(stderr, "test b failed\n"); |
| 640 | return T_EXIT_FAIL; |
| 641 | } |
| 642 | |
| 643 | /* test bundling recv and send */ |
| 644 | ret = test(0, 0, NULL, 1, 1); |
| 645 | if (ret) { |
| 646 | fprintf(stderr, "test c failed\n"); |
| 647 | return T_EXIT_FAIL; |
| 648 | } |
| 649 | |
| 650 | /* test bundling with full socket */ |
| 651 | ret = test(1, 1000000, &eagain_hit, 1, 1); |
| 652 | if (ret) { |
| 653 | fprintf(stderr, "test d failed\n"); |
| 654 | return T_EXIT_FAIL; |
| 655 | } |
| 656 | |
| 657 | /* test bundling with almost full socket */ |
| 658 | ret = test(1, eagain_hit - (nr_msgs / 2), NULL, 1, 1); |
| 659 | if (ret) { |
| 660 | fprintf(stderr, "test e failed\n"); |
| 661 | return T_EXIT_FAIL; |
| 662 | } |
| 663 | |
| 664 | /* test recv bundle with almost full socket */ |
| 665 | ret = test(1, eagain_hit - (nr_msgs / 2), NULL, 0, 1); |
| 666 | if (ret) { |
| 667 | fprintf(stderr, "test f failed\n"); |
| 668 | return T_EXIT_FAIL; |
| 669 | } |
| 670 | |
| 671 | if (is_udp) |
| 672 | return T_EXIT_PASS; |
| 673 | |
| 674 | /* test send bundle with almost full socket */ |
| 675 | ret = test(1, eagain_hit - (nr_msgs / 2), &eagain_hit, 1, 0); |
| 676 | if (ret) { |
| 677 | fprintf(stderr, "test g failed\n"); |
| 678 | return T_EXIT_FAIL; |