pull/5032/head
yang-g 9 years ago
parent 9356b47903
commit 70fa0da7f1
  1. 28
      test/core/surface/server_chttp2_test.c

@ -32,7 +32,14 @@
*/ */
#include <grpc/grpc.h> #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/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" #include "test/core/util/test_config.h"
void test_unparsable_target(void) { void test_unparsable_target(void) {
@ -40,10 +47,31 @@ void test_unparsable_target(void) {
GPR_ASSERT(port == 0); 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) { int main(int argc, char **argv) {
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
grpc_init(); grpc_init();
test_unparsable_target(); test_unparsable_target();
test_add_same_port_twice();
grpc_shutdown(); grpc_shutdown();
return 0; return 0;
} }

Loading…
Cancel
Save