aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-06-15 08:02:38 -0700
committerGravatar Craig Tiller <ctiller@google.com>2016-06-15 08:02:38 -0700
commit95123ceb9bc1b4683518a75ad1a0fb8c0b962ab0 (patch)
tree2d5791ebf81947a64a5a261c6dbccd86c929091f /test/core
parent8fb6c924b54775be2d9fea52a39cc930460558de (diff)
Add a test for multiple endpoint shutdowns
Diffstat (limited to 'test/core')
-rw-r--r--test/core/iomgr/endpoint_tests.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c
index 6d15ecf141..b9331fd8fe 100644
--- a/test/core/iomgr/endpoint_tests.c
+++ b/test/core/iomgr/endpoint_tests.c
@@ -253,6 +253,41 @@ static void read_and_write_test(grpc_endpoint_test_config config,
grpc_exec_ctx_finish(&exec_ctx);
}
+static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
+ GPR_ASSERT(!success);
+ ++*(int *)arg;
+}
+
+static void multiple_shutdown_test(grpc_endpoint_test_config config) {
+ grpc_endpoint_test_fixture f = begin_test(config, "read_and_write_test", 128);
+ int fail_count = 0;
+
+ gpr_slice_buffer incoming;
+ gpr_slice_buffer_init(&incoming);
+
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_endpoint_read(&exec_ctx, f.client_ep, &incoming,
+ grpc_closure_create(must_fail, &fail_count));
+ grpc_exec_ctx_flush(&exec_ctx);
+ GPR_ASSERT(fail_count == 0);
+ grpc_endpoint_shutdown(&exec_ctx, f.client_ep);
+ grpc_exec_ctx_flush(&exec_ctx);
+ GPR_ASSERT(fail_count == 1);
+ grpc_endpoint_read(&exec_ctx, f.client_ep, &incoming,
+ grpc_closure_create(must_fail, &fail_count));
+ grpc_exec_ctx_flush(&exec_ctx);
+ GPR_ASSERT(fail_count == 2);
+ grpc_endpoint_shutdown(&exec_ctx, f.client_ep);
+ grpc_exec_ctx_flush(&exec_ctx);
+ GPR_ASSERT(fail_count == 2);
+
+ gpr_slice_buffer_destroy(&incoming);
+
+ grpc_endpoint_destroy(&exec_ctx, f.client_ep);
+ grpc_endpoint_destroy(&exec_ctx, f.server_ep);
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+
void grpc_endpoint_tests(grpc_endpoint_test_config config,
grpc_pollset *pollset, gpr_mu *mu) {
size_t i;
@@ -264,5 +299,6 @@ void grpc_endpoint_tests(grpc_endpoint_test_config config,
for (i = 1; i < 1000; i = GPR_MAX(i + 1, i * 5 / 4)) {
read_and_write_test(config, 40320, i, i, 0);
}
+ multiple_shutdown_test(config);
g_pollset = NULL;
}