aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/security
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-08-27 07:36:12 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-08-27 07:36:12 -0700
commit99d7b661bede39143d1be6040fb67c81b8117ae3 (patch)
tree8396780e126a8db360700b182ed2722eef2527a9 /test/core/security
parentb6c912b75b14cebc0527ccbac91964af347e7df7 (diff)
Revert "Refactor Endpoint API"
Diffstat (limited to 'test/core/security')
-rw-r--r--test/core/security/secure_endpoint_test.c55
1 files changed, 46 insertions, 9 deletions
diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c
index c76ddcd194..a8368fc842 100644
--- a/test/core/security/secure_endpoint_test.c
+++ b/test/core/security/secure_endpoint_test.c
@@ -135,26 +135,62 @@ static grpc_endpoint_test_config configs[] = {
secure_endpoint_create_fixture_tcp_socketpair_leftover, clean_up},
};
-static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
- grpc_endpoint_test_fixture f = config.create_fixture(slice_size);
- gpr_slice_buffer incoming;
+static void verify_leftover(void *user_data, gpr_slice *slices, size_t nslices,
+ grpc_endpoint_cb_status error) {
gpr_slice s =
gpr_slice_from_copied_string("hello world 12345678900987654321");
+
+ GPR_ASSERT(error == GRPC_ENDPOINT_CB_OK);
+ GPR_ASSERT(nslices == 1);
+
+ GPR_ASSERT(0 == gpr_slice_cmp(s, slices[0]));
+ gpr_slice_unref(slices[0]);
+ gpr_slice_unref(s);
+ *(int *)user_data = 1;
+}
+
+static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
+ grpc_endpoint_test_fixture f = config.create_fixture(slice_size);
+ int verified = 0;
gpr_log(GPR_INFO, "Start test left over");
- gpr_slice_buffer_init(&incoming);
- GPR_ASSERT(grpc_endpoint_read(f.client_ep, &incoming, NULL) ==
- GRPC_ENDPOINT_DONE);
- GPR_ASSERT(incoming.count == 1);
- GPR_ASSERT(0 == gpr_slice_cmp(s, incoming.slices[0]));
+ grpc_endpoint_notify_on_read(f.client_ep, verify_leftover, &verified);
+ GPR_ASSERT(verified == 1);
grpc_endpoint_shutdown(f.client_ep);
grpc_endpoint_shutdown(f.server_ep);
grpc_endpoint_destroy(f.client_ep);
grpc_endpoint_destroy(f.server_ep);
+ clean_up();
+}
+
+static void destroy_early(void *user_data, gpr_slice *slices, size_t nslices,
+ grpc_endpoint_cb_status error) {
+ grpc_endpoint_test_fixture *f = user_data;
+ gpr_slice s =
+ gpr_slice_from_copied_string("hello world 12345678900987654321");
+
+ GPR_ASSERT(error == GRPC_ENDPOINT_CB_OK);
+ GPR_ASSERT(nslices == 1);
+
+ grpc_endpoint_shutdown(f->client_ep);
+ grpc_endpoint_destroy(f->client_ep);
+
+ GPR_ASSERT(0 == gpr_slice_cmp(s, slices[0]));
+ gpr_slice_unref(slices[0]);
gpr_slice_unref(s);
- gpr_slice_buffer_destroy(&incoming);
+}
+/* test which destroys the ep before finishing reading */
+static void test_destroy_ep_early(grpc_endpoint_test_config config,
+ size_t slice_size) {
+ grpc_endpoint_test_fixture f = config.create_fixture(slice_size);
+ gpr_log(GPR_INFO, "Start test destroy early");
+
+ grpc_endpoint_notify_on_read(f.client_ep, destroy_early, &f);
+
+ grpc_endpoint_shutdown(f.server_ep);
+ grpc_endpoint_destroy(f.server_ep);
clean_up();
}
@@ -167,6 +203,7 @@ int main(int argc, char **argv) {
grpc_pollset_init(&g_pollset);
grpc_endpoint_tests(configs[0], &g_pollset);
test_leftover(configs[1], 1);
+ test_destroy_ep_early(configs[1], 1);
grpc_pollset_shutdown(&g_pollset, destroy_pollset, &g_pollset);
grpc_iomgr_shutdown();