aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--test/core/end2end/dualstack_socket_test.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c
index 62676d01e0..5e2c80af5a 100644
--- a/test/core/end2end/dualstack_socket_test.c
+++ b/test/core/end2end/dualstack_socket_test.c
@@ -75,6 +75,10 @@ void test_connect(const char *server_host, const char *client_host, int port,
gpr_timespec deadline;
int got_port;
+ if (port == 0) {
+ port = grpc_pick_unused_port_or_die();
+ }
+
gpr_join_host_port(&server_hostport, server_host, port);
/* Create server. */
@@ -179,7 +183,6 @@ void test_connect(const char *server_host, const char *client_host, int port,
int main(int argc, char **argv) {
int do_ipv6 = 1;
- int fixed_port;
grpc_test_init(argc, argv);
grpc_init();
@@ -189,32 +192,28 @@ int main(int argc, char **argv) {
do_ipv6 = 0;
}
- for (fixed_port = 0; fixed_port <= 1; fixed_port++) {
- int port = fixed_port ? grpc_pick_unused_port_or_die() : 0;
-
/* For coverage, test with and without dualstack sockets. */
- for (grpc_forbid_dualstack_sockets_for_testing = 0;
- grpc_forbid_dualstack_sockets_for_testing <= 1;
- grpc_forbid_dualstack_sockets_for_testing++) {
- /* :: and 0.0.0.0 are handled identically. */
- test_connect("::", "127.0.0.1", port, 1);
- test_connect("::", "::ffff:127.0.0.1", port, 1);
- test_connect("::", "localhost", port, 1);
- test_connect("0.0.0.0", "127.0.0.1", port, 1);
- test_connect("0.0.0.0", "::ffff:127.0.0.1", port, 1);
- test_connect("0.0.0.0", "localhost", port, 1);
- if (do_ipv6) {
- test_connect("::", "::1", port, 1);
- test_connect("0.0.0.0", "::1", port, 1);
- }
-
- /* These only work when the families agree. */
- test_connect("127.0.0.1", "127.0.0.1", port, 1);
- if (do_ipv6) {
- test_connect("::1", "::1", port, 1);
- test_connect("::1", "127.0.0.1", port, 0);
- test_connect("127.0.0.1", "::1", port, 0);
- }
+ for (grpc_forbid_dualstack_sockets_for_testing = 0;
+ grpc_forbid_dualstack_sockets_for_testing <= 1;
+ grpc_forbid_dualstack_sockets_for_testing++) {
+ /* :: and 0.0.0.0 are handled identically. */
+ test_connect("::", "127.0.0.1", 0, 1);
+ test_connect("::", "::ffff:127.0.0.1", 0, 1);
+ test_connect("::", "localhost", 0, 1);
+ test_connect("0.0.0.0", "127.0.0.1", 0, 1);
+ test_connect("0.0.0.0", "::ffff:127.0.0.1", 0, 1);
+ test_connect("0.0.0.0", "localhost", 0, 1);
+ if (do_ipv6) {
+ test_connect("::", "::1", 0, 1);
+ test_connect("0.0.0.0", "::1", 0, 1);
+ }
+
+ /* These only work when the families agree. */
+ test_connect("127.0.0.1", "127.0.0.1", 0, 1);
+ if (do_ipv6) {
+ test_connect("::1", "::1", 0, 1);
+ test_connect("::1", "127.0.0.1", 0, 0);
+ test_connect("127.0.0.1", "::1", 0, 0);
}
}