aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/surface/server_chttp2_test.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2016-02-09 16:32:51 -0800
committerGravatar Craig Tiller <craig.tiller@gmail.com>2016-02-09 16:32:51 -0800
commitf73429901acf8f7c19c9c33539fbdbc7b703d7a4 (patch)
treea23fabb6ef6337610c3e8382e628b0b24aad46ba /test/core/surface/server_chttp2_test.c
parent7e5a9cf32addfaf8e6b73fda27fa1a36d5a3821e (diff)
parentbfe240ea07d09786e26c0e7f75a7dbabcb977c7f (diff)
Merge github.com:grpc/grpc into sceq
Diffstat (limited to 'test/core/surface/server_chttp2_test.c')
-rw-r--r--test/core/surface/server_chttp2_test.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.c
index ec7df6f0e3..84b345bb50 100644
--- a/test/core/surface/server_chttp2_test.c
+++ b/test/core/surface/server_chttp2_test.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -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;
}