diff options
-rw-r--r-- | test/core/surface/server_chttp2_test.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.c index ec7df6f0e3..0a3652a27a 100644 --- a/test/core/surface/server_chttp2_test.c +++ b/test/core/surface/server_chttp2_test.c @@ -32,7 +32,14 @@ */ #include <grpc/grpc.h> +#include <grpc/grpc_security.h> +#include <grpc/support/alloc.h> +#include <grpc/support/host_port.h> #include <grpc/support/log.h> +#include <grpc/support/time.h> +#include "src/core/security/credentials.h" +#include "src/core/tsi/fake_transport_security.h" +#include "test/core/util/port.h" #include "test/core/util/test_config.h" void test_unparsable_target(void) { @@ -40,10 +47,31 @@ void test_unparsable_target(void) { GPR_ASSERT(port == 0); } +void test_add_same_port_twice() { + int port = grpc_pick_unused_port_or_die(); + char *addr = NULL; + grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_server *server = grpc_server_create(NULL, NULL); + grpc_server_credentials *fake_creds = + grpc_fake_transport_security_server_credentials_create(); + gpr_join_host_port(&addr, "localhost", port); + GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds)); + GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds) == 0); + + grpc_server_credentials_release(fake_creds); + gpr_free(addr); + grpc_server_shutdown_and_notify(server, cq, NULL); + grpc_completion_queue_pluck(cq, NULL, gpr_inf_future(GPR_CLOCK_REALTIME), + NULL); + grpc_server_destroy(server); + grpc_completion_queue_destroy(cq); +} + int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); test_unparsable_target(); + test_add_same_port_twice(); grpc_shutdown(); return 0; } |