aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2016-02-02 23:22:48 -0800
committerGravatar yang-g <yangg@google.com>2016-02-02 23:22:48 -0800
commit70fa0da7f128bb2f5d6e4962352a7b2b4279e106 (patch)
tree5f3d538c8cb9983a04f2c4927dd5e836544f1a45
parent9356b47903b7cee3ea5f1325dc69574179f75edf (diff)
add a test
-rw-r--r--test/core/surface/server_chttp2_test.c28
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;
}