Add a test for multiple endpoint shutdowns

pull/6897/head
Craig Tiller 9 years ago
parent 8fb6c924b5
commit 95123ceb9b
  1. 36
      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;
}

Loading…
Cancel
Save