diff options
author | Craig Tiller <ctiller@google.com> | 2015-01-12 17:44:43 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-01-12 17:44:43 -0800 |
commit | 770f60a4753ec2004165f1b928396399451b04e3 (patch) | |
tree | ab5c85fb57455c50d22f7da0920a72669c42b4ac /test | |
parent | 7c1d7f7a9a11ff1032bee4e145344a3fc8fe2719 (diff) | |
parent | 6ad120e435069656af0394dc0b97744701cac51c (diff) |
Merge github.com:google/grpc into testcpp
Diffstat (limited to 'test')
-rw-r--r-- | test/core/end2end/dualstack_socket_test.c | 70 | ||||
-rwxr-xr-x | test/core/end2end/gen_build_json.py | 1 |
2 files changed, 42 insertions, 29 deletions
diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index b443caa2a6..9837300f67 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -73,26 +73,35 @@ void test_connect(const char *server_host, const char *client_host, int port, cq_verifier *v_client; cq_verifier *v_server; gpr_timespec deadline; + int got_port; - gpr_join_host_port(&client_hostport, client_host, port); gpr_join_host_port(&server_hostport, server_host, port); - gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)", - server_hostport, client_hostport, expect_ok ? "success" : "failure"); /* Create server. */ server_cq = grpc_completion_queue_create(); server = grpc_server_create(server_cq, NULL); - GPR_ASSERT(grpc_server_add_http2_port(server, server_hostport)); + GPR_ASSERT((got_port = grpc_server_add_http2_port(server, server_hostport)) > + 0); + if (port == 0) { + port = got_port; + } else { + GPR_ASSERT(port == got_port); + } grpc_server_start(server); - gpr_free(server_hostport); v_server = cq_verifier_create(server_cq); /* Create client. */ + gpr_join_host_port(&client_hostport, client_host, port); client_cq = grpc_completion_queue_create(); client = grpc_channel_create(client_hostport, NULL); - gpr_free(client_hostport); v_client = cq_verifier_create(client_cq); + gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)", + server_hostport, client_hostport, expect_ok ? "success" : "failure"); + + gpr_free(client_hostport); + gpr_free(server_hostport); + if (expect_ok) { /* Normal deadline, shouldn't be reached. */ deadline = ms_from_now(60000); @@ -170,8 +179,7 @@ void test_connect(const char *server_host, const char *client_host, int port, int main(int argc, char **argv) { int do_ipv6 = 1; - int i; - int port = grpc_pick_unused_port_or_die(); + int fixed_port; grpc_test_init(argc, argv); grpc_init(); @@ -181,30 +189,34 @@ int main(int argc, char **argv) { do_ipv6 = 0; } - for (i = 0; i <= 1; i++) { + 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. */ - grpc_forbid_dualstack_sockets_for_testing = i; - - /* :: 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); - } + 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); + } - /* 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); } - } grpc_shutdown(); diff --git a/test/core/end2end/gen_build_json.py b/test/core/end2end/gen_build_json.py index 50ae21ce69..b91995bc76 100755 --- a/test/core/end2end/gen_build_json.py +++ b/test/core/end2end/gen_build_json.py @@ -80,6 +80,7 @@ def main(): 'end2end_certs', 'grpc_test_util', 'grpc', + 'gpr_test_util', 'gpr' ] } |