aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
Diffstat (limited to 'test/core')
-rw-r--r--test/core/bad_client/BUILD34
-rw-r--r--test/core/bad_client/bad_client.c17
-rwxr-xr-xtest/core/bad_client/generate_tests.bzl68
-rw-r--r--test/core/bad_ssl/BUILD34
-rwxr-xr-xtest/core/bad_ssl/generate_tests.bzl52
-rw-r--r--test/core/channel/channel_args_test.c27
-rw-r--r--test/core/channel/channel_stack_test.c9
-rw-r--r--test/core/client_channel/lb_policies_test.c125
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.c23
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_test.c4
-rw-r--r--test/core/client_channel/resolvers/sockaddr_resolver_test.c15
-rw-r--r--test/core/client_channel/set_initial_connect_string_test.c5
-rw-r--r--test/core/compression/algorithm_test.c10
-rw-r--r--test/core/compression/message_compress_test.c59
-rw-r--r--test/core/end2end/BUILD80
-rw-r--r--test/core/end2end/bad_server_response_test.c14
-rw-r--r--test/core/end2end/connection_refused_test.c6
-rw-r--r--test/core/end2end/end2end_nosec_tests.c16
-rwxr-xr-xtest/core/end2end/end2end_test.sh33
-rw-r--r--test/core/end2end/end2end_tests.c16
-rw-r--r--test/core/end2end/fake_resolver.c23
-rw-r--r--test/core/end2end/fixtures/h2_census.c12
-rw-r--r--test/core/end2end/fixtures/h2_compress.c14
-rw-r--r--test/core/end2end/fixtures/h2_load_reporting.c6
-rw-r--r--test/core/end2end/fixtures/h2_oauth2.c6
-rw-r--r--test/core/end2end/fixtures/h2_ssl.c6
-rw-r--r--test/core/end2end/fixtures/h2_ssl_cert.c6
-rw-r--r--test/core/end2end/fixtures/h2_ssl_proxy.c12
-rw-r--r--test/core/end2end/fixtures/http_proxy.c44
-rw-r--r--test/core/end2end/fuzzers/BUILD56
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.c50
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/08455b3ef9d516deb8155d8db7d51c43ce0ff07abin0 -> 426 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/0d19e60f4eb1b729e272dd5dec68e8b67f03a5f4bin0 -> 167 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/14064ac4844c709b247a4345a92d8be9766785c4bin0 -> 316 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/1901234bd7c9cb6ee19ff8b17179c481bdc7c5f2bin0 -> 345 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/20ff1f8d5d34cb01d58aa334dc46a6644e6e1d12bin0 -> 199 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/2378c3f1206f20711468391ce739116ffe58374bbin0 -> 216 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/40640a91fda4e4e42d3063a28b9ffbba1b8c3701bin0 -> 226 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/49f564289c79de9e0342f8b0821a167bc8c5ec00bin0 -> 183 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/507865c4a5ce880b80400d93fa85def2682581cbbin0 -> 314 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/5f2fdb01d8ff632803ca2b732a7c088c6843d7d3bin0 -> 349 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/61de97a9d6c4b082602c02277d8d763921f5f95bbin0 -> 175 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/62b039b8a318cc08471f13629da08c68c414d8e7bin0 -> 176 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/641739453f7d4d3b55a1c7b79bed7da6dfd62ae0bin0 -> 175 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/6589505362ffb5164a3c7cb1b9feadcddfba44e9bin0 -> 33 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/724f5400f19e5a0be97022341c39eeaaaffeb390bin0 -> 336 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/7254b9ff59ab3fcf345effdabbc25ebd2e907b23bin0 -> 167 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/784d6f5c093ab5360670173ce001e1a446f95822bin0 -> 202 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/79328fdc89d0af0e38da089dab062fd3ea5aae59bin0 -> 474 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/7a2569f4daf4480ad142cb4ee7c675bed82db74cbin0 -> 547 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/87a300cd25d2e57745bd00499d4d2352a10a2fa1bin0 -> 35 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/8a1c629910280f8beebb88687696de98da988eccbin0 -> 41 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/8ff7b1568d2da2e4196c2e28617e1911d62021e6bin0 -> 371 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/982f375b183d984958667461c7767206062eb4cbbin0 -> 429 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/98739af631223fa05ad88f1e63a52052a9bb4b1cbin0 -> 178 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/a78bca1ef8829d720dd5dedac3a9d4d12684da34bin0 -> 373 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/ac763d89466ebfad676e75be0076831c03fe2a5dbin0 -> 473 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/b165523f699e6ae9b2ad15873b9d56465d1af546bin0 -> 224 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/b2a5ec3ef40c68d594638218e3c943a479f82215bin0 -> 474 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/b92b1c5e0dba009a9516e7185f5df019c62c5cc9bin0 -> 414 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/c5cd7af16e7bc0049445d5a0b92a3d4b7e5e3533bin0 -> 425 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/crash-da39a3ee5e6b4b0d3255bfef95601890afd807090
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/e28ffd8c2816f12f6395805199c792d1718191dfbin0 -> 371 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/ec823f4018389e64a99f6580277fba28df6bd136bin0 -> 226 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/ee2c1ac1e668f22836cf25a59495e778b0e2c7a8bin0 -> 338 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/ee6855178435d2046d8763ecae46e1e0a71a95f4bin0 -> 178 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/eeb310d91038cb02862e187e68c5d6578233485bbin0 -> 46 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/f07bc2907c95f2aeb79ca60e2ad826e13b848f45bin0 -> 351 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/fb655905396b768cf3ff015afdb0b564dae2cdfdbin0 -> 349 bytes
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/fdb038087233cd176746558875932029f779221dbin0 -> 371 bytes
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer.c2
-rw-r--r--test/core/end2end/fuzzers/server_fuzzer.c2
-rwxr-xr-xtest/core/end2end/gen_build_yaml.py2
-rwxr-xr-xtest/core/end2end/generate_tests.bzl194
-rw-r--r--test/core/end2end/goaway_server_test.c10
-rw-r--r--test/core/end2end/invalid_call_argument_test.c24
-rw-r--r--test/core/end2end/tests/cancel_after_accept.c6
-rw-r--r--test/core/end2end/tests/compressed_payload.c24
-rw-r--r--test/core/end2end/tests/connectivity.c10
-rw-r--r--test/core/end2end/tests/filter_call_init_fails.c11
-rw-r--r--test/core/end2end/tests/filter_causes_close.c22
-rw-r--r--test/core/end2end/tests/filter_latency.c11
-rw-r--r--test/core/end2end/tests/load_reporting_hook.c6
-rw-r--r--test/core/end2end/tests/max_message_length.c17
-rw-r--r--test/core/end2end/tests/payload.c2
-rw-r--r--test/core/end2end/tests/simple_delayed_request.c19
-rw-r--r--test/core/end2end/tests/write_buffering.c291
-rw-r--r--test/core/end2end/tests/write_buffering_at_end.c280
-rw-r--r--test/core/http/BUILD49
-rw-r--r--test/core/http/httpcli_test.c22
-rw-r--r--test/core/http/httpscli_test.c22
-rw-r--r--test/core/internal_api_canaries/iomgr.c13
-rw-r--r--test/core/iomgr/combiner_test.c27
-rw-r--r--test/core/iomgr/endpoint_pair_test.c3
-rw-r--r--test/core/iomgr/endpoint_tests.c22
-rw-r--r--test/core/iomgr/ev_epoll_linux_test.c9
-rw-r--r--test/core/iomgr/fd_conservation_posix_test.c6
-rw-r--r--test/core/iomgr/fd_posix_test.c28
-rw-r--r--test/core/iomgr/resolve_address_test.c55
-rw-r--r--test/core/iomgr/resource_quota_test.c22
-rw-r--r--test/core/iomgr/tcp_client_posix_test.c7
-rw-r--r--test/core/iomgr/tcp_posix_test.c35
-rw-r--r--test/core/iomgr/tcp_server_posix_test.c6
-rw-r--r--test/core/iomgr/timer_list_test.c43
-rw-r--r--test/core/iomgr/udp_server_test.c5
-rw-r--r--test/core/json/BUILD41
-rw-r--r--test/core/memory_usage/client.c316
-rw-r--r--test/core/memory_usage/memory_usage_test.c93
-rw-r--r--test/core/memory_usage/server.c321
-rw-r--r--test/core/nanopb/BUILD49
-rw-r--r--test/core/security/b64_test.c44
-rw-r--r--test/core/security/create_jwt.c2
-rw-r--r--test/core/security/credentials_test.c141
-rw-r--r--test/core/security/json_token_test.c13
-rw-r--r--test/core/security/jwt_verifier_test.c106
-rw-r--r--test/core/security/oauth2_utils.c3
-rw-r--r--test/core/security/secure_endpoint_test.c12
-rw-r--r--test/core/security/ssl_server_fuzzer.c29
-rw-r--r--test/core/security/verify_jwt.c6
-rw-r--r--test/core/support/BUILD154
-rw-r--r--test/core/support/backoff_test.c91
-rw-r--r--test/core/support/string_test.c16
-rw-r--r--test/core/surface/byte_buffer_reader_test.c10
-rw-r--r--test/core/surface/channel_create_test.c12
-rw-r--r--test/core/surface/concurrent_connectivity_test.c8
-rw-r--r--test/core/surface/lame_client_test.c6
-rw-r--r--test/core/surface/public_headers_must_be_c89.c2
-rw-r--r--test/core/surface/secure_channel_create_test.c4
-rw-r--r--test/core/surface/sequential_connectivity_test.c7
-rw-r--r--test/core/surface/server_chttp2_test.c5
-rw-r--r--test/core/transport/chttp2/BUILD40
-rw-r--r--test/core/transport/chttp2/bin_decoder_test.c103
-rw-r--r--test/core/transport/chttp2/hpack_encoder_test.c81
-rw-r--r--test/core/transport/chttp2/hpack_parser_fuzzer_test.c8
-rw-r--r--test/core/transport/chttp2/hpack_parser_test.c33
-rw-r--r--test/core/transport/chttp2/hpack_table_test.c54
-rw-r--r--test/core/transport/connectivity_state_test.c9
-rw-r--r--test/core/transport/metadata_test.c110
-rw-r--r--test/core/util/BUILD87
-rwxr-xr-xtest/core/util/fuzzer_one_entry_runner.sh33
-rw-r--r--test/core/util/grpc_fuzzer.bzl43
-rw-r--r--test/core/util/memory_counters.h2
-rw-r--r--test/core/util/mock_endpoint.c10
-rw-r--r--test/core/util/passthru_endpoint.c21
-rw-r--r--test/core/util/port_server_client.c28
-rw-r--r--test/core/util/reconnect_server.c1
-rw-r--r--test/core/util/test_tcp_server.c6
147 files changed, 3639 insertions, 710 deletions
diff --git a/test/core/bad_client/BUILD b/test/core/bad_client/BUILD
new file mode 100644
index 0000000000..6b06955efe
--- /dev/null
+++ b/test/core/bad_client/BUILD
@@ -0,0 +1,34 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+licenses(["notice"]) # 3-clause BSD
+
+load(":generate_tests.bzl", "grpc_bad_client_tests")
+
+grpc_bad_client_tests()
diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c
index 07fcd995d7..a84086804c 100644
--- a/test/core/bad_client/bad_client.c
+++ b/test/core/bad_client/bad_client.c
@@ -33,15 +33,18 @@
#include "test/core/bad_client/bad_client.h"
+#include <stdio.h>
+
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/thd.h>
-#include <stdio.h>
+
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/http_server_filter.h"
#include "src/core/lib/iomgr/endpoint_pair.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/support/murmur_hash.h"
#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/completion_queue.h"
@@ -117,7 +120,7 @@ void grpc_run_bad_client_test(
grpc_resource_quota *resource_quota =
grpc_resource_quota_create("bad_client_test");
sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 65536);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
/* Create server, completion events */
a.server = grpc_server_create(NULL, NULL);
@@ -148,7 +151,8 @@ void grpc_run_bad_client_test(
grpc_slice_buffer_init(&outgoing);
grpc_slice_buffer_add(&outgoing, slice);
- grpc_closure_init(&done_write_closure, done_write, &a);
+ grpc_closure_init(&done_write_closure, done_write, &a,
+ grpc_schedule_on_exec_ctx);
/* Write data */
grpc_endpoint_write(&exec_ctx, sfd.client, &outgoing, &done_write_closure);
@@ -175,13 +179,14 @@ void grpc_run_bad_client_test(
grpc_slice_buffer_init(&args.incoming);
gpr_event_init(&args.read_done);
grpc_closure read_done_closure;
- grpc_closure_init(&read_done_closure, read_done, &args);
+ grpc_closure_init(&read_done_closure, read_done, &args,
+ grpc_schedule_on_exec_ctx);
grpc_endpoint_read(&exec_ctx, sfd.client, &args.incoming,
&read_done_closure);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(
gpr_event_wait(&args.read_done, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)));
- grpc_slice_buffer_destroy(&args.incoming);
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &args.incoming);
}
// Shutdown.
grpc_endpoint_shutdown(&exec_ctx, sfd.client);
@@ -194,7 +199,7 @@ void grpc_run_bad_client_test(
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(a.server);
grpc_completion_queue_destroy(a.cq);
- grpc_slice_buffer_destroy(&outgoing);
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &outgoing);
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
diff --git a/test/core/bad_client/generate_tests.bzl b/test/core/bad_client/generate_tests.bzl
new file mode 100755
index 0000000000..694ddeeab6
--- /dev/null
+++ b/test/core/bad_client/generate_tests.bzl
@@ -0,0 +1,68 @@
+#!/usr/bin/env python2.7
+# Copyright 2015, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+"""Generates the appropriate build.json data for all the bad_client tests."""
+
+
+def test_options():
+ return struct()
+
+
+# maps test names to options
+BAD_CLIENT_TESTS = {
+ 'badreq': test_options(),
+ 'connection_prefix': test_options(),
+ 'headers': test_options(),
+ 'initial_settings_frame': test_options(),
+ 'head_of_line_blocking': test_options(),
+ 'large_metadata': test_options(),
+ 'server_registered_method': test_options(),
+ 'simple_request': test_options(),
+ 'window_overflow': test_options(),
+ 'unknown_frame': test_options(),
+}
+
+def grpc_bad_client_tests():
+ native.cc_library(
+ name = 'bad_client_test',
+ srcs = ['bad_client.c'],
+ hdrs = ['bad_client.h'],
+ copts = ['-std=c99'],
+ deps = ['//test/core/util:grpc_test_util', '//:grpc', '//:gpr', '//test/core/end2end:cq_verifier']
+ )
+ for t, topt in BAD_CLIENT_TESTS.items():
+ native.cc_test(
+ name = '%s_bad_client_test' % t,
+ srcs = ['tests/%s.c' % t],
+ deps = [':bad_client_test'],
+ copts = ['-std=c99'],
+ )
+
diff --git a/test/core/bad_ssl/BUILD b/test/core/bad_ssl/BUILD
new file mode 100644
index 0000000000..288788a52d
--- /dev/null
+++ b/test/core/bad_ssl/BUILD
@@ -0,0 +1,34 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+licenses(["notice"]) # 3-clause BSD
+
+load(":generate_tests.bzl", "grpc_bad_ssl_tests")
+
+grpc_bad_ssl_tests()
diff --git a/test/core/bad_ssl/generate_tests.bzl b/test/core/bad_ssl/generate_tests.bzl
new file mode 100755
index 0000000000..78474bc1ca
--- /dev/null
+++ b/test/core/bad_ssl/generate_tests.bzl
@@ -0,0 +1,52 @@
+#!/usr/bin/env python2.7
+# Copyright 2015, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+def test_options():
+ return struct()
+
+
+# maps test names to options
+BAD_SSL_TESTS = ['cert', 'alpn']
+
+def grpc_bad_ssl_tests():
+ native.cc_library(
+ name = 'bad_ssl_test_server',
+ srcs = ['server_common.c'],
+ hdrs = ['server_common.h'],
+ deps = ['//test/core/util:grpc_test_util', '//:grpc', '//test/core/end2end:ssl_test_data']
+ )
+ for t in BAD_SSL_TESTS:
+ native.cc_test(
+ name = 'bad_ssl_%s_server' % t,
+ srcs = ['servers/%s.c' % t],
+ deps = [':bad_ssl_test_server'],
+ )
+
diff --git a/test/core/channel/channel_args_test.c b/test/core/channel/channel_args_test.c
index d3eb969f09..b2c41652a4 100644
--- a/test/core/channel/channel_args_test.c
+++ b/test/core/channel/channel_args_test.c
@@ -37,10 +37,12 @@
#include <grpc/support/useful.h>
#include "src/core/lib/channel/channel_args.h"
-
+#include "src/core/lib/iomgr/exec_ctx.h"
#include "test/core/util/test_config.h"
static void test_create(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+
grpc_arg arg_int;
grpc_arg arg_string;
grpc_arg to_add[2];
@@ -68,10 +70,12 @@ static void test_create(void) {
GPR_ASSERT(strcmp(ch_args->args[1].value.string, arg_string.value.string) ==
0);
- grpc_channel_args_destroy(ch_args);
+ grpc_channel_args_destroy(&exec_ctx, ch_args);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_set_compression_algorithm(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_channel_args *ch_args;
ch_args =
@@ -81,10 +85,12 @@ static void test_set_compression_algorithm(void) {
GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM) == 0);
GPR_ASSERT(ch_args->args[0].type == GRPC_ARG_INTEGER);
- grpc_channel_args_destroy(ch_args);
+ grpc_channel_args_destroy(&exec_ctx, ch_args);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_compression_algorithm_states(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate;
unsigned states_bitset;
size_t i;
@@ -100,10 +106,10 @@ static void test_compression_algorithm_states(void) {
/* disable gzip and deflate */
ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
- &ch_args, GRPC_COMPRESS_GZIP, 0);
+ &exec_ctx, &ch_args, GRPC_COMPRESS_GZIP, 0);
GPR_ASSERT(ch_args == ch_args_wo_gzip);
ch_args_wo_gzip_deflate = grpc_channel_args_compression_algorithm_set_state(
- &ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0);
+ &exec_ctx, &ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
@@ -118,7 +124,7 @@ static void test_compression_algorithm_states(void) {
/* re-enabled gzip only */
ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
- &ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1);
+ &exec_ctx, &ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
@@ -131,7 +137,8 @@ static void test_compression_algorithm_states(void) {
}
}
- grpc_channel_args_destroy(ch_args);
+ grpc_channel_args_destroy(&exec_ctx, ch_args);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_set_socket_mutator(void) {
@@ -144,7 +151,11 @@ static void test_set_socket_mutator(void) {
GPR_ASSERT(strcmp(ch_args->args[0].key, GRPC_ARG_SOCKET_MUTATOR) == 0);
GPR_ASSERT(ch_args->args[0].type == GRPC_ARG_POINTER);
- grpc_channel_args_destroy(ch_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, ch_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
}
int main(int argc, char **argv) {
diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c
index 0840820cca..080c56f134 100644
--- a/test/core/channel/channel_stack_test.c
+++ b/test/core/channel/channel_stack_test.c
@@ -41,9 +41,9 @@
#include "test/core/util/test_config.h"
-static void channel_init_func(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+static grpc_error *channel_init_func(grpc_exec_ctx *exec_ctx,
+ grpc_channel_element *elem,
+ grpc_channel_element_args *args) {
GPR_ASSERT(args->channel_args->num_args == 1);
GPR_ASSERT(args->channel_args->args[0].type == GRPC_ARG_INTEGER);
GPR_ASSERT(0 == strcmp(args->channel_args->args[0].key, "test_key"));
@@ -51,6 +51,7 @@ static void channel_init_func(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(args->is_first);
GPR_ASSERT(args->is_last);
*(int *)(elem->channel_data) = 0;
+ return GRPC_ERROR_NONE;
}
static grpc_error *call_init_func(grpc_exec_ctx *exec_ctx,
@@ -156,8 +157,8 @@ static void test_create_channel_stack(void) {
GRPC_CHANNEL_STACK_UNREF(&exec_ctx, channel_stack, "done");
+ GRPC_MDSTR_UNREF(&exec_ctx, path);
grpc_exec_ctx_finish(&exec_ctx);
- GRPC_MDSTR_UNREF(path);
}
int main(int argc, char **argv) {
diff --git a/test/core/client_channel/lb_policies_test.c b/test/core/client_channel/lb_policies_test.c
index 95595d7c51..f46982a387 100644
--- a/test/core/client_channel/lb_policies_test.c
+++ b/test/core/client_channel/lb_policies_test.c
@@ -64,9 +64,11 @@ typedef struct servers_fixture {
} servers_fixture;
typedef struct request_sequences {
- size_t n;
- int *connections;
- int *connectivity_states;
+ size_t n; /* number of iterations */
+ int *connections; /* indexed by the interation number, value is the index of
+ the server it connected to or -1 if none */
+ int *connectivity_states; /* indexed by the interation number, value is the
+ client connectivity state */
} request_sequences;
typedef void (*verifier_fn)(const servers_fixture *, grpc_channel *,
@@ -239,6 +241,8 @@ static request_sequences request_sequences_create(size_t n) {
res.n = n;
res.connections = gpr_malloc(sizeof(*res.connections) * n);
res.connectivity_states = gpr_malloc(sizeof(*res.connectivity_states) * n);
+ memset(res.connections, 0, sizeof(*res.connections) * n);
+ memset(res.connectivity_states, 0, sizeof(*res.connectivity_states) * n);
return res;
}
@@ -481,7 +485,7 @@ void run_spec(const test_spec *spec) {
gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str);
arg_array[0].type = GRPC_ARG_INTEGER;
- arg_array[0].key = "grpc.testing.fixed_reconnect_backoff";
+ arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
arg_array[0].value.integer = RETRY_TIMEOUT;
arg_array[1].type = GRPC_ARG_STRING;
arg_array[1].key = GRPC_ARG_LB_POLICY_NAME;
@@ -519,7 +523,7 @@ static grpc_channel *create_client(const servers_fixture *f) {
gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str);
arg_array[0].type = GRPC_ARG_INTEGER;
- arg_array[0].key = "grpc.testing.fixed_reconnect_backoff";
+ arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
arg_array[0].value.integer = RETRY_TIMEOUT;
arg_array[1].type = GRPC_ARG_STRING;
arg_array[1].key = GRPC_ARG_LB_POLICY_NAME;
@@ -641,7 +645,11 @@ static void test_get_channel_info() {
arg.value.string = "{\"loadBalancingPolicy\": \"ROUND_ROBIN\"}";
grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", args, NULL);
- grpc_channel_args_destroy(args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
// Ensures that resolver returns.
grpc_channel_check_connectivity_state(channel, true /* try_to_connect */);
// Now request the service config again.
@@ -780,15 +788,15 @@ static void verify_total_carnage_round_robin(const servers_fixture *f,
}
}
- /* no server is ever available. The persistent state is TRANSIENT_FAILURE */
+ /* No server is ever available. There should be no READY states (or SHUTDOWN).
+ * Note that all other states (IDLE, CONNECTING, TRANSIENT_FAILURE) are still
+ * possible, as the policy transitions while attempting to reconnect. */
for (size_t i = 0; i < sequences->n; i++) {
const grpc_connectivity_state actual = sequences->connectivity_states[i];
- const grpc_connectivity_state expected = GRPC_CHANNEL_TRANSIENT_FAILURE;
- if (actual != expected) {
+ if (actual == GRPC_CHANNEL_READY || actual == GRPC_CHANNEL_SHUTDOWN) {
gpr_log(GPR_ERROR,
- "CONNECTIVITY STATUS SEQUENCE FAILURE: expected '%s', got '%s' "
- "at iteration #%d",
- grpc_connectivity_state_name(expected),
+ "CONNECTIVITY STATUS SEQUENCE FAILURE: got unexpected state "
+ "'%s' at iteration #%d.",
grpc_connectivity_state_name(actual), (int)i);
abort();
}
@@ -825,8 +833,7 @@ static void verify_partial_carnage_round_robin(
}
/* We can assert that the first client channel state should be READY, when all
- * servers were available; and that the last one should be TRANSIENT_FAILURE,
- * after all servers are gone. */
+ * servers were available */
grpc_connectivity_state actual = sequences->connectivity_states[0];
grpc_connectivity_state expected = GRPC_CHANNEL_READY;
if (actual != expected) {
@@ -838,17 +845,19 @@ static void verify_partial_carnage_round_robin(
abort();
}
+ /* ... and that the last one shouldn't be READY (or SHUTDOWN): all servers are
+ * gone. It may be all other states (IDLE, CONNECTING, TRANSIENT_FAILURE), as
+ * the policy transitions while attempting to reconnect. */
actual = sequences->connectivity_states[num_iters - 1];
- expected = GRPC_CHANNEL_TRANSIENT_FAILURE;
- if (actual != expected) {
- gpr_log(GPR_ERROR,
- "CONNECTIVITY STATUS SEQUENCE FAILURE: expected '%s', got '%s' "
- "at iteration #%d",
- grpc_connectivity_state_name(expected),
- grpc_connectivity_state_name(actual), (int)num_iters - 1);
- abort();
+ for (i = 0; i < sequences->n; i++) {
+ if (actual == GRPC_CHANNEL_READY || actual == GRPC_CHANNEL_SHUTDOWN) {
+ gpr_log(GPR_ERROR,
+ "CONNECTIVITY STATUS SEQUENCE FAILURE: got unexpected state "
+ "'%s' at iteration #%d.",
+ grpc_connectivity_state_name(actual), (int)i);
+ abort();
+ }
}
-
gpr_free(expected_connection_sequence);
}
@@ -873,68 +882,21 @@ static void verify_rebirth_round_robin(const servers_fixture *f,
grpc_channel *client,
const request_sequences *sequences,
const size_t num_iters) {
- int *expected_connection_sequence;
- size_t i, j, unique_seq_last_idx, unique_seq_first_idx;
- const size_t expected_seq_length = f->num_servers;
- int *seen_elements;
-
dump_array("actual_connection_sequence", sequences->connections, num_iters);
- /* verify conn. seq. expectation */
- /* get the first unique run of length "num_servers". */
- expected_connection_sequence = gpr_malloc(sizeof(int) * expected_seq_length);
- seen_elements = gpr_malloc(sizeof(int) * expected_seq_length);
-
- unique_seq_last_idx = ~(size_t)0;
-
- memset(seen_elements, 0, sizeof(int) * expected_seq_length);
- for (i = 0; i < num_iters; i++) {
- if (sequences->connections[i] < 0 ||
- seen_elements[sequences->connections[i]] != 0) {
- /* if anything breaks the uniqueness of the run, back to square zero */
- memset(seen_elements, 0, sizeof(int) * expected_seq_length);
- continue;
- }
- seen_elements[sequences->connections[i]] = 1;
- for (j = 0; j < expected_seq_length; j++) {
- if (seen_elements[j] == 0) break;
- }
- if (j == expected_seq_length) { /* seen all the elements */
- unique_seq_last_idx = i;
- break;
- }
- }
- /* make sure we found a valid run */
- dump_array("seen_elements", seen_elements, expected_seq_length);
- for (j = 0; j < expected_seq_length; j++) {
- GPR_ASSERT(seen_elements[j] != 0);
- }
-
- GPR_ASSERT(unique_seq_last_idx != ~(size_t)0);
-
- unique_seq_first_idx = (unique_seq_last_idx - expected_seq_length + 1);
- memcpy(expected_connection_sequence,
- sequences->connections + unique_seq_first_idx,
- sizeof(int) * expected_seq_length);
-
/* first iteration succeeds */
GPR_ASSERT(sequences->connections[0] != -1);
/* then we fail for a while... */
GPR_ASSERT(sequences->connections[1] == -1);
- /* ... but should be up at "unique_seq_first_idx" */
- GPR_ASSERT(sequences->connections[unique_seq_first_idx] != -1);
-
- for (j = 0, i = unique_seq_first_idx; i < num_iters; i++) {
- const int actual = sequences->connections[i];
- const int expected =
- expected_connection_sequence[j++ % expected_seq_length];
- if (actual != expected) {
- print_failed_expectations(expected_connection_sequence,
- sequences->connections, expected_seq_length,
- num_iters);
- abort();
+ /* ... but should be up eventually */
+ size_t first_iter_back_up = ~0ul;
+ for (size_t i = 2; i < sequences->n; ++i) {
+ if (sequences->connections[i] != -1) {
+ first_iter_back_up = i;
+ break;
}
}
+ GPR_ASSERT(first_iter_back_up != ~0ul);
/* We can assert that the first client channel state should be READY, when all
* servers were available; same thing for the last one. In the middle
@@ -962,7 +924,7 @@ static void verify_rebirth_round_robin(const servers_fixture *f,
}
bool found_failure_status = false;
- for (i = 1; i < sequences->n - 1; i++) {
+ for (size_t i = 1; i < sequences->n - 1; i++) {
if (sequences->connectivity_states[i] == GRPC_CHANNEL_TRANSIENT_FAILURE) {
found_failure_status = true;
break;
@@ -974,14 +936,11 @@ static void verify_rebirth_round_robin(const servers_fixture *f,
"CONNECTIVITY STATUS SEQUENCE FAILURE: "
"GRPC_CHANNEL_TRANSIENT_FAILURE status not found. Got the following "
"instead:");
- for (i = 0; i < num_iters; i++) {
+ for (size_t i = 0; i < num_iters; i++) {
gpr_log(GPR_ERROR, "[%d]: %s", (int)i,
grpc_connectivity_state_name(sequences->connectivity_states[i]));
}
}
-
- gpr_free(expected_connection_sequence);
- gpr_free(seen_elements);
}
int main(int argc, char **argv) {
@@ -991,8 +950,8 @@ int main(int argc, char **argv) {
const size_t NUM_ITERS = 10;
const size_t NUM_SERVERS = 4;
- grpc_test_init(argc, argv);
grpc_init();
+ grpc_test_init(argc, argv);
grpc_tracer_set_enabled("round_robin", 1);
GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, "this-lb-policy-does-not-exist",
diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
index 5dcd5cbf9b..d5ee057657 100644
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
@@ -67,7 +67,8 @@ static void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr,
grpc_exec_ctx_sched(exec_ctx, on_done, error, NULL);
}
-static grpc_resolver *create_resolver(const char *name) {
+static grpc_resolver *create_resolver(grpc_exec_ctx *exec_ctx,
+ const char *name) {
grpc_resolver_factory *factory = grpc_resolver_factory_lookup("dns");
grpc_uri *uri = grpc_uri_parse(name, 0);
GPR_ASSERT(uri);
@@ -75,7 +76,7 @@ static grpc_resolver *create_resolver(const char *name) {
memset(&args, 0, sizeof(args));
args.uri = uri;
grpc_resolver *resolver =
- grpc_resolver_factory_create_resolver(factory, &args);
+ grpc_resolver_factory_create_resolver(exec_ctx, factory, &args);
grpc_resolver_factory_unref(factory);
grpc_uri_destroy(uri);
return resolver;
@@ -104,30 +105,30 @@ int main(int argc, char **argv) {
grpc_init();
gpr_mu_init(&g_mu);
- grpc_resolve_address = my_resolve_address;
-
- grpc_resolver *resolver = create_resolver("dns:test");
-
+ grpc_blocking_resolve_address = my_resolve_address;
grpc_channel_args *result = (grpc_channel_args *)1;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_resolver *resolver = create_resolver(&exec_ctx, "dns:test");
gpr_event ev1;
gpr_event_init(&ev1);
- grpc_resolver_next(&exec_ctx, resolver, &result,
- grpc_closure_create(on_done, &ev1));
+ grpc_resolver_next(
+ &exec_ctx, resolver, &result,
+ grpc_closure_create(on_done, &ev1, grpc_schedule_on_exec_ctx));
grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(wait_loop(5, &ev1));
GPR_ASSERT(result == NULL);
gpr_event ev2;
gpr_event_init(&ev2);
- grpc_resolver_next(&exec_ctx, resolver, &result,
- grpc_closure_create(on_done, &ev2));
+ grpc_resolver_next(
+ &exec_ctx, resolver, &result,
+ grpc_closure_create(on_done, &ev2, grpc_schedule_on_exec_ctx));
grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(wait_loop(30, &ev2));
GPR_ASSERT(result != NULL);
- grpc_channel_args_destroy(result);
+ grpc_channel_args_destroy(&exec_ctx, result);
GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test");
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/client_channel/resolvers/dns_resolver_test.c b/test/core/client_channel/resolvers/dns_resolver_test.c
index 41a9125431..5603a57b5f 100644
--- a/test/core/client_channel/resolvers/dns_resolver_test.c
+++ b/test/core/client_channel/resolvers/dns_resolver_test.c
@@ -48,7 +48,7 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
GPR_ASSERT(uri);
memset(&args, 0, sizeof(args));
args.uri = uri;
- resolver = grpc_resolver_factory_create_resolver(factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
GPR_ASSERT(resolver != NULL);
GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_succeeds");
grpc_uri_destroy(uri);
@@ -65,7 +65,7 @@ static void test_fails(grpc_resolver_factory *factory, const char *string) {
GPR_ASSERT(uri);
memset(&args, 0, sizeof(args));
args.uri = uri;
- resolver = grpc_resolver_factory_create_resolver(factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
GPR_ASSERT(resolver == NULL);
grpc_uri_destroy(uri);
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.c b/test/core/client_channel/resolvers/sockaddr_resolver_test.c
index ebf311ab83..10df78537c 100644
--- a/test/core/client_channel/resolvers/sockaddr_resolver_test.c
+++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.c
@@ -49,12 +49,7 @@ typedef struct on_resolution_arg {
void on_resolution_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
on_resolution_arg *res = arg;
- const grpc_arg *channel_arg =
- grpc_channel_args_find(res->resolver_result, GRPC_ARG_SERVER_NAME);
- GPR_ASSERT(channel_arg != NULL);
- GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
- GPR_ASSERT(strcmp(res->expected_server_name, channel_arg->value.string) == 0);
- grpc_channel_args_destroy(res->resolver_result);
+ grpc_channel_args_destroy(exec_ctx, res->resolver_result);
}
static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
@@ -67,14 +62,14 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
GPR_ASSERT(uri);
memset(&args, 0, sizeof(args));
args.uri = uri;
- resolver = grpc_resolver_factory_create_resolver(factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
GPR_ASSERT(resolver != NULL);
on_resolution_arg on_res_arg;
memset(&on_res_arg, 0, sizeof(on_res_arg));
on_res_arg.expected_server_name = uri->path;
- grpc_closure *on_resolution =
- grpc_closure_create(on_resolution_cb, &on_res_arg);
+ grpc_closure *on_resolution = grpc_closure_create(
+ on_resolution_cb, &on_res_arg, grpc_schedule_on_exec_ctx);
grpc_resolver_next(&exec_ctx, resolver, &on_res_arg.resolver_result,
on_resolution);
@@ -93,7 +88,7 @@ static void test_fails(grpc_resolver_factory *factory, const char *string) {
GPR_ASSERT(uri);
memset(&args, 0, sizeof(args));
args.uri = uri;
- resolver = grpc_resolver_factory_create_resolver(factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
GPR_ASSERT(resolver == NULL);
grpc_uri_destroy(uri);
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/client_channel/set_initial_connect_string_test.c b/test/core/client_channel/set_initial_connect_string_test.c
index b16a3ebf45..b78ba98e0a 100644
--- a/test/core/client_channel/set_initial_connect_string_test.c
+++ b/test/core/client_channel/set_initial_connect_string_test.c
@@ -92,8 +92,9 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
grpc_pollset *accepting_pollset,
grpc_tcp_server_acceptor *acceptor) {
+ gpr_free(acceptor);
test_tcp_server *server = arg;
- grpc_closure_init(&on_read, handle_read, NULL);
+ grpc_closure_init(&on_read, handle_read, NULL, grpc_schedule_on_exec_ctx);
grpc_slice_buffer_init(&state.incoming_buffer);
grpc_slice_buffer_init(&state.temp_incoming_buffer);
state.tcp = tcp;
@@ -157,7 +158,7 @@ static void cleanup_rpc(void) {
grpc_event ev;
grpc_slice_buffer_destroy(&state.incoming_buffer);
grpc_slice_buffer_destroy(&state.temp_incoming_buffer);
- grpc_channel_credentials_unref(state.creds);
+ grpc_channel_credentials_release(state.creds);
grpc_call_destroy(state.call);
grpc_completion_queue_shutdown(state.cq);
do {
diff --git a/test/core/compression/algorithm_test.c b/test/core/compression/algorithm_test.c
index bdee748ae6..ff17667b94 100644
--- a/test/core/compression/algorithm_test.c
+++ b/test/core/compression/algorithm_test.c
@@ -53,6 +53,7 @@ static void test_algorithm_mesh(void) {
grpc_compression_algorithm parsed;
grpc_mdstr *mdstr;
grpc_mdelem *mdelem;
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GPR_ASSERT(
grpc_compression_algorithm_name((grpc_compression_algorithm)i, &name));
GPR_ASSERT(grpc_compression_algorithm_parse(name, strlen(name), &parsed));
@@ -63,8 +64,9 @@ static void test_algorithm_mesh(void) {
mdelem = grpc_compression_encoding_mdelem(parsed);
GPR_ASSERT(mdelem->value == mdstr);
GPR_ASSERT(mdelem->key == GRPC_MDSTR_GRPC_ENCODING);
- GRPC_MDSTR_UNREF(mdstr);
- GRPC_MDELEM_UNREF(mdelem);
+ GRPC_MDSTR_UNREF(&exec_ctx, mdstr);
+ GRPC_MDELEM_UNREF(&exec_ctx, mdelem);
+ grpc_exec_ctx_finish(&exec_ctx);
}
/* test failure */
@@ -73,6 +75,7 @@ static void test_algorithm_mesh(void) {
}
static void test_algorithm_failure(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_mdstr *mdstr;
gpr_log(GPR_DEBUG, "test_algorithm_failure");
@@ -88,7 +91,8 @@ static void test_algorithm_failure(void) {
NULL);
GPR_ASSERT(grpc_compression_algorithm_mdstr(GRPC_COMPRESS_ALGORITHMS_COUNT +
1) == NULL);
- GRPC_MDSTR_UNREF(mdstr);
+ GRPC_MDSTR_UNREF(&exec_ctx, mdstr);
+ grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char **argv) {
diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c
index fc53cd9d36..2432ca768a 100644
--- a/test/core/compression/message_compress_test.c
+++ b/test/core/compression/message_compress_test.c
@@ -40,6 +40,7 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/support/murmur_hash.h"
#include "test/core/util/slice_splitter.h"
#include "test/core/util/test_config.h"
@@ -82,7 +83,12 @@ static void assert_passthrough(grpc_slice value,
grpc_split_slices_to_buffer(uncompressed_split_mode, &value, 1, &input);
- was_compressed = grpc_msg_compress(algorithm, &input, &compressed_raw);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ was_compressed =
+ grpc_msg_compress(&exec_ctx, algorithm, &input, &compressed_raw);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
GPR_ASSERT(input.count > 0);
switch (compress_result_check) {
@@ -99,8 +105,13 @@ static void assert_passthrough(grpc_slice value,
grpc_split_slice_buffer(compressed_split_mode, &compressed_raw, &compressed);
- GPR_ASSERT(grpc_msg_decompress(
- was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed, &output));
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GPR_ASSERT(grpc_msg_decompress(
+ &exec_ctx, was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed,
+ &output));
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
final = grpc_slice_merge(output.slices, output.count);
GPR_ASSERT(0 == grpc_slice_cmp(value, final));
@@ -160,7 +171,9 @@ static void test_tiny_data_compress(void) {
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_COMPRESS_NONE) continue;
- GPR_ASSERT(0 == grpc_msg_compress(i, &input, &output));
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GPR_ASSERT(0 == grpc_msg_compress(&exec_ctx, i, &input, &output));
+ grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(1 == output.count);
}
@@ -180,8 +193,9 @@ static void test_bad_decompression_data_crc(void) {
grpc_slice_buffer_init(&output);
grpc_slice_buffer_add(&input, create_test_value(ONE_MB_A));
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
/* compress it */
- grpc_msg_compress(GRPC_COMPRESS_GZIP, &input, &corrupted);
+ grpc_msg_compress(&exec_ctx, GRPC_COMPRESS_GZIP, &input, &corrupted);
/* corrupt the output by smashing the CRC */
GPR_ASSERT(corrupted.count > 1);
GPR_ASSERT(GRPC_SLICE_LENGTH(corrupted.slices[1]) > 8);
@@ -189,7 +203,9 @@ static void test_bad_decompression_data_crc(void) {
memcpy(GRPC_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4);
/* try (and fail) to decompress the corrupted compresed buffer */
- GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_GZIP, &corrupted, &output));
+ GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_GZIP, &corrupted,
+ &output));
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&corrupted);
@@ -208,7 +224,10 @@ static void test_bad_decompression_data_trailing_garbage(void) {
"\x78\xda\x63\x60\x60\x60\x00\x00\x00\x04\x00\x01\x99", 13));
/* try (and fail) to decompress the invalid compresed buffer */
- GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output));
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_DEFLATE, &input,
+ &output));
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -224,7 +243,10 @@ static void test_bad_decompression_data_stream(void) {
grpc_slice_from_copied_buffer("\x78\xda\xff\xff", 4));
/* try (and fail) to decompress the invalid compresed buffer */
- GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output));
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_DEFLATE, &input,
+ &output));
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -239,13 +261,16 @@ static void test_bad_compression_algorithm(void) {
grpc_slice_buffer_init(&output);
grpc_slice_buffer_add(
&input, grpc_slice_from_copied_string("Never gonna give you up"));
- was_compressed =
- grpc_msg_compress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
+
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ was_compressed = grpc_msg_compress(&exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT,
+ &input, &output);
GPR_ASSERT(0 == was_compressed);
- was_compressed =
- grpc_msg_compress(GRPC_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output);
+ was_compressed = grpc_msg_compress(
+ &exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output);
GPR_ASSERT(0 == was_compressed);
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -261,13 +286,15 @@ static void test_bad_decompression_algorithm(void) {
grpc_slice_buffer_add(&input,
grpc_slice_from_copied_string(
"I'm not really compressed but it doesn't matter"));
- was_decompressed =
- grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ was_decompressed = grpc_msg_decompress(
+ &exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
GPR_ASSERT(0 == was_decompressed);
- was_decompressed = grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT + 123,
- &input, &output);
+ was_decompressed = grpc_msg_decompress(
+ &exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output);
GPR_ASSERT(0 == was_decompressed);
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD
new file mode 100644
index 0000000000..a40fb8e083
--- /dev/null
+++ b/test/core/end2end/BUILD
@@ -0,0 +1,80 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+licenses(["notice"]) # 3-clause BSD
+
+load(":generate_tests.bzl", "grpc_end2end_tests")
+
+cc_library(
+ name = 'cq_verifier',
+ srcs = ['cq_verifier.c'],
+ hdrs = ['cq_verifier.h'],
+ deps = ['//:gpr', '//:grpc', '//test/core/util:grpc_test_util'],
+ copts = ['-std=c99'],
+ visibility = ["//test:__subpackages__"],
+)
+
+cc_library(
+ name = 'ssl_test_data',
+ visibility = ["//test:__subpackages__"],
+ hdrs = ['data/ssl_test_data.h'],
+ copts = ['-std=c99'],
+ srcs = [
+ "data/client_certs.c",
+ "data/server1_cert.c",
+ "data/server1_key.c",
+ "data/test_root_cert.c",
+ ]
+)
+
+cc_library(
+ name = 'fake_resolver',
+ hdrs = ['fake_resolver.h'],
+ srcs = ['fake_resolver.c'],
+ copts = ['-std=c99'],
+ deps = ['//:gpr', '//:grpc', '//test/core/util:grpc_test_util']
+)
+
+cc_library(
+ name = 'http_proxy',
+ hdrs = ['fixtures/http_proxy.h'],
+ srcs = ['fixtures/http_proxy.c'],
+ copts = ['-std=c99'],
+ deps = ['//:gpr', '//:grpc', '//test/core/util:grpc_test_util']
+)
+
+cc_library(
+ name = 'proxy',
+ hdrs = ['fixtures/proxy.h'],
+ srcs = ['fixtures/proxy.c'],
+ copts = ['-std=c99'],
+ deps = ['//:gpr', '//:grpc', '//test/core/util:grpc_test_util']
+)
+
+grpc_end2end_tests()
diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c
index 1c4a17fda8..a052016883 100644
--- a/test/core/end2end/bad_server_response_test.c
+++ b/test/core/end2end/bad_server_response_test.c
@@ -47,6 +47,7 @@
#include <grpc/support/thd.h>
#include "src/core/lib/iomgr/sockaddr.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/support/string.h"
#include "test/core/end2end/cq_verifier.h"
@@ -145,9 +146,10 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
grpc_pollset *accepting_pollset,
grpc_tcp_server_acceptor *acceptor) {
+ gpr_free(acceptor);
test_tcp_server *server = arg;
- grpc_closure_init(&on_read, handle_read, NULL);
- grpc_closure_init(&on_write, done_write, NULL);
+ grpc_closure_init(&on_read, handle_read, NULL, grpc_schedule_on_exec_ctx);
+ grpc_closure_init(&on_write, done_write, NULL, grpc_schedule_on_exec_ctx);
grpc_slice_buffer_init(&state.temp_incoming_buffer);
grpc_slice_buffer_init(&state.outgoing_buffer);
state.tcp = tcp;
@@ -226,10 +228,10 @@ static void start_rpc(int target_port, grpc_status_code expected_status,
cq_verifier_destroy(cqv);
}
-static void cleanup_rpc(void) {
+static void cleanup_rpc(grpc_exec_ctx *exec_ctx) {
grpc_event ev;
- grpc_slice_buffer_destroy(&state.temp_incoming_buffer);
- grpc_slice_buffer_destroy(&state.outgoing_buffer);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &state.temp_incoming_buffer);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &state.outgoing_buffer);
grpc_call_destroy(state.call);
grpc_completion_queue_shutdown(state.cq);
do {
@@ -298,8 +300,8 @@ static void run_test(const char *response_payload,
/* clean up */
grpc_endpoint_shutdown(&exec_ctx, state.tcp);
grpc_endpoint_destroy(&exec_ctx, state.tcp);
+ cleanup_rpc(&exec_ctx);
grpc_exec_ctx_finish(&exec_ctx);
- cleanup_rpc();
test_tcp_server_destroy(&test_server);
grpc_shutdown();
diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c
index 728d6dca59..4430804360 100644
--- a/test/core/end2end/connection_refused_test.c
+++ b/test/core/end2end/connection_refused_test.c
@@ -145,7 +145,11 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
gpr_free(details);
grpc_metadata_array_destroy(&trailing_metadata_recv);
- if (args != NULL) grpc_channel_args_destroy(args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ if (args != NULL) grpc_channel_args_destroy(&exec_ctx, args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
grpc_shutdown();
}
diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c
index 663489082f..b162bf2f40 100644
--- a/test/core/end2end/end2end_nosec_tests.c
+++ b/test/core/end2end/end2end_nosec_tests.c
@@ -135,6 +135,10 @@ extern void streaming_error_response(grpc_end2end_test_config config);
extern void streaming_error_response_pre_init(void);
extern void trailing_metadata(grpc_end2end_test_config config);
extern void trailing_metadata_pre_init(void);
+extern void write_buffering(grpc_end2end_test_config config);
+extern void write_buffering_pre_init(void);
+extern void write_buffering_at_end(grpc_end2end_test_config config);
+extern void write_buffering_at_end_pre_init(void);
void grpc_end2end_tests_pre_init(void) {
GPR_ASSERT(!g_pre_init_called);
@@ -185,6 +189,8 @@ void grpc_end2end_tests_pre_init(void) {
simple_request_pre_init();
streaming_error_response_pre_init();
trailing_metadata_pre_init();
+ write_buffering_pre_init();
+ write_buffering_at_end_pre_init();
}
void grpc_end2end_tests(int argc, char **argv,
@@ -240,6 +246,8 @@ void grpc_end2end_tests(int argc, char **argv,
simple_request(config);
streaming_error_response(config);
trailing_metadata(config);
+ write_buffering(config);
+ write_buffering_at_end(config);
return;
}
@@ -428,6 +436,14 @@ void grpc_end2end_tests(int argc, char **argv,
trailing_metadata(config);
continue;
}
+ if (0 == strcmp("write_buffering", argv[i])) {
+ write_buffering(config);
+ continue;
+ }
+ if (0 == strcmp("write_buffering_at_end", argv[i])) {
+ write_buffering_at_end(config);
+ continue;
+ }
gpr_log(GPR_DEBUG, "not a test: '%s'", argv[i]);
abort();
}
diff --git a/test/core/end2end/end2end_test.sh b/test/core/end2end/end2end_test.sh
new file mode 100755
index 0000000000..f2309acc88
--- /dev/null
+++ b/test/core/end2end/end2end_test.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Test runner for end2end tests from bazel
+
+# Copyright 2017, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+$1 $2
diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c
index 25c7c62fde..9bca0c81f6 100644
--- a/test/core/end2end/end2end_tests.c
+++ b/test/core/end2end/end2end_tests.c
@@ -137,6 +137,10 @@ extern void streaming_error_response(grpc_end2end_test_config config);
extern void streaming_error_response_pre_init(void);
extern void trailing_metadata(grpc_end2end_test_config config);
extern void trailing_metadata_pre_init(void);
+extern void write_buffering(grpc_end2end_test_config config);
+extern void write_buffering_pre_init(void);
+extern void write_buffering_at_end(grpc_end2end_test_config config);
+extern void write_buffering_at_end_pre_init(void);
void grpc_end2end_tests_pre_init(void) {
GPR_ASSERT(!g_pre_init_called);
@@ -188,6 +192,8 @@ void grpc_end2end_tests_pre_init(void) {
simple_request_pre_init();
streaming_error_response_pre_init();
trailing_metadata_pre_init();
+ write_buffering_pre_init();
+ write_buffering_at_end_pre_init();
}
void grpc_end2end_tests(int argc, char **argv,
@@ -244,6 +250,8 @@ void grpc_end2end_tests(int argc, char **argv,
simple_request(config);
streaming_error_response(config);
trailing_metadata(config);
+ write_buffering(config);
+ write_buffering_at_end(config);
return;
}
@@ -436,6 +444,14 @@ void grpc_end2end_tests(int argc, char **argv,
trailing_metadata(config);
continue;
}
+ if (0 == strcmp("write_buffering", argv[i])) {
+ write_buffering(config);
+ continue;
+ }
+ if (0 == strcmp("write_buffering_at_end", argv[i])) {
+ write_buffering_at_end(config);
+ continue;
+ }
gpr_log(GPR_DEBUG, "not a test: '%s'", argv[i]);
abort();
}
diff --git a/test/core/end2end/fake_resolver.c b/test/core/end2end/fake_resolver.c
index 865b55de4d..966642f403 100644
--- a/test/core/end2end/fake_resolver.c
+++ b/test/core/end2end/fake_resolver.c
@@ -48,6 +48,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/support/string.h"
@@ -76,8 +77,8 @@ typedef struct {
static void fake_resolver_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* gr) {
fake_resolver* r = (fake_resolver*)gr;
gpr_mu_destroy(&r->mu);
- grpc_channel_args_destroy(r->channel_args);
- grpc_lb_addresses_destroy(r->addresses);
+ grpc_channel_args_destroy(exec_ctx, r->channel_args);
+ grpc_lb_addresses_destroy(exec_ctx, r->addresses);
gpr_free(r);
}
@@ -87,7 +88,7 @@ static void fake_resolver_shutdown(grpc_exec_ctx* exec_ctx,
gpr_mu_lock(&r->mu);
if (r->next_completion != NULL) {
*r->target_result = NULL;
- grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
r->next_completion = NULL;
}
gpr_mu_unlock(&r->mu);
@@ -100,7 +101,7 @@ static void fake_resolver_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
grpc_arg arg = grpc_lb_addresses_create_channel_arg(r->addresses);
*r->target_result =
grpc_channel_args_copy_and_add(r->channel_args, &arg, 1);
- grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
r->next_completion = NULL;
}
}
@@ -140,7 +141,8 @@ static void fake_resolver_factory_unref(grpc_resolver_factory* factory) {}
static void do_nothing(void* ignored) {}
-static grpc_resolver* fake_resolver_create(grpc_resolver_factory* factory,
+static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx,
+ grpc_resolver_factory* factory,
grpc_resolver_args* args) {
if (0 != strcmp(args->uri->authority, "")) {
gpr_log(GPR_ERROR, "authority based uri's not supported by the %s scheme",
@@ -172,21 +174,16 @@ static grpc_resolver* fake_resolver_create(grpc_resolver_factory* factory,
addresses->addresses[i].is_balancer = lb_enabled;
if (errors_found) break;
}
- grpc_slice_buffer_destroy(&path_parts);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &path_parts);
grpc_slice_unref(path_slice);
if (errors_found) {
- grpc_lb_addresses_destroy(addresses);
+ grpc_lb_addresses_destroy(exec_ctx, addresses);
return NULL;
}
// Instantiate resolver.
fake_resolver* r = gpr_malloc(sizeof(fake_resolver));
memset(r, 0, sizeof(*r));
- grpc_arg server_name_arg;
- server_name_arg.type = GRPC_ARG_STRING;
- server_name_arg.key = GRPC_ARG_SERVER_NAME;
- server_name_arg.value.string = args->uri->path;
- r->channel_args =
- grpc_channel_args_copy_and_add(args->args, &server_name_arg, 1);
+ r->channel_args = grpc_channel_args_copy(args->args);
r->addresses = addresses;
gpr_mu_init(&r->mu);
grpc_resolver_init(&r->base, &fake_resolver_vtable);
diff --git a/test/core/end2end/fixtures/h2_census.c b/test/core/end2end/fixtures/h2_census.c
index c52d7660f5..8e60123ed6 100644
--- a/test/core/end2end/fixtures/h2_census.c
+++ b/test/core/end2end/fixtures/h2_census.c
@@ -85,7 +85,11 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
client_args = grpc_channel_args_copy_and_add(client_args, &arg, 1);
f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL);
GPR_ASSERT(f->client);
- grpc_channel_args_destroy(client_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, client_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
}
void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
@@ -97,7 +101,11 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
}
server_args = grpc_channel_args_copy_and_add(server_args, &arg, 1);
f->server = grpc_server_create(server_args, NULL);
- grpc_channel_args_destroy(server_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, server_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
grpc_server_register_completion_queue(f->server, f->cq, NULL);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c
index fedd2ebc46..c01e45664b 100644
--- a/test/core/end2end/fixtures/h2_compress.c
+++ b/test/core/end2end/fixtures/h2_compress.c
@@ -78,7 +78,9 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture *f,
grpc_channel_args *client_args) {
fullstack_compression_fixture_data *ffd = f->fixture_data;
if (ffd->client_args_compression != NULL) {
- grpc_channel_args_destroy(ffd->client_args_compression);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, ffd->client_args_compression);
+ grpc_exec_ctx_finish(&exec_ctx);
}
ffd->client_args_compression = grpc_channel_args_set_compression_algorithm(
client_args, GRPC_COMPRESS_GZIP);
@@ -90,7 +92,9 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture *f,
grpc_channel_args *server_args) {
fullstack_compression_fixture_data *ffd = f->fixture_data;
if (ffd->server_args_compression != NULL) {
- grpc_channel_args_destroy(ffd->server_args_compression);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, ffd->server_args_compression);
+ grpc_exec_ctx_finish(&exec_ctx);
}
ffd->server_args_compression = grpc_channel_args_set_compression_algorithm(
server_args, GRPC_COMPRESS_GZIP);
@@ -104,11 +108,13 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture *f,
}
void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture *f) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
fullstack_compression_fixture_data *ffd = f->fixture_data;
- grpc_channel_args_destroy(ffd->client_args_compression);
- grpc_channel_args_destroy(ffd->server_args_compression);
+ grpc_channel_args_destroy(&exec_ctx, ffd->client_args_compression);
+ grpc_channel_args_destroy(&exec_ctx, ffd->server_args_compression);
gpr_free(ffd->localaddr);
gpr_free(ffd);
+ grpc_exec_ctx_finish(&exec_ctx);
}
/* All test configurations */
diff --git a/test/core/end2end/fixtures/h2_load_reporting.c b/test/core/end2end/fixtures/h2_load_reporting.c
index 7a76489b44..38321f34db 100644
--- a/test/core/end2end/fixtures/h2_load_reporting.c
+++ b/test/core/end2end/fixtures/h2_load_reporting.c
@@ -88,7 +88,11 @@ void chttp2_init_server_load_reporting(grpc_end2end_test_fixture *f,
}
server_args = grpc_channel_args_copy_and_add(server_args, &arg, 1);
f->server = grpc_server_create(server_args, NULL);
- grpc_channel_args_destroy(server_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, server_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
grpc_server_register_completion_queue(f->server, f->cq, NULL);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
diff --git a/test/core/end2end/fixtures/h2_oauth2.c b/test/core/end2end/fixtures/h2_oauth2.c
index 6122f4f2f9..83f759ce2d 100644
--- a/test/core/end2end/fixtures/h2_oauth2.c
+++ b/test/core/end2end/fixtures/h2_oauth2.c
@@ -163,7 +163,11 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_channel_args *new_client_args =
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_oauth2_creds);
- grpc_channel_args_destroy(new_client_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, new_client_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
grpc_channel_credentials_release(ssl_creds);
grpc_call_credentials_release(oauth2_creds);
}
diff --git a/test/core/end2end/fixtures/h2_ssl.c b/test/core/end2end/fixtures/h2_ssl.c
index bbd522cf30..cf44cd093c 100644
--- a/test/core/end2end/fixtures/h2_ssl.c
+++ b/test/core/end2end/fixtures/h2_ssl.c
@@ -118,7 +118,11 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_channel_args *new_client_args =
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds);
- grpc_channel_args_destroy(new_client_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, new_client_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
}
static int fail_server_auth_check(grpc_channel_args *server_args) {
diff --git a/test/core/end2end/fixtures/h2_ssl_cert.c b/test/core/end2end/fixtures/h2_ssl_cert.c
index e39cb491de..ae49cc859a 100644
--- a/test/core/end2end/fixtures/h2_ssl_cert.c
+++ b/test/core/end2end/fixtures/h2_ssl_cert.c
@@ -186,7 +186,11 @@ typedef enum { NONE, SELF_SIGNED, SIGNED, BAD_CERT_PAIR } certtype;
grpc_channel_args *new_client_args = \
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); \
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); \
- grpc_channel_args_destroy(new_client_args); \
+ { \
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; \
+ grpc_channel_args_destroy(&exec_ctx, new_client_args); \
+ grpc_exec_ctx_finish(&exec_ctx); \
+ } \
}
CLIENT_INIT(NONE)
diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.c b/test/core/end2end/fixtures/h2_ssl_proxy.c
index 27cf3ebf32..740b075bf6 100644
--- a/test/core/end2end/fixtures/h2_ssl_proxy.c
+++ b/test/core/end2end/fixtures/h2_ssl_proxy.c
@@ -79,7 +79,11 @@ static grpc_channel *create_proxy_client(const char *target,
channel =
grpc_secure_channel_create(ssl_creds, target, new_client_args, NULL);
grpc_channel_credentials_release(ssl_creds);
- grpc_channel_args_destroy(new_client_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, new_client_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
return channel;
}
@@ -151,7 +155,11 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_channel_args *new_client_args =
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds);
- grpc_channel_args_destroy(new_client_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, new_client_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
}
static int fail_server_auth_check(grpc_channel_args *server_args) {
diff --git a/test/core/end2end/fixtures/http_proxy.c b/test/core/end2end/fixtures/http_proxy.c
index 57fc4a38f8..b62082c6fb 100644
--- a/test/core/end2end/fixtures/http_proxy.c
+++ b/test/core/end2end/fixtures/http_proxy.c
@@ -59,6 +59,7 @@
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/iomgr/tcp_client.h"
#include "src/core/lib/iomgr/tcp_server.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "test/core/util/port.h"
struct grpc_end2end_http_proxy {
@@ -110,12 +111,14 @@ static void proxy_connection_unref(grpc_exec_ctx* exec_ctx,
if (conn->server_endpoint != NULL)
grpc_endpoint_destroy(exec_ctx, conn->server_endpoint);
grpc_pollset_set_destroy(conn->pollset_set);
- grpc_slice_buffer_destroy(&conn->client_read_buffer);
- grpc_slice_buffer_destroy(&conn->client_deferred_write_buffer);
- grpc_slice_buffer_destroy(&conn->client_write_buffer);
- grpc_slice_buffer_destroy(&conn->server_read_buffer);
- grpc_slice_buffer_destroy(&conn->server_deferred_write_buffer);
- grpc_slice_buffer_destroy(&conn->server_write_buffer);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &conn->client_read_buffer);
+ grpc_slice_buffer_destroy_internal(exec_ctx,
+ &conn->client_deferred_write_buffer);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &conn->client_write_buffer);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &conn->server_read_buffer);
+ grpc_slice_buffer_destroy_internal(exec_ctx,
+ &conn->server_deferred_write_buffer);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &conn->server_write_buffer);
grpc_http_parser_destroy(&conn->http_parser);
grpc_http_request_destroy(&conn->http_request);
gpr_free(conn);
@@ -367,6 +370,7 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
grpc_endpoint* endpoint, grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
+ gpr_free(acceptor);
grpc_end2end_http_proxy* proxy = arg;
// Instantiate proxy_connection.
proxy_connection* conn = gpr_malloc(sizeof(*conn));
@@ -375,15 +379,20 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
gpr_ref_init(&conn->refcount, 1);
conn->pollset_set = grpc_pollset_set_create();
grpc_pollset_set_add_pollset(exec_ctx, conn->pollset_set, proxy->pollset);
- grpc_closure_init(&conn->on_read_request_done, on_read_request_done, conn);
- grpc_closure_init(&conn->on_server_connect_done, on_server_connect_done,
- conn);
- grpc_closure_init(&conn->on_write_response_done, on_write_response_done,
- conn);
- grpc_closure_init(&conn->on_client_read_done, on_client_read_done, conn);
- grpc_closure_init(&conn->on_client_write_done, on_client_write_done, conn);
- grpc_closure_init(&conn->on_server_read_done, on_server_read_done, conn);
- grpc_closure_init(&conn->on_server_write_done, on_server_write_done, conn);
+ grpc_closure_init(&conn->on_read_request_done, on_read_request_done, conn,
+ grpc_schedule_on_exec_ctx);
+ grpc_closure_init(&conn->on_server_connect_done, on_server_connect_done, conn,
+ grpc_schedule_on_exec_ctx);
+ grpc_closure_init(&conn->on_write_response_done, on_write_response_done, conn,
+ grpc_schedule_on_exec_ctx);
+ grpc_closure_init(&conn->on_client_read_done, on_client_read_done, conn,
+ grpc_schedule_on_exec_ctx);
+ grpc_closure_init(&conn->on_client_write_done, on_client_write_done, conn,
+ grpc_schedule_on_exec_ctx);
+ grpc_closure_init(&conn->on_server_read_done, on_server_read_done, conn,
+ grpc_schedule_on_exec_ctx);
+ grpc_closure_init(&conn->on_server_write_done, on_server_write_done, conn,
+ grpc_schedule_on_exec_ctx);
grpc_slice_buffer_init(&conn->client_read_buffer);
grpc_slice_buffer_init(&conn->client_deferred_write_buffer);
grpc_slice_buffer_init(&conn->client_write_buffer);
@@ -468,9 +477,10 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) {
grpc_tcp_server_shutdown_listeners(&exec_ctx, proxy->server);
grpc_tcp_server_unref(&exec_ctx, proxy->server);
gpr_free(proxy->proxy_name);
- grpc_channel_args_destroy(proxy->channel_args);
+ grpc_channel_args_destroy(&exec_ctx, proxy->channel_args);
grpc_closure destroyed;
- grpc_closure_init(&destroyed, destroy_pollset, proxy->pollset);
+ grpc_closure_init(&destroyed, destroy_pollset, proxy->pollset,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(&exec_ctx, proxy->pollset, &destroyed);
gpr_free(proxy);
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/end2end/fuzzers/BUILD b/test/core/end2end/fuzzers/BUILD
new file mode 100644
index 0000000000..4d98aa0725
--- /dev/null
+++ b/test/core/end2end/fuzzers/BUILD
@@ -0,0 +1,56 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+licenses(["notice"]) # 3-clause BSD
+
+load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
+
+grpc_fuzzer(
+ name = "api_fuzzer",
+ srcs = ["api_fuzzer.c"],
+ deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util", "//test/core/end2end:ssl_test_data"],
+ corpus = "api_fuzzer_corpus",
+ copts = ["-std=c99"],
+)
+
+grpc_fuzzer(
+ name = "client_fuzzer",
+ srcs = ["client_fuzzer.c"],
+ deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util"],
+ corpus = "client_fuzzer_corpus",
+ copts = ["-std=c99"],
+)
+
+grpc_fuzzer(
+ name = "server_fuzzer",
+ srcs = ["server_fuzzer.c"],
+ deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util"],
+ corpus = "server_fuzzer_corpus",
+ copts = ["-std=c99"],
+)
diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c
index b3e0d90da8..7961b4ee8a 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.c
+++ b/test/core/end2end/fuzzers/api_fuzzer.c
@@ -349,11 +349,11 @@ static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg,
addrs->addrs = gpr_malloc(sizeof(*addrs->addrs));
addrs->addrs[0].len = 0;
*r->addrs = addrs;
- grpc_exec_ctx_sched(exec_ctx, r->on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, r->on_done, GRPC_ERROR_NONE);
} else {
- grpc_exec_ctx_sched(
+ grpc_closure_sched(
exec_ctx, r->on_done,
- GRPC_ERROR_CREATE_REFERENCING("Resolution failed", &error, 1), NULL);
+ GRPC_ERROR_CREATE_REFERENCING("Resolution failed", &error, 1));
}
gpr_free(r->addr);
@@ -369,10 +369,11 @@ void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr,
r->addr = gpr_strdup(addr);
r->on_done = on_done;
r->addrs = addresses;
- grpc_timer_init(exec_ctx, &r->timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_seconds(1, GPR_TIMESPAN)),
- finish_resolve, r, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(
+ exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_seconds(1, GPR_TIMESPAN)),
+ grpc_closure_create(finish_resolve, r, grpc_schedule_on_exec_ctx),
+ gpr_now(GPR_CLOCK_MONOTONIC));
}
////////////////////////////////////////////////////////////////////////////////
@@ -398,7 +399,7 @@ static void do_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
future_connect *fc = arg;
if (error != GRPC_ERROR_NONE) {
*fc->ep = NULL;
- grpc_exec_ctx_sched(exec_ctx, fc->closure, GRPC_ERROR_REF(error), NULL);
+ grpc_closure_sched(exec_ctx, fc->closure, GRPC_ERROR_REF(error));
} else if (g_server != NULL) {
grpc_endpoint *client;
grpc_endpoint *server;
@@ -410,7 +411,7 @@ static void do_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
grpc_server_setup_transport(exec_ctx, g_server, transport, NULL, NULL);
grpc_chttp2_transport_start_reading(exec_ctx, transport, NULL);
- grpc_exec_ctx_sched(exec_ctx, fc->closure, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, fc->closure, GRPC_ERROR_NONE);
} else {
sched_connect(exec_ctx, fc->closure, fc->ep, fc->deadline);
}
@@ -421,8 +422,8 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
grpc_endpoint **ep, gpr_timespec deadline) {
if (gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) < 0) {
*ep = NULL;
- grpc_exec_ctx_sched(exec_ctx, closure,
- GRPC_ERROR_CREATE("Connect deadline exceeded"), NULL);
+ grpc_closure_sched(exec_ctx, closure,
+ GRPC_ERROR_CREATE("Connect deadline exceeded"));
return;
}
@@ -430,10 +431,11 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
fc->closure = closure;
fc->ep = ep;
fc->deadline = deadline;
- grpc_timer_init(exec_ctx, &fc->timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_millis(1, GPR_TIMESPAN)),
- do_connect, fc, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(
+ exec_ctx, &fc->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_millis(1, GPR_TIMESPAN)),
+ grpc_closure_create(do_connect, fc, grpc_schedule_on_exec_ctx),
+ gpr_now(GPR_CLOCK_MONOTONIC));
}
static void my_tcp_client_connect(grpc_exec_ctx *exec_ctx,
@@ -746,7 +748,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_channel_args *args = read_args(&inp);
g_channel = grpc_insecure_channel_create(target_uri, args, NULL);
GPR_ASSERT(g_channel != NULL);
- grpc_channel_args_destroy(args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
gpr_free(target_uri);
gpr_free(target);
} else {
@@ -770,7 +776,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_channel_args *args = read_args(&inp);
g_server = grpc_server_create(args, NULL);
GPR_ASSERT(g_server != NULL);
- grpc_channel_args_destroy(args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
grpc_server_register_completion_queue(g_server, cq, NULL);
grpc_server_start(g_server);
server_shutdown = false;
@@ -1106,7 +1116,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_channel_credentials *creds = read_channel_creds(&inp);
g_channel = grpc_secure_channel_create(creds, target_uri, args, NULL);
GPR_ASSERT(g_channel != NULL);
- grpc_channel_args_destroy(args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
gpr_free(target_uri);
gpr_free(target);
grpc_channel_credentials_release(creds);
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/08455b3ef9d516deb8155d8db7d51c43ce0ff07a b/test/core/end2end/fuzzers/api_fuzzer_corpus/08455b3ef9d516deb8155d8db7d51c43ce0ff07a
new file mode 100644
index 0000000000..4b698ba9ee
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/08455b3ef9d516deb8155d8db7d51c43ce0ff07a
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0d19e60f4eb1b729e272dd5dec68e8b67f03a5f4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0d19e60f4eb1b729e272dd5dec68e8b67f03a5f4
new file mode 100644
index 0000000000..2889e7040e
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0d19e60f4eb1b729e272dd5dec68e8b67f03a5f4
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/14064ac4844c709b247a4345a92d8be9766785c4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/14064ac4844c709b247a4345a92d8be9766785c4
new file mode 100644
index 0000000000..fa731d4a05
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/14064ac4844c709b247a4345a92d8be9766785c4
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1901234bd7c9cb6ee19ff8b17179c481bdc7c5f2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1901234bd7c9cb6ee19ff8b17179c481bdc7c5f2
new file mode 100644
index 0000000000..ef09a0eaf5
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1901234bd7c9cb6ee19ff8b17179c481bdc7c5f2
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/20ff1f8d5d34cb01d58aa334dc46a6644e6e1d12 b/test/core/end2end/fuzzers/api_fuzzer_corpus/20ff1f8d5d34cb01d58aa334dc46a6644e6e1d12
new file mode 100644
index 0000000000..fc747d4a72
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/20ff1f8d5d34cb01d58aa334dc46a6644e6e1d12
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/2378c3f1206f20711468391ce739116ffe58374b b/test/core/end2end/fuzzers/api_fuzzer_corpus/2378c3f1206f20711468391ce739116ffe58374b
new file mode 100644
index 0000000000..ca3ce31cbe
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/2378c3f1206f20711468391ce739116ffe58374b
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/40640a91fda4e4e42d3063a28b9ffbba1b8c3701 b/test/core/end2end/fuzzers/api_fuzzer_corpus/40640a91fda4e4e42d3063a28b9ffbba1b8c3701
new file mode 100644
index 0000000000..f11821acc9
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/40640a91fda4e4e42d3063a28b9ffbba1b8c3701
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/49f564289c79de9e0342f8b0821a167bc8c5ec00 b/test/core/end2end/fuzzers/api_fuzzer_corpus/49f564289c79de9e0342f8b0821a167bc8c5ec00
new file mode 100644
index 0000000000..c846377f0a
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/49f564289c79de9e0342f8b0821a167bc8c5ec00
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/507865c4a5ce880b80400d93fa85def2682581cb b/test/core/end2end/fuzzers/api_fuzzer_corpus/507865c4a5ce880b80400d93fa85def2682581cb
new file mode 100644
index 0000000000..c4473eacbb
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/507865c4a5ce880b80400d93fa85def2682581cb
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5f2fdb01d8ff632803ca2b732a7c088c6843d7d3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/5f2fdb01d8ff632803ca2b732a7c088c6843d7d3
new file mode 100644
index 0000000000..b91a052534
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5f2fdb01d8ff632803ca2b732a7c088c6843d7d3
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/61de97a9d6c4b082602c02277d8d763921f5f95b b/test/core/end2end/fuzzers/api_fuzzer_corpus/61de97a9d6c4b082602c02277d8d763921f5f95b
new file mode 100644
index 0000000000..a24008b1d4
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/61de97a9d6c4b082602c02277d8d763921f5f95b
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/62b039b8a318cc08471f13629da08c68c414d8e7 b/test/core/end2end/fuzzers/api_fuzzer_corpus/62b039b8a318cc08471f13629da08c68c414d8e7
new file mode 100644
index 0000000000..e5e218acc3
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/62b039b8a318cc08471f13629da08c68c414d8e7
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/641739453f7d4d3b55a1c7b79bed7da6dfd62ae0 b/test/core/end2end/fuzzers/api_fuzzer_corpus/641739453f7d4d3b55a1c7b79bed7da6dfd62ae0
new file mode 100644
index 0000000000..9dcc5c578c
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/641739453f7d4d3b55a1c7b79bed7da6dfd62ae0
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6589505362ffb5164a3c7cb1b9feadcddfba44e9 b/test/core/end2end/fuzzers/api_fuzzer_corpus/6589505362ffb5164a3c7cb1b9feadcddfba44e9
new file mode 100644
index 0000000000..10625da2ff
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6589505362ffb5164a3c7cb1b9feadcddfba44e9
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/724f5400f19e5a0be97022341c39eeaaaffeb390 b/test/core/end2end/fuzzers/api_fuzzer_corpus/724f5400f19e5a0be97022341c39eeaaaffeb390
new file mode 100644
index 0000000000..1dbc538192
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/724f5400f19e5a0be97022341c39eeaaaffeb390
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7254b9ff59ab3fcf345effdabbc25ebd2e907b23 b/test/core/end2end/fuzzers/api_fuzzer_corpus/7254b9ff59ab3fcf345effdabbc25ebd2e907b23
new file mode 100644
index 0000000000..92371e031f
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/7254b9ff59ab3fcf345effdabbc25ebd2e907b23
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/784d6f5c093ab5360670173ce001e1a446f95822 b/test/core/end2end/fuzzers/api_fuzzer_corpus/784d6f5c093ab5360670173ce001e1a446f95822
new file mode 100644
index 0000000000..79885b7f2a
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/784d6f5c093ab5360670173ce001e1a446f95822
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/79328fdc89d0af0e38da089dab062fd3ea5aae59 b/test/core/end2end/fuzzers/api_fuzzer_corpus/79328fdc89d0af0e38da089dab062fd3ea5aae59
new file mode 100644
index 0000000000..4a5cbfd654
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/79328fdc89d0af0e38da089dab062fd3ea5aae59
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7a2569f4daf4480ad142cb4ee7c675bed82db74c b/test/core/end2end/fuzzers/api_fuzzer_corpus/7a2569f4daf4480ad142cb4ee7c675bed82db74c
new file mode 100644
index 0000000000..75b55e7e10
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/7a2569f4daf4480ad142cb4ee7c675bed82db74c
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/87a300cd25d2e57745bd00499d4d2352a10a2fa1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/87a300cd25d2e57745bd00499d4d2352a10a2fa1
new file mode 100644
index 0000000000..c8f79862bc
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/87a300cd25d2e57745bd00499d4d2352a10a2fa1
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8a1c629910280f8beebb88687696de98da988ecc b/test/core/end2end/fuzzers/api_fuzzer_corpus/8a1c629910280f8beebb88687696de98da988ecc
new file mode 100644
index 0000000000..ce3377fdc1
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8a1c629910280f8beebb88687696de98da988ecc
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8ff7b1568d2da2e4196c2e28617e1911d62021e6 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8ff7b1568d2da2e4196c2e28617e1911d62021e6
new file mode 100644
index 0000000000..321520b870
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8ff7b1568d2da2e4196c2e28617e1911d62021e6
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/982f375b183d984958667461c7767206062eb4cb b/test/core/end2end/fuzzers/api_fuzzer_corpus/982f375b183d984958667461c7767206062eb4cb
new file mode 100644
index 0000000000..01d07d6408
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/982f375b183d984958667461c7767206062eb4cb
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/98739af631223fa05ad88f1e63a52052a9bb4b1c b/test/core/end2end/fuzzers/api_fuzzer_corpus/98739af631223fa05ad88f1e63a52052a9bb4b1c
new file mode 100644
index 0000000000..a4adb7aee6
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/98739af631223fa05ad88f1e63a52052a9bb4b1c
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a78bca1ef8829d720dd5dedac3a9d4d12684da34 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a78bca1ef8829d720dd5dedac3a9d4d12684da34
new file mode 100644
index 0000000000..322d4ae019
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a78bca1ef8829d720dd5dedac3a9d4d12684da34
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ac763d89466ebfad676e75be0076831c03fe2a5d b/test/core/end2end/fuzzers/api_fuzzer_corpus/ac763d89466ebfad676e75be0076831c03fe2a5d
new file mode 100644
index 0000000000..64c9720c9b
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ac763d89466ebfad676e75be0076831c03fe2a5d
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b165523f699e6ae9b2ad15873b9d56465d1af546 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b165523f699e6ae9b2ad15873b9d56465d1af546
new file mode 100644
index 0000000000..b0b7452924
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b165523f699e6ae9b2ad15873b9d56465d1af546
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b2a5ec3ef40c68d594638218e3c943a479f82215 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b2a5ec3ef40c68d594638218e3c943a479f82215
new file mode 100644
index 0000000000..ac2b154407
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b2a5ec3ef40c68d594638218e3c943a479f82215
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b92b1c5e0dba009a9516e7185f5df019c62c5cc9 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b92b1c5e0dba009a9516e7185f5df019c62c5cc9
new file mode 100644
index 0000000000..3d542f38ec
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b92b1c5e0dba009a9516e7185f5df019c62c5cc9
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c5cd7af16e7bc0049445d5a0b92a3d4b7e5e3533 b/test/core/end2end/fuzzers/api_fuzzer_corpus/c5cd7af16e7bc0049445d5a0b92a3d4b7e5e3533
new file mode 100644
index 0000000000..c8fca17ad3
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c5cd7af16e7bc0049445d5a0b92a3d4b7e5e3533
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-da39a3ee5e6b4b0d3255bfef95601890afd80709 b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-da39a3ee5e6b4b0d3255bfef95601890afd80709
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-da39a3ee5e6b4b0d3255bfef95601890afd80709
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e28ffd8c2816f12f6395805199c792d1718191df b/test/core/end2end/fuzzers/api_fuzzer_corpus/e28ffd8c2816f12f6395805199c792d1718191df
new file mode 100644
index 0000000000..a867a8b0be
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e28ffd8c2816f12f6395805199c792d1718191df
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ec823f4018389e64a99f6580277fba28df6bd136 b/test/core/end2end/fuzzers/api_fuzzer_corpus/ec823f4018389e64a99f6580277fba28df6bd136
new file mode 100644
index 0000000000..2e6d409d39
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ec823f4018389e64a99f6580277fba28df6bd136
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ee2c1ac1e668f22836cf25a59495e778b0e2c7a8 b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee2c1ac1e668f22836cf25a59495e778b0e2c7a8
new file mode 100644
index 0000000000..f1990ac231
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee2c1ac1e668f22836cf25a59495e778b0e2c7a8
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ee6855178435d2046d8763ecae46e1e0a71a95f4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee6855178435d2046d8763ecae46e1e0a71a95f4
new file mode 100644
index 0000000000..6badaf36dc
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee6855178435d2046d8763ecae46e1e0a71a95f4
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/eeb310d91038cb02862e187e68c5d6578233485b b/test/core/end2end/fuzzers/api_fuzzer_corpus/eeb310d91038cb02862e187e68c5d6578233485b
new file mode 100644
index 0000000000..1b05cfb036
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/eeb310d91038cb02862e187e68c5d6578233485b
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f07bc2907c95f2aeb79ca60e2ad826e13b848f45 b/test/core/end2end/fuzzers/api_fuzzer_corpus/f07bc2907c95f2aeb79ca60e2ad826e13b848f45
new file mode 100644
index 0000000000..313d456262
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f07bc2907c95f2aeb79ca60e2ad826e13b848f45
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/fb655905396b768cf3ff015afdb0b564dae2cdfd b/test/core/end2end/fuzzers/api_fuzzer_corpus/fb655905396b768cf3ff015afdb0b564dae2cdfd
new file mode 100644
index 0000000000..b02dabe03a
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/fb655905396b768cf3ff015afdb0b564dae2cdfd
Binary files differ
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/fdb038087233cd176746558875932029f779221d b/test/core/end2end/fuzzers/api_fuzzer_corpus/fdb038087233cd176746558875932029f779221d
new file mode 100644
index 0000000000..017fdbf661
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/fdb038087233cd176746558875932029f779221d
Binary files differ
diff --git a/test/core/end2end/fuzzers/client_fuzzer.c b/test/core/end2end/fuzzers/client_fuzzer.c
index c5260cd287..26b520885b 100644
--- a/test/core/end2end/fuzzers/client_fuzzer.c
+++ b/test/core/end2end/fuzzers/client_fuzzer.c
@@ -62,7 +62,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_resource_quota_create("client_fuzzer");
grpc_endpoint *mock_endpoint =
grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
grpc_transport *transport =
diff --git a/test/core/end2end/fuzzers/server_fuzzer.c b/test/core/end2end/fuzzers/server_fuzzer.c
index 164022ec79..115fb06925 100644
--- a/test/core/end2end/fuzzers/server_fuzzer.c
+++ b/test/core/end2end/fuzzers/server_fuzzer.c
@@ -60,7 +60,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_resource_quota_create("server_fuzzer");
grpc_endpoint *mock_endpoint =
grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
grpc_mock_endpoint_put_read(
&exec_ctx, mock_endpoint,
grpc_slice_from_copied_buffer((const char *)data, size));
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index 201a92a1fd..bcb7136eaa 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -143,6 +143,8 @@ END2END_TESTS = {
'streaming_error_response': default_test_options,
'trailing_metadata': default_test_options,
'authority_not_supported': default_test_options,
+ 'write_buffering': default_test_options,
+ 'write_buffering_at_end': default_test_options,
}
diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl
new file mode 100755
index 0000000000..95c06de73f
--- /dev/null
+++ b/test/core/end2end/generate_tests.bzl
@@ -0,0 +1,194 @@
+#!/usr/bin/env python2.7
+# Copyright 2015, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+"""Generates the appropriate build.json data for all the end2end tests."""
+
+
+def fixture_options(fullstack=True, includes_proxy=False, dns_resolver=True,
+ secure=True, tracing=False,
+ platforms=['windows', 'linux', 'mac', 'posix']):
+ return struct(
+ fullstack=fullstack,
+ includes_proxy=includes_proxy,
+ dns_resolver=dns_resolver,
+ secure=secure,
+ tracing=tracing,
+ #platforms=platforms
+ )
+
+
+# maps fixture name to whether it requires the security library
+END2END_FIXTURES = {
+ 'h2_compress': fixture_options(),
+ 'h2_census': fixture_options(),
+ 'h2_load_reporting': fixture_options(),
+ 'h2_fakesec': fixture_options(),
+ 'h2_fd': fixture_options(dns_resolver=False, fullstack=False,
+ platforms=['linux', 'mac', 'posix']),
+ 'h2_full': fixture_options(),
+ 'h2_full+pipe': fixture_options(platforms=['linux']),
+ 'h2_full+trace': fixture_options(tracing=True),
+ 'h2_http_proxy': fixture_options(),
+ 'h2_oauth2': fixture_options(),
+ 'h2_proxy': fixture_options(includes_proxy=True),
+ 'h2_sockpair_1byte': fixture_options(fullstack=False, dns_resolver=False),
+ 'h2_sockpair': fixture_options(fullstack=False, dns_resolver=False),
+ 'h2_sockpair+trace': fixture_options(fullstack=False, dns_resolver=False,
+ tracing=True),
+ 'h2_ssl': fixture_options(secure=True),
+ 'h2_ssl_cert': fixture_options(secure=True),
+ 'h2_ssl_proxy': fixture_options(secure=True),
+ 'h2_uds': fixture_options(dns_resolver=False,
+ platforms=['linux', 'mac', 'posix']),
+}
+
+
+def test_options(needs_fullstack=False, needs_dns=False, proxyable=True,
+ secure=False, traceable=False):
+ return struct(
+ needs_fullstack=needs_fullstack,
+ needs_dns=needs_dns,
+ proxyable=proxyable,
+ secure=secure,
+ traceable=traceable
+ )
+
+
+# maps test names to options
+END2END_TESTS = {
+ 'bad_hostname': test_options(),
+ 'binary_metadata': test_options(),
+ 'resource_quota_server': test_options(proxyable=False),
+ 'call_creds': test_options(secure=True),
+ 'cancel_after_accept': test_options(),
+ 'cancel_after_client_done': test_options(),
+ 'cancel_after_invoke': test_options(),
+ 'cancel_before_invoke': test_options(),
+ 'cancel_in_a_vacuum': test_options(),
+ 'cancel_with_status': test_options(),
+ 'compressed_payload': test_options(),
+ 'connectivity': test_options(needs_fullstack=True, proxyable=False),
+ 'default_host': test_options(needs_fullstack=True, needs_dns=True),
+ 'disappearing_server': test_options(needs_fullstack=True),
+ 'empty_batch': test_options(),
+ 'filter_causes_close': test_options(),
+ 'filter_call_init_fails': test_options(),
+ 'graceful_server_shutdown': test_options(),
+ 'hpack_size': test_options(proxyable=False, traceable=False),
+ 'high_initial_seqno': test_options(),
+ 'idempotent_request': test_options(),
+ 'invoke_large_request': test_options(),
+ 'large_metadata': test_options(),
+ 'max_concurrent_streams': test_options(proxyable=False),
+ 'max_message_length': test_options(),
+ 'negative_deadline': test_options(),
+ 'network_status_change': test_options(),
+ 'no_logging': test_options(traceable=False),
+ 'no_op': test_options(),
+ 'payload': test_options(),
+ 'load_reporting_hook': test_options(),
+ 'ping_pong_streaming': test_options(),
+ 'ping': test_options(proxyable=False),
+ 'registered_call': test_options(),
+ 'request_with_flags': test_options(proxyable=False),
+ 'request_with_payload': test_options(),
+ 'server_finishes_request': test_options(),
+ 'shutdown_finishes_calls': test_options(),
+ 'shutdown_finishes_tags': test_options(),
+ 'simple_cacheable_request': test_options(),
+ 'simple_delayed_request': test_options(needs_fullstack=True),
+ 'simple_metadata': test_options(),
+ 'simple_request': test_options(),
+ 'streaming_error_response': test_options(),
+ 'trailing_metadata': test_options(),
+ 'authority_not_supported': test_options(),
+ 'filter_latency': test_options(),
+ 'write_buffering': test_options(),
+ 'write_buffering_at_end': test_options(),
+}
+
+
+def compatible(fopt, topt):
+ if topt.needs_fullstack:
+ if not fopt.fullstack:
+ return False
+ if topt.needs_dns:
+ if not fopt.dns_resolver:
+ return False
+ if not topt.proxyable:
+ if fopt.includes_proxy:
+ return False
+ if not topt.traceable:
+ if fopt.tracing:
+ return False
+ return True
+
+
+def grpc_end2end_tests():
+ native.cc_library(
+ name = 'end2end_tests',
+ srcs = ['end2end_tests.c', 'end2end_test_utils.c'] + [
+ 'tests/%s.c' % t
+ for t in sorted(END2END_TESTS.keys())],
+ hdrs = [
+ 'tests/cancel_test_helpers.h',
+ 'end2end_tests.h'
+ ],
+ copts = ['-std=c99'],
+ deps = [
+ ':cq_verifier',
+ ':ssl_test_data',
+ ':fake_resolver',
+ ':http_proxy',
+ ':proxy',
+ '//test/core/util:grpc_test_util',
+ '//:grpc',
+ '//test/core/util:gpr_test_util',
+ '//:gpr',
+ ]
+ )
+
+ for f, fopt in END2END_FIXTURES.items():
+ native.cc_binary(
+ name = '%s_test' % f,
+ srcs = ['fixtures/%s.c' % f],
+ copts = ['-std=c99'],
+ deps = [':end2end_tests']
+ )
+ for t, topt in END2END_TESTS.items():
+ #print(compatible(fopt, topt), f, t, fopt, topt)
+ if not compatible(fopt, topt): continue
+ native.sh_test(
+ name = '%s_test@%s' % (f, t),
+ srcs = ['end2end_test.sh'],
+ args = ['$(location %s_test)' % f, t],
+ data = [':%s_test' % f],
+ )
diff --git a/test/core/end2end/goaway_server_test.c b/test/core/end2end/goaway_server_test.c
index 9d9092aa0c..dba80118dd 100644
--- a/test/core/end2end/goaway_server_test.c
+++ b/test/core/end2end/goaway_server_test.c
@@ -134,8 +134,16 @@ int main(int argc, char **argv) {
char *addr;
+ grpc_channel_args client_args;
+ grpc_arg arg_array[1];
+ arg_array[0].type = GRPC_ARG_INTEGER;
+ arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].value.integer = 1000;
+ client_args.args = arg_array;
+ client_args.num_args = 1;
+
/* create a channel that picks first amongst the servers */
- grpc_channel *chan = grpc_insecure_channel_create("test", NULL, NULL);
+ grpc_channel *chan = grpc_insecure_channel_create("test", &client_args, NULL);
/* and an initial call to them */
grpc_call *call1 = grpc_channel_create_call(
chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo", "127.0.0.1",
diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c
index 765b6ad1be..d974d2c8ff 100644
--- a/test/core/end2end/invalid_call_argument_test.c
+++ b/test/core/end2end/invalid_call_argument_test.c
@@ -573,6 +573,29 @@ static void test_recv_close_on_server_twice() {
cleanup_test();
}
+static void test_invalid_initial_metadata_reserved_key() {
+ gpr_log(GPR_INFO, "test_invalid_initial_metadata_reserved_key");
+
+ grpc_metadata metadata;
+ metadata.key = ":start_with_colon";
+ metadata.value = "value";
+ metadata.value_length = 6;
+
+ grpc_op *op;
+ prepare_test(1);
+ op = g_state.ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 1;
+ op->data.send_initial_metadata.metadata = &metadata;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ GPR_ASSERT(GRPC_CALL_ERROR_INVALID_METADATA ==
+ grpc_call_start_batch(g_state.call, g_state.ops,
+ (size_t)(op - g_state.ops), tag(1), NULL));
+ cleanup_test();
+}
+
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_init();
@@ -595,6 +618,7 @@ int main(int argc, char **argv) {
test_send_server_status_twice();
test_recv_close_on_server_with_invalid_flags();
test_recv_close_on_server_twice();
+ test_invalid_initial_metadata_reserved_key();
grpc_shutdown();
return 0;
diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c
index e582c59f2d..a8e310c683 100644
--- a/test/core/end2end/tests/cancel_after_accept.c
+++ b/test/core/end2end/tests/cancel_after_accept.c
@@ -251,7 +251,11 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_call_destroy(c);
grpc_call_destroy(s);
- if (args != NULL) grpc_channel_args_destroy(args);
+ if (args != NULL) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
cq_verifier_destroy(cqv);
end_test(&f);
diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c
index 81fc7091f8..d7efe7747b 100644
--- a/test/core/end2end/tests/compressed_payload.c
+++ b/test/core/end2end/tests/compressed_payload.c
@@ -140,8 +140,12 @@ static void request_for_disabled_algorithm(
NULL, requested_client_compression_algorithm);
server_args =
grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_NONE);
- server_args = grpc_channel_args_compression_algorithm_set_state(
- &server_args, algorithm_to_disable, false);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ server_args = grpc_channel_args_compression_algorithm_set_state(
+ &exec_ctx, &server_args, algorithm_to_disable, false);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
f = begin_test(config, test_name, client_args, server_args);
cqv = cq_verifier_create(f.cq);
@@ -262,8 +266,12 @@ static void request_for_disabled_algorithm(
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(request_payload_recv);
- grpc_channel_args_destroy(client_args);
- grpc_channel_args_destroy(server_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, client_args);
+ grpc_channel_args_destroy(&exec_ctx, server_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
end_test(&f);
config.tear_down_data(&f);
@@ -512,8 +520,12 @@ static void request_with_payload_template(
cq_verifier_destroy(cqv);
- grpc_channel_args_destroy(client_args);
- grpc_channel_args_destroy(server_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, client_args);
+ grpc_channel_args_destroy(&exec_ctx, server_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/connectivity.c b/test/core/end2end/tests/connectivity.c
index 260297ebd4..42475c7331 100644
--- a/test/core/end2end/tests/connectivity.c
+++ b/test/core/end2end/tests/connectivity.c
@@ -68,7 +68,15 @@ static void test_connectivity(grpc_end2end_test_config config) {
gpr_thd_options thdopt = gpr_thd_options_default();
gpr_thd_id thdid;
- config.init_client(&f, NULL);
+ grpc_channel_args client_args;
+ grpc_arg arg_array[1];
+ arg_array[0].type = GRPC_ARG_INTEGER;
+ arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].value.integer = 1000;
+ client_args.args = arg_array;
+ client_args.num_args = 1;
+
+ config.init_client(&f, &client_args);
ce.channel = f.client;
ce.cq = f.cq;
diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.c
index 41ae575fff..ac9d2dd2fe 100644
--- a/test/core/end2end/tests/filter_call_init_fails.c
+++ b/test/core/end2end/tests/filter_call_init_fails.c
@@ -216,9 +216,11 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
const grpc_call_final_info *final_info,
void *and_free_memory) {}
-static void init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {}
+static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
+ grpc_channel_element *elem,
+ grpc_channel_element_args *args) {
+ return GRPC_ERROR_NONE;
+}
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {}
@@ -241,7 +243,8 @@ static const grpc_channel_filter test_filter = {
* Registration
*/
-static bool maybe_add_filter(grpc_channel_stack_builder *builder, void *arg) {
+static bool maybe_add_filter(grpc_exec_ctx *exec_ctx,
+ grpc_channel_stack_builder *builder, void *arg) {
if (g_enable_filter) {
// Want to add the filter as close to the end as possible, to make
// sure that all of the filters work well together. However, we
diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c
index bf9fd9073d..45f623c5c7 100644
--- a/test/core/end2end/tests/filter_causes_close.c
+++ b/test/core/end2end/tests/filter_causes_close.c
@@ -213,13 +213,13 @@ static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg,
grpc_slice message =
grpc_slice_from_copied_string("Failure that's not preventable.");
grpc_transport_stream_op *op = grpc_make_transport_stream_op(NULL);
- grpc_transport_stream_op_add_close(op, GRPC_STATUS_PERMISSION_DENIED,
- &message);
+ grpc_transport_stream_op_add_close(exec_ctx, op,
+ GRPC_STATUS_PERMISSION_DENIED, &message);
grpc_call_next_op(exec_ctx, elem, op);
}
- grpc_exec_ctx_sched(
+ grpc_closure_sched(
exec_ctx, calld->recv_im_ready,
- GRPC_ERROR_CREATE_REFERENCING("Forced call to close", &error, 1), NULL);
+ GRPC_ERROR_CREATE_REFERENCING("Forced call to close", &error, 1));
}
static void start_transport_stream_op(grpc_exec_ctx *exec_ctx,
@@ -228,7 +228,8 @@ static void start_transport_stream_op(grpc_exec_ctx *exec_ctx,
call_data *calld = elem->call_data;
if (op->recv_initial_metadata != NULL) {
calld->recv_im_ready = op->recv_initial_metadata_ready;
- op->recv_initial_metadata_ready = grpc_closure_create(recv_im_ready, elem);
+ op->recv_initial_metadata_ready =
+ grpc_closure_create(recv_im_ready, elem, grpc_schedule_on_exec_ctx);
}
grpc_call_next_op(exec_ctx, elem, op);
}
@@ -243,9 +244,11 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
const grpc_call_final_info *final_info,
void *and_free_memory) {}
-static void init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {}
+static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
+ grpc_channel_element *elem,
+ grpc_channel_element_args *args) {
+ return GRPC_ERROR_NONE;
+}
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {}
@@ -268,7 +271,8 @@ static const grpc_channel_filter test_filter = {
* Registration
*/
-static bool maybe_add_filter(grpc_channel_stack_builder *builder, void *arg) {
+static bool maybe_add_filter(grpc_exec_ctx *exec_ctx,
+ grpc_channel_stack_builder *builder, void *arg) {
if (g_enable_filter) {
return grpc_channel_stack_builder_prepend_filter(builder, &test_filter,
NULL, NULL);
diff --git a/test/core/end2end/tests/filter_latency.c b/test/core/end2end/tests/filter_latency.c
index ea63d45420..dbb5c8dcd9 100644
--- a/test/core/end2end/tests/filter_latency.c
+++ b/test/core/end2end/tests/filter_latency.c
@@ -281,9 +281,11 @@ static void server_destroy_call_elem(grpc_exec_ctx *exec_ctx,
gpr_mu_unlock(&g_mu);
}
-static void init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {}
+static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
+ grpc_channel_element *elem,
+ grpc_channel_element_args *args) {
+ return GRPC_ERROR_NONE;
+}
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {}
@@ -320,7 +322,8 @@ static const grpc_channel_filter test_server_filter = {
* Registration
*/
-static bool maybe_add_filter(grpc_channel_stack_builder *builder, void *arg) {
+static bool maybe_add_filter(grpc_exec_ctx *exec_ctx,
+ grpc_channel_stack_builder *builder, void *arg) {
grpc_channel_filter *filter = arg;
if (g_enable_filter) {
// Want to add the filter as close to the end as possible, to make
diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c
index 5b75f26bd2..ae5c270629 100644
--- a/test/core/end2end/tests/load_reporting_hook.c
+++ b/test/core/end2end/tests/load_reporting_hook.c
@@ -311,7 +311,11 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) {
response_msg, &initial_lr_metadata,
&trailing_lr_metadata);
end_test(&f);
- grpc_channel_args_destroy(lr_server_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, lr_server_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
config.tear_down_data(&f);
}
diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c
index c222d9dfae..4a6ef44bb3 100644
--- a/test/core/end2end/tests/max_message_length.c
+++ b/test/core/end2end/tests/max_message_length.c
@@ -168,8 +168,12 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
f = begin_test(config, "test_max_request_message_length", client_args,
server_args);
- if (client_args != NULL) grpc_channel_args_destroy(client_args);
- if (server_args != NULL) grpc_channel_args_destroy(server_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ if (client_args != NULL) grpc_channel_args_destroy(&exec_ctx, client_args);
+ if (server_args != NULL) grpc_channel_args_destroy(&exec_ctx, server_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
cqv = cq_verifier_create(f.cq);
@@ -342,9 +346,12 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
f = begin_test(config, "test_max_response_message_length", client_args,
server_args);
- if (client_args != NULL) grpc_channel_args_destroy(client_args);
- if (server_args != NULL) grpc_channel_args_destroy(server_args);
-
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ if (client_args != NULL) grpc_channel_args_destroy(&exec_ctx, client_args);
+ if (server_args != NULL) grpc_channel_args_destroy(&exec_ctx, server_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
cqv = cq_verifier_create(f.cq);
c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c
index db2e5c83de..4a88c5f2a8 100644
--- a/test/core/end2end/tests/payload.c
+++ b/test/core/end2end/tests/payload.c
@@ -126,7 +126,7 @@ static void request_response_with_payload(grpc_end2end_test_config config,
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_byte_buffer *response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- gpr_timespec deadline = five_seconds_time();
+ gpr_timespec deadline = n_seconds_time(60);
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c
index ec40c8f22d..414a03d98b 100644
--- a/test/core/end2end/tests/simple_delayed_request.c
+++ b/test/core/end2end/tests/simple_delayed_request.c
@@ -200,21 +200,36 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
static void test_simple_delayed_request_short(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
+ grpc_channel_args client_args;
+ grpc_arg arg_array[1];
+ arg_array[0].type = GRPC_ARG_INTEGER;
+ arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].value.integer = 1000;
+ client_args.args = arg_array;
+ client_args.num_args = 1;
gpr_log(GPR_INFO, "%s/%s", "test_simple_delayed_request_short", config.name);
f = config.create_fixture(NULL, NULL);
- simple_delayed_request_body(config, &f, NULL, NULL, 100000);
+
+ simple_delayed_request_body(config, &f, &client_args, NULL, 100000);
end_test(&f);
config.tear_down_data(&f);
}
static void test_simple_delayed_request_long(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
+ grpc_channel_args client_args;
+ grpc_arg arg_array[1];
+ arg_array[0].type = GRPC_ARG_INTEGER;
+ arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].value.integer = 1000;
+ client_args.args = arg_array;
+ client_args.num_args = 1;
gpr_log(GPR_INFO, "%s/%s", "test_simple_delayed_request_long", config.name);
f = config.create_fixture(NULL, NULL);
/* This timeout should be longer than a single retry */
- simple_delayed_request_body(config, &f, NULL, NULL, 1500000);
+ simple_delayed_request_body(config, &f, &client_args, NULL, 1500000);
end_test(&f);
config.tear_down_data(&f);
}
diff --git a/test/core/end2end/tests/write_buffering.c b/test/core/end2end/tests/write_buffering.c
new file mode 100644
index 0000000000..856e9f0306
--- /dev/null
+++ b/test/core/end2end/tests/write_buffering.c
@@ -0,0 +1,291 @@
+/*
+ *
+ * Copyright 2017, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "test/core/end2end/end2end_tests.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include <grpc/byte_buffer.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+#include "test/core/end2end/cq_verifier.h"
+
+static void *tag(intptr_t t) { return (void *)t; }
+
+static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
+ const char *test_name,
+ grpc_channel_args *client_args,
+ grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture f;
+ gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture(client_args, server_args);
+ config.init_server(&f, server_args);
+ config.init_client(&f, client_args);
+ return f;
+}
+
+static gpr_timespec n_seconds_time(int n) {
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+}
+
+static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+
+static void drain_cq(grpc_completion_queue *cq) {
+ grpc_event ev;
+ do {
+ ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+}
+
+static void shutdown_server(grpc_end2end_test_fixture *f) {
+ if (!f->server) return;
+ grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
+ GPR_ASSERT(grpc_completion_queue_pluck(
+ f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL)
+ .type == GRPC_OP_COMPLETE);
+ grpc_server_destroy(f->server);
+ f->server = NULL;
+}
+
+static void shutdown_client(grpc_end2end_test_fixture *f) {
+ if (!f->client) return;
+ grpc_channel_destroy(f->client);
+ f->client = NULL;
+}
+
+static void end_test(grpc_end2end_test_fixture *f) {
+ shutdown_server(f);
+ shutdown_client(f);
+
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
+}
+
+/* Client sends a request with payload, server reads then returns status. */
+static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
+ grpc_call *c;
+ grpc_call *s;
+ grpc_slice request_payload_slice1 =
+ grpc_slice_from_copied_string("hello world");
+ grpc_byte_buffer *request_payload1 =
+ grpc_raw_byte_buffer_create(&request_payload_slice1, 1);
+ grpc_slice request_payload_slice2 = grpc_slice_from_copied_string("abc123");
+ grpc_byte_buffer *request_payload2 =
+ grpc_raw_byte_buffer_create(&request_payload_slice2, 1);
+ gpr_timespec deadline = five_seconds_time();
+ grpc_end2end_test_fixture f =
+ begin_test(config, "test_invoke_request_with_payload", NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_op ops[6];
+ grpc_op *op;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_byte_buffer *request_payload_recv1 = NULL;
+ grpc_byte_buffer *request_payload_recv2 = NULL;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ grpc_call_error error;
+ char *details = NULL;
+ size_t details_capacity = 0;
+ int was_cancelled = 2;
+
+ c = grpc_channel_create_call(
+ f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo",
+ get_host_override_string("foo.test.google.fr:1234", config), deadline,
+ NULL);
+ GPR_ASSERT(c);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
+ f.server, &s, &call_details,
+ &request_metadata_recv, f.cq, f.cq, tag(101)));
+ CQ_EXPECT_COMPLETION(cqv, tag(1), true); /* send message is buffered */
+ CQ_EXPECT_COMPLETION(cqv, tag(101), true);
+ cq_verify(cqv);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_MESSAGE;
+ op->data.send_message = request_payload1;
+ op->flags = GRPC_WRITE_BUFFER_HINT;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ /* recv message should not succeed yet - it's buffered at the client still */
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message = &request_payload_recv1;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(2), true);
+ CQ_EXPECT_COMPLETION(cqv, tag(3), true);
+ CQ_EXPECT_COMPLETION(cqv, tag(102), true);
+ cq_verify(cqv);
+
+ /* send another message, this time not buffered */
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_MESSAGE;
+ op->data.send_message = request_payload2;
+ op->flags = 0;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ /* now the first send should match up with the first recv */
+ CQ_EXPECT_COMPLETION(cqv, tag(103), true);
+ CQ_EXPECT_COMPLETION(cqv, tag(4), true);
+ cq_verify(cqv);
+
+ /* and the next recv should be ready immediately also */
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message = &request_payload_recv2;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(104), true);
+ cq_verify(cqv);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->data.recv_status_on_client.status_details_capacity = &details_capacity;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), NULL);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status = GRPC_STATUS_OK;
+ op->data.send_status_from_server.status_details = "xyz";
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(105), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(105), 1);
+ CQ_EXPECT_COMPLETION(cqv, tag(4), 1);
+ cq_verify(cqv);
+
+ GPR_ASSERT(status == GRPC_STATUS_OK);
+ GPR_ASSERT(0 == strcmp(details, "xyz"));
+ GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
+ validate_host_override_string("foo.test.google.fr:1234", call_details.host,
+ config);
+ GPR_ASSERT(was_cancelled == 0);
+ GPR_ASSERT(byte_buffer_eq_string(request_payload_recv1, "hello world"));
+ GPR_ASSERT(byte_buffer_eq_string(request_payload_recv2, "abc123"));
+
+ gpr_free(details);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+
+ grpc_call_destroy(c);
+ grpc_call_destroy(s);
+
+ cq_verifier_destroy(cqv);
+
+ grpc_byte_buffer_destroy(request_payload1);
+ grpc_byte_buffer_destroy(request_payload_recv1);
+ grpc_byte_buffer_destroy(request_payload2);
+ grpc_byte_buffer_destroy(request_payload_recv2);
+
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+void write_buffering(grpc_end2end_test_config config) {
+ test_invoke_request_with_payload(config);
+}
+
+void write_buffering_pre_init(void) {}
diff --git a/test/core/end2end/tests/write_buffering_at_end.c b/test/core/end2end/tests/write_buffering_at_end.c
new file mode 100644
index 0000000000..43aefcbdbc
--- /dev/null
+++ b/test/core/end2end/tests/write_buffering_at_end.c
@@ -0,0 +1,280 @@
+/*
+ *
+ * Copyright 2017, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "test/core/end2end/end2end_tests.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include <grpc/byte_buffer.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+#include "test/core/end2end/cq_verifier.h"
+
+static void *tag(intptr_t t) { return (void *)t; }
+
+static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
+ const char *test_name,
+ grpc_channel_args *client_args,
+ grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture f;
+ gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture(client_args, server_args);
+ config.init_server(&f, server_args);
+ config.init_client(&f, client_args);
+ return f;
+}
+
+static gpr_timespec n_seconds_time(int n) {
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+}
+
+static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+
+static void drain_cq(grpc_completion_queue *cq) {
+ grpc_event ev;
+ do {
+ ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+}
+
+static void shutdown_server(grpc_end2end_test_fixture *f) {
+ if (!f->server) return;
+ grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
+ GPR_ASSERT(grpc_completion_queue_pluck(
+ f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL)
+ .type == GRPC_OP_COMPLETE);
+ grpc_server_destroy(f->server);
+ f->server = NULL;
+}
+
+static void shutdown_client(grpc_end2end_test_fixture *f) {
+ if (!f->client) return;
+ grpc_channel_destroy(f->client);
+ f->client = NULL;
+}
+
+static void end_test(grpc_end2end_test_fixture *f) {
+ shutdown_server(f);
+ shutdown_client(f);
+
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
+}
+
+/* Client sends a request with payload, server reads then returns status. */
+static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
+ grpc_call *c;
+ grpc_call *s;
+ grpc_slice request_payload_slice =
+ grpc_slice_from_copied_string("hello world");
+ grpc_byte_buffer *request_payload =
+ grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ gpr_timespec deadline = five_seconds_time();
+ grpc_end2end_test_fixture f =
+ begin_test(config, "test_invoke_request_with_payload", NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_op ops[6];
+ grpc_op *op;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_byte_buffer *request_payload_recv1 = NULL;
+ grpc_byte_buffer *request_payload_recv2 = NULL;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ grpc_call_error error;
+ char *details = NULL;
+ size_t details_capacity = 0;
+ int was_cancelled = 2;
+
+ c = grpc_channel_create_call(
+ f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo",
+ get_host_override_string("foo.test.google.fr:1234", config), deadline,
+ NULL);
+ GPR_ASSERT(c);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
+ f.server, &s, &call_details,
+ &request_metadata_recv, f.cq, f.cq, tag(101)));
+ CQ_EXPECT_COMPLETION(cqv, tag(1), true); /* send message is buffered */
+ CQ_EXPECT_COMPLETION(cqv, tag(101), true);
+ cq_verify(cqv);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_MESSAGE;
+ op->data.send_message = request_payload;
+ op->flags = GRPC_WRITE_BUFFER_HINT;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ /* recv message should not succeed yet - it's buffered at the client still */
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message = &request_payload_recv1;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(2), true);
+ CQ_EXPECT_COMPLETION(cqv, tag(3), true);
+ CQ_EXPECT_COMPLETION(cqv, tag(102), true);
+ cq_verify(cqv);
+
+ /* send end of stream: should release the buffering */
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ /* now the first send should match up with the first recv */
+ CQ_EXPECT_COMPLETION(cqv, tag(103), true);
+ CQ_EXPECT_COMPLETION(cqv, tag(4), true);
+ cq_verify(cqv);
+
+ /* and the next recv should be ready immediately also (and empty) */
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message = &request_payload_recv2;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(104), true);
+ cq_verify(cqv);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->data.recv_status_on_client.status_details_capacity = &details_capacity;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), NULL);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status = GRPC_STATUS_OK;
+ op->data.send_status_from_server.status_details = "xyz";
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(105), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(105), 1);
+ CQ_EXPECT_COMPLETION(cqv, tag(4), 1);
+ cq_verify(cqv);
+
+ GPR_ASSERT(status == GRPC_STATUS_OK);
+ GPR_ASSERT(0 == strcmp(details, "xyz"));
+ GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
+ validate_host_override_string("foo.test.google.fr:1234", call_details.host,
+ config);
+ GPR_ASSERT(was_cancelled == 0);
+ GPR_ASSERT(byte_buffer_eq_string(request_payload_recv1, "hello world"));
+ GPR_ASSERT(request_payload_recv2 == NULL);
+
+ gpr_free(details);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+
+ grpc_call_destroy(c);
+ grpc_call_destroy(s);
+
+ cq_verifier_destroy(cqv);
+
+ grpc_byte_buffer_destroy(request_payload);
+ grpc_byte_buffer_destroy(request_payload_recv1);
+
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+void write_buffering_at_end(grpc_end2end_test_config config) {
+ test_invoke_request_with_payload(config);
+}
+
+void write_buffering_at_end_pre_init(void) {}
diff --git a/test/core/http/BUILD b/test/core/http/BUILD
new file mode 100644
index 0000000000..037ede3cd1
--- /dev/null
+++ b/test/core/http/BUILD
@@ -0,0 +1,49 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+licenses(["notice"]) # 3-clause BSD
+
+load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
+
+grpc_fuzzer(
+ name = "response_fuzzer",
+ srcs = ["response_fuzzer.c"],
+ deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util"],
+ corpus = "response_corpus",
+ copts = ["-std=c99"],
+)
+
+grpc_fuzzer(
+ name = "request_fuzzer",
+ srcs = ["request_fuzzer.c"],
+ deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util"],
+ corpus = "request_corpus",
+ copts = ["-std=c99"],
+)
+
diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.c
index 702ddf7428..fbf696f65e 100644
--- a/test/core/http/httpcli_test.c
+++ b/test/core/http/httpcli_test.c
@@ -90,10 +90,11 @@ static void test_get(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get");
- grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, resource_quota, &req,
- n_seconds_time(15),
- grpc_closure_create(on_finish, &response), &response);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_httpcli_get(
+ &exec_ctx, &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
+ grpc_closure_create(on_finish, &response, grpc_schedule_on_exec_ctx),
+ &response);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@@ -130,10 +131,12 @@ static void test_post(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post");
- grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, resource_quota, &req,
- "hello", 5, n_seconds_time(15),
- grpc_closure_create(on_finish, &response), &response);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_httpcli_post(
+ &exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello", 5,
+ n_seconds_time(15),
+ grpc_closure_create(on_finish, &response, grpc_schedule_on_exec_ctx),
+ &response);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@@ -207,7 +210,8 @@ int main(int argc, char **argv) {
test_post(port);
grpc_httpcli_context_destroy(&g_context);
- grpc_closure_init(&destroyed, destroy_pops, &g_pops);
+ grpc_closure_init(&destroyed, destroy_pops, &g_pops,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
&destroyed);
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.c
index be46000e81..67a9a6798a 100644
--- a/test/core/http/httpscli_test.c
+++ b/test/core/http/httpscli_test.c
@@ -91,10 +91,11 @@ static void test_get(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get");
- grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, resource_quota, &req,
- n_seconds_time(15),
- grpc_closure_create(on_finish, &response), &response);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_httpcli_get(
+ &exec_ctx, &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
+ grpc_closure_create(on_finish, &response, grpc_schedule_on_exec_ctx),
+ &response);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@@ -132,10 +133,12 @@ static void test_post(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post");
- grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, resource_quota, &req,
- "hello", 5, n_seconds_time(15),
- grpc_closure_create(on_finish, &response), &response);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_httpcli_post(
+ &exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello", 5,
+ n_seconds_time(15),
+ grpc_closure_create(on_finish, &response, grpc_schedule_on_exec_ctx),
+ &response);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@@ -210,7 +213,8 @@ int main(int argc, char **argv) {
test_post(port);
grpc_httpcli_context_destroy(&g_context);
- grpc_closure_init(&destroyed, destroy_pops, &g_pops);
+ grpc_closure_init(&destroyed, destroy_pops, &g_pops,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
&destroyed);
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/internal_api_canaries/iomgr.c b/test/core/internal_api_canaries/iomgr.c
index de03c47c13..3225b9dc19 100644
--- a/test/core/internal_api_canaries/iomgr.c
+++ b/test/core/internal_api_canaries/iomgr.c
@@ -48,7 +48,7 @@
static void test_code(void) {
/* iomgr.h */
grpc_iomgr_init();
- grpc_iomgr_shutdown();
+ grpc_iomgr_shutdown(NULL);
/* closure.h */
grpc_closure closure;
@@ -60,9 +60,9 @@ static void test_code(void) {
closure_list.head = NULL;
closure_list.tail = NULL;
- grpc_closure_init(&closure, NULL, NULL);
+ grpc_closure_init(&closure, NULL, NULL, grpc_schedule_on_exec_ctx);
- grpc_closure_create(NULL, NULL);
+ grpc_closure_create(NULL, NULL, grpc_schedule_on_exec_ctx);
grpc_closure_list_move(NULL, NULL);
grpc_closure_list_append(NULL, NULL, GRPC_ERROR_CREATE("Foo"));
@@ -72,8 +72,8 @@ static void test_code(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_exec_ctx_flush(&exec_ctx);
grpc_exec_ctx_finish(&exec_ctx);
- grpc_exec_ctx_sched(&exec_ctx, &closure, GRPC_ERROR_CREATE("Foo"), NULL);
- grpc_exec_ctx_enqueue_list(&exec_ctx, &closure_list, NULL);
+ grpc_closure_sched(&exec_ctx, &closure, GRPC_ERROR_CREATE("Foo"));
+ grpc_closure_list_sched(&exec_ctx, &closure_list);
/* endpoint.h */
grpc_endpoint endpoint;
@@ -99,8 +99,7 @@ static void test_code(void) {
/* executor.h */
grpc_executor_init();
- grpc_executor_push(&closure, GRPC_ERROR_CREATE("Phi"));
- grpc_executor_shutdown();
+ grpc_executor_shutdown(NULL);
/* pollset.h */
grpc_pollset_size();
diff --git a/test/core/iomgr/combiner_test.c b/test/core/iomgr/combiner_test.c
index f7d5809be7..9b6d6ff9b4 100644
--- a/test/core/iomgr/combiner_test.c
+++ b/test/core/iomgr/combiner_test.c
@@ -59,9 +59,10 @@ static void test_execute_one(void) {
grpc_combiner *lock = grpc_combiner_create(NULL);
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_combiner_execute(&exec_ctx, lock,
- grpc_closure_create(set_bool_to_true, &done),
- GRPC_ERROR_NONE, false);
+ grpc_closure_sched(&exec_ctx,
+ grpc_closure_create(set_bool_to_true, &done,
+ grpc_combiner_scheduler(lock, false)),
+ GRPC_ERROR_NONE);
grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(done);
grpc_combiner_destroy(&exec_ctx, lock);
@@ -94,9 +95,10 @@ static void execute_many_loop(void *a) {
ex_args *c = gpr_malloc(sizeof(*c));
c->ctr = &args->ctr;
c->value = n++;
- grpc_combiner_execute(&exec_ctx, args->lock,
- grpc_closure_create(check_one, c), GRPC_ERROR_NONE,
- false);
+ grpc_closure_sched(
+ &exec_ctx, grpc_closure_create(check_one, c, grpc_combiner_scheduler(
+ args->lock, false)),
+ GRPC_ERROR_NONE);
grpc_exec_ctx_flush(&exec_ctx);
}
// sleep for a little bit, to test a combiner draining and another thread
@@ -134,9 +136,10 @@ static void in_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
}
static void add_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- grpc_combiner_execute_finally(exec_ctx, arg,
- grpc_closure_create(in_finally, NULL),
- GRPC_ERROR_NONE, false);
+ grpc_closure_sched(exec_ctx, grpc_closure_create(
+ in_finally, NULL,
+ grpc_combiner_finally_scheduler(arg, false)),
+ GRPC_ERROR_NONE);
}
static void test_execute_finally(void) {
@@ -144,8 +147,10 @@ static void test_execute_finally(void) {
grpc_combiner *lock = grpc_combiner_create(NULL);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_combiner_execute(&exec_ctx, lock, grpc_closure_create(add_finally, lock),
- GRPC_ERROR_NONE, false);
+ grpc_closure_sched(&exec_ctx,
+ grpc_closure_create(add_finally, lock,
+ grpc_combiner_scheduler(lock, false)),
+ GRPC_ERROR_NONE);
grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(got_in_finally);
grpc_combiner_destroy(&exec_ctx, lock);
diff --git a/test/core/iomgr/endpoint_pair_test.c b/test/core/iomgr/endpoint_pair_test.c
index 2a257a7cea..f02171f2ef 100644
--- a/test/core/iomgr/endpoint_pair_test.c
+++ b/test/core/iomgr/endpoint_pair_test.c
@@ -81,7 +81,8 @@ int main(int argc, char **argv) {
g_pollset = gpr_malloc(grpc_pollset_size());
grpc_pollset_init(g_pollset, &g_mu);
grpc_endpoint_tests(configs[0], g_pollset, g_mu);
- grpc_closure_init(&destroyed, destroy_pollset, g_pollset);
+ grpc_closure_init(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c
index 8186ea7e85..df5dd20903 100644
--- a/test/core/iomgr/endpoint_tests.c
+++ b/test/core/iomgr/endpoint_tests.c
@@ -41,6 +41,8 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
+
+#include "src/core/lib/slice/slice_internal.h"
#include "test/core/util/test_config.h"
/*
@@ -211,9 +213,10 @@ static void read_and_write_test(grpc_endpoint_test_config config,
state.write_done = 0;
state.current_read_data = 0;
state.current_write_data = 0;
- grpc_closure_init(&state.done_read, read_and_write_test_read_handler, &state);
+ grpc_closure_init(&state.done_read, read_and_write_test_read_handler, &state,
+ grpc_schedule_on_exec_ctx);
grpc_closure_init(&state.done_write, read_and_write_test_write_handler,
- &state);
+ &state, grpc_schedule_on_exec_ctx);
grpc_slice_buffer_init(&state.outgoing);
grpc_slice_buffer_init(&state.incoming);
@@ -249,8 +252,8 @@ static void read_and_write_test(grpc_endpoint_test_config config,
grpc_exec_ctx_flush(&exec_ctx);
end_test(config);
- grpc_slice_buffer_destroy(&state.outgoing);
- grpc_slice_buffer_destroy(&state.incoming);
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &state.outgoing);
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
grpc_endpoint_destroy(&exec_ctx, state.read_ep);
grpc_endpoint_destroy(&exec_ctx, state.write_ep);
grpc_exec_ctx_finish(&exec_ctx);
@@ -290,21 +293,24 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
grpc_endpoint_read(&exec_ctx, f.client_ep, &slice_buffer,
- grpc_closure_create(inc_on_failure, &fail_count));
+ grpc_closure_create(inc_on_failure, &fail_count,
+ grpc_schedule_on_exec_ctx));
wait_for_fail_count(&exec_ctx, &fail_count, 0);
grpc_endpoint_shutdown(&exec_ctx, f.client_ep);
wait_for_fail_count(&exec_ctx, &fail_count, 1);
grpc_endpoint_read(&exec_ctx, f.client_ep, &slice_buffer,
- grpc_closure_create(inc_on_failure, &fail_count));
+ grpc_closure_create(inc_on_failure, &fail_count,
+ grpc_schedule_on_exec_ctx));
wait_for_fail_count(&exec_ctx, &fail_count, 2);
grpc_slice_buffer_add(&slice_buffer, grpc_slice_from_copied_string("a"));
grpc_endpoint_write(&exec_ctx, f.client_ep, &slice_buffer,
- grpc_closure_create(inc_on_failure, &fail_count));
+ grpc_closure_create(inc_on_failure, &fail_count,
+ grpc_schedule_on_exec_ctx));
wait_for_fail_count(&exec_ctx, &fail_count, 3);
grpc_endpoint_shutdown(&exec_ctx, f.client_ep);
wait_for_fail_count(&exec_ctx, &fail_count, 3);
- grpc_slice_buffer_destroy(&slice_buffer);
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &slice_buffer);
grpc_endpoint_destroy(&exec_ctx, f.client_ep);
grpc_endpoint_destroy(&exec_ctx, f.server_ep);
diff --git a/test/core/iomgr/ev_epoll_linux_test.c b/test/core/iomgr/ev_epoll_linux_test.c
index 564b05d7f4..40ae91bc6d 100644
--- a/test/core/iomgr/ev_epoll_linux_test.c
+++ b/test/core/iomgr/ev_epoll_linux_test.c
@@ -102,7 +102,8 @@ static void test_pollset_cleanup(grpc_exec_ctx *exec_ctx,
int i;
for (i = 0; i < num_pollsets; i++) {
- grpc_closure_init(&destroyed, destroy_pollset, pollsets[i].pollset);
+ grpc_closure_init(&destroyed, destroy_pollset, pollsets[i].pollset,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(exec_ctx, pollsets[i].pollset, &destroyed);
grpc_exec_ctx_flush(exec_ctx);
@@ -236,7 +237,11 @@ int main(int argc, char **argv) {
"strategy. and the current strategy is: '%s'",
poll_strategy);
}
- grpc_iomgr_shutdown();
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_iomgr_shutdown(&exec_ctx);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
return 0;
}
#else /* defined(GRPC_LINUX_EPOLL) */
diff --git a/test/core/iomgr/fd_conservation_posix_test.c b/test/core/iomgr/fd_conservation_posix_test.c
index 652b37eb6f..3dffa02c3c 100644
--- a/test/core/iomgr/fd_conservation_posix_test.c
+++ b/test/core/iomgr/fd_conservation_posix_test.c
@@ -65,6 +65,10 @@ int main(int argc, char **argv) {
grpc_resource_quota_unref(resource_quota);
- grpc_iomgr_shutdown();
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_iomgr_shutdown(&exec_ctx);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
return 0;
}
diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c
index 6166699fe6..a617bfc646 100644
--- a/test/core/iomgr/fd_posix_test.c
+++ b/test/core/iomgr/fd_posix_test.c
@@ -219,8 +219,8 @@ static void listen_cb(grpc_exec_ctx *exec_ctx, void *arg, /*=sv_arg*/
se->sv = sv;
se->em_fd = grpc_fd_create(fd, "listener");
grpc_pollset_add_fd(exec_ctx, g_pollset, se->em_fd);
- se->session_read_closure.cb = session_read_cb;
- se->session_read_closure.cb_arg = se;
+ grpc_closure_init(&se->session_read_closure, session_read_cb, se,
+ grpc_schedule_on_exec_ctx);
grpc_fd_notify_on_read(exec_ctx, se->em_fd, &se->session_read_closure);
grpc_fd_notify_on_read(exec_ctx, listen_em_fd, &sv->listen_closure);
@@ -249,8 +249,8 @@ static int server_start(grpc_exec_ctx *exec_ctx, server *sv) {
sv->em_fd = grpc_fd_create(fd, "server");
grpc_pollset_add_fd(exec_ctx, g_pollset, sv->em_fd);
/* Register to be interested in reading from listen_fd. */
- sv->listen_closure.cb = listen_cb;
- sv->listen_closure.cb_arg = sv;
+ grpc_closure_init(&sv->listen_closure, listen_cb, sv,
+ grpc_schedule_on_exec_ctx);
grpc_fd_notify_on_read(exec_ctx, sv->em_fd, &sv->listen_closure);
return port;
@@ -333,8 +333,8 @@ static void client_session_write(grpc_exec_ctx *exec_ctx, void *arg, /*client */
if (errno == EAGAIN) {
gpr_mu_lock(g_mu);
if (cl->client_write_cnt < CLIENT_TOTAL_WRITE_CNT) {
- cl->write_closure.cb = client_session_write;
- cl->write_closure.cb_arg = cl;
+ grpc_closure_init(&cl->write_closure, client_session_write, cl,
+ grpc_schedule_on_exec_ctx);
grpc_fd_notify_on_write(exec_ctx, cl->em_fd, &cl->write_closure);
cl->client_write_cnt++;
} else {
@@ -459,10 +459,10 @@ static void test_grpc_fd_change(void) {
grpc_closure second_closure;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- first_closure.cb = first_read_callback;
- first_closure.cb_arg = &a;
- second_closure.cb = second_read_callback;
- second_closure.cb_arg = &b;
+ grpc_closure_init(&first_closure, first_read_callback, &a,
+ grpc_schedule_on_exec_ctx);
+ grpc_closure_init(&second_closure, second_read_callback, &b,
+ grpc_schedule_on_exec_ctx);
init_change_data(&a);
init_change_data(&b);
@@ -546,11 +546,13 @@ int main(int argc, char **argv) {
grpc_pollset_init(g_pollset, &g_mu);
test_grpc_fd();
test_grpc_fd_change();
- grpc_closure_init(&destroyed, destroy_pollset, g_pollset);
+ grpc_closure_init(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_exec_ctx_flush(&exec_ctx);
gpr_free(g_pollset);
- grpc_iomgr_shutdown();
+ grpc_iomgr_shutdown(&exec_ctx);
+ grpc_exec_ctx_finish(&exec_ctx);
return 0;
}
diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c
index 1e9e6abb2a..84f4ed4c90 100644
--- a/test/core/iomgr/resolve_address_test.c
+++ b/test/core/iomgr/resolve_address_test.c
@@ -71,9 +71,10 @@ void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) {
grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset);
grpc_pollset_set_destroy(args->pollset_set);
grpc_closure do_nothing_cb;
- grpc_closure_init(&do_nothing_cb, do_nothing, NULL);
+ grpc_closure_init(&do_nothing_cb, do_nothing, NULL,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb);
- // exec_ctx needs to be flushed before calling grpc_pollset_shutdown
+ // exec_ctx needs to be flushed before calling grpc_pollset_destroy()
grpc_exec_ctx_flush(exec_ctx);
grpc_pollset_destroy(args->pollset);
gpr_free(args->pollset);
@@ -136,8 +137,10 @@ static void test_localhost(void) {
args_struct args;
args_init(&exec_ctx, &args);
poll_pollset_until_request_done(&args);
- grpc_resolve_address(&exec_ctx, "localhost:1", NULL, args.pollset_set,
- grpc_closure_create(must_succeed, &args), &args.addrs);
+ grpc_resolve_address(
+ &exec_ctx, "localhost:1", NULL, args.pollset_set,
+ grpc_closure_create(must_succeed, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
args_finish(&exec_ctx, &args);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -147,8 +150,10 @@ static void test_default_port(void) {
args_struct args;
args_init(&exec_ctx, &args);
poll_pollset_until_request_done(&args);
- grpc_resolve_address(&exec_ctx, "localhost", "1", args.pollset_set,
- grpc_closure_create(must_succeed, &args), &args.addrs);
+ grpc_resolve_address(
+ &exec_ctx, "localhost", "1", args.pollset_set,
+ grpc_closure_create(must_succeed, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
args_finish(&exec_ctx, &args);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -158,8 +163,10 @@ static void test_missing_default_port(void) {
args_struct args;
args_init(&exec_ctx, &args);
poll_pollset_until_request_done(&args);
- grpc_resolve_address(&exec_ctx, "localhost", NULL, args.pollset_set,
- grpc_closure_create(must_fail, &args), &args.addrs);
+ grpc_resolve_address(
+ &exec_ctx, "localhost", NULL, args.pollset_set,
+ grpc_closure_create(must_fail, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
args_finish(&exec_ctx, &args);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -169,8 +176,10 @@ static void test_ipv6_with_port(void) {
args_struct args;
args_init(&exec_ctx, &args);
poll_pollset_until_request_done(&args);
- grpc_resolve_address(&exec_ctx, "[2001:db8::1]:1", NULL, args.pollset_set,
- grpc_closure_create(must_succeed, &args), &args.addrs);
+ grpc_resolve_address(
+ &exec_ctx, "[2001:db8::1]:1", NULL, args.pollset_set,
+ grpc_closure_create(must_succeed, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
args_finish(&exec_ctx, &args);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -185,8 +194,10 @@ static void test_ipv6_without_port(void) {
args_struct args;
args_init(&exec_ctx, &args);
poll_pollset_until_request_done(&args);
- grpc_resolve_address(&exec_ctx, kCases[i], "80", args.pollset_set,
- grpc_closure_create(must_succeed, &args), &args.addrs);
+ grpc_resolve_address(
+ &exec_ctx, kCases[i], "80", args.pollset_set,
+ grpc_closure_create(must_succeed, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
args_finish(&exec_ctx, &args);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -202,8 +213,10 @@ static void test_invalid_ip_addresses(void) {
args_struct args;
args_init(&exec_ctx, &args);
poll_pollset_until_request_done(&args);
- grpc_resolve_address(&exec_ctx, kCases[i], NULL, args.pollset_set,
- grpc_closure_create(must_fail, &args), &args.addrs);
+ grpc_resolve_address(
+ &exec_ctx, kCases[i], NULL, args.pollset_set,
+ grpc_closure_create(must_fail, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
args_finish(&exec_ctx, &args);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -219,8 +232,10 @@ static void test_unparseable_hostports(void) {
args_struct args;
args_init(&exec_ctx, &args);
poll_pollset_until_request_done(&args);
- grpc_resolve_address(&exec_ctx, kCases[i], "1", args.pollset_set,
- grpc_closure_create(must_fail, &args), &args.addrs);
+ grpc_resolve_address(
+ &exec_ctx, kCases[i], "1", args.pollset_set,
+ grpc_closure_create(must_fail, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
args_finish(&exec_ctx, &args);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -237,7 +252,11 @@ int main(int argc, char **argv) {
test_ipv6_without_port();
test_invalid_ip_addresses();
test_unparseable_hostports();
- grpc_iomgr_shutdown();
- grpc_executor_shutdown();
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_executor_shutdown(&exec_ctx);
+ grpc_iomgr_shutdown(&exec_ctx);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
return 0;
}
diff --git a/test/core/iomgr/resource_quota_test.c b/test/core/iomgr/resource_quota_test.c
index a82d44f7f8..a5b28f210d 100644
--- a/test/core/iomgr/resource_quota_test.c
+++ b/test/core/iomgr/resource_quota_test.c
@@ -36,6 +36,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/lib/slice/slice_internal.h"
#include "test/core/util/test_config.h"
static void inc_int_cb(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) {
@@ -45,7 +46,9 @@ static void inc_int_cb(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) {
static void set_bool_cb(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) {
*(bool *)a = true;
}
-grpc_closure *set_bool(bool *p) { return grpc_closure_create(set_bool_cb, p); }
+grpc_closure *set_bool(bool *p) {
+ return grpc_closure_create(set_bool_cb, p, grpc_schedule_on_exec_ctx);
+}
typedef struct {
size_t size;
@@ -67,7 +70,7 @@ grpc_closure *make_reclaimer(grpc_resource_user *resource_user, size_t size,
a->size = size;
a->resource_user = resource_user;
a->then = then;
- return grpc_closure_create(reclaimer_cb, a);
+ return grpc_closure_create(reclaimer_cb, a, grpc_schedule_on_exec_ctx);
}
static void unused_reclaimer_cb(grpc_exec_ctx *exec_ctx, void *arg,
@@ -76,7 +79,8 @@ static void unused_reclaimer_cb(grpc_exec_ctx *exec_ctx, void *arg,
grpc_closure_run(exec_ctx, arg, GRPC_ERROR_NONE);
}
grpc_closure *make_unused_reclaimer(grpc_closure *then) {
- return grpc_closure_create(unused_reclaimer_cb, then);
+ return grpc_closure_create(unused_reclaimer_cb, then,
+ grpc_schedule_on_exec_ctx);
}
static void destroy_user(grpc_resource_user *usr) {
@@ -631,7 +635,11 @@ static void test_one_slice(void) {
GPR_ASSERT(num_allocs == start_allocs + 1);
}
- grpc_slice_buffer_destroy(&buffer);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
destroy_user(usr);
grpc_resource_quota_unref(q);
}
@@ -667,7 +675,11 @@ static void test_one_slice_deleted_late(void) {
}
grpc_resource_quota_unref(q);
- grpc_slice_buffer_destroy(&buffer);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
}
int main(int argc, char **argv) {
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c
index 5fab826fb7..0ea7a000eb 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -113,7 +113,7 @@ void test_succeeds(void) {
/* connect to it */
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)addr,
(socklen_t *)&resolved_addr.len) == 0);
- grpc_closure_init(&done, must_succeed, NULL);
+ grpc_closure_init(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx);
grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL,
&resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME));
@@ -163,7 +163,7 @@ void test_fails(void) {
gpr_mu_unlock(g_mu);
/* connect to a broken address */
- grpc_closure_init(&done, must_fail, NULL);
+ grpc_closure_init(&done, must_fail, NULL, grpc_schedule_on_exec_ctx);
grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL,
&resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME));
@@ -207,7 +207,8 @@ int main(int argc, char **argv) {
gpr_log(GPR_ERROR, "End of first test");
test_fails();
grpc_pollset_set_destroy(g_pollset_set);
- grpc_closure_init(&destroyed, destroy_pollset, g_pollset);
+ grpc_closure_init(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c
index 5eafa570bb..cabb64eb8f 100644
--- a/test/core/iomgr/tcp_posix_test.c
+++ b/test/core/iomgr/tcp_posix_test.c
@@ -50,6 +50,8 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
+
+#include "src/core/lib/slice/slice_internal.h"
#include "test/core/iomgr/endpoint_tests.h"
#include "test/core/util/test_config.h"
@@ -184,7 +186,7 @@ static void read_test(size_t num_bytes, size_t slice_size) {
grpc_resource_quota *resource_quota = grpc_resource_quota_create("read_test");
ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), resource_quota,
slice_size, "test");
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes);
@@ -194,7 +196,7 @@ static void read_test(size_t num_bytes, size_t slice_size) {
state.read_bytes = 0;
state.target_read_bytes = written_bytes;
grpc_slice_buffer_init(&state.incoming);
- grpc_closure_init(&state.read_cb, read_cb, &state);
+ grpc_closure_init(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
@@ -212,7 +214,7 @@ static void read_test(size_t num_bytes, size_t slice_size) {
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy(&state.incoming);
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
grpc_endpoint_destroy(&exec_ctx, ep);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -235,7 +237,7 @@ static void large_read_test(size_t slice_size) {
grpc_resource_quota_create("large_read_test");
ep = grpc_tcp_create(grpc_fd_create(sv[1], "large_read_test"), resource_quota,
slice_size, "test");
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
written_bytes = fill_socket(sv[0]);
@@ -245,7 +247,7 @@ static void large_read_test(size_t slice_size) {
state.read_bytes = 0;
state.target_read_bytes = (size_t)written_bytes;
grpc_slice_buffer_init(&state.incoming);
- grpc_closure_init(&state.read_cb, read_cb, &state);
+ grpc_closure_init(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
@@ -263,7 +265,7 @@ static void large_read_test(size_t slice_size) {
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy(&state.incoming);
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
grpc_endpoint_destroy(&exec_ctx, ep);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -374,7 +376,7 @@ static void write_test(size_t num_bytes, size_t slice_size) {
grpc_resource_quota_create("write_test");
ep = grpc_tcp_create(grpc_fd_create(sv[1], "write_test"), resource_quota,
GRPC_TCP_DEFAULT_READ_SLICE_SIZE, "test");
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
state.ep = ep;
@@ -384,7 +386,8 @@ static void write_test(size_t num_bytes, size_t slice_size) {
grpc_slice_buffer_init(&outgoing);
grpc_slice_buffer_addn(&outgoing, slices, num_blocks);
- grpc_closure_init(&write_done_closure, write_done, &state);
+ grpc_closure_init(&write_done_closure, write_done, &state,
+ grpc_schedule_on_exec_ctx);
grpc_endpoint_write(&exec_ctx, ep, &outgoing, &write_done_closure);
drain_socket_blocking(sv[0], num_bytes, num_bytes);
@@ -404,7 +407,7 @@ static void write_test(size_t num_bytes, size_t slice_size) {
}
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy(&outgoing);
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &outgoing);
grpc_endpoint_destroy(&exec_ctx, ep);
gpr_free(slices);
grpc_exec_ctx_finish(&exec_ctx);
@@ -429,7 +432,8 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_closure fd_released_cb;
int fd_released_done = 0;
- grpc_closure_init(&fd_released_cb, &on_fd_released, &fd_released_done);
+ grpc_closure_init(&fd_released_cb, &on_fd_released, &fd_released_done,
+ grpc_schedule_on_exec_ctx);
gpr_log(GPR_INFO,
"Release fd read_test of size %" PRIuPTR ", slice size %" PRIuPTR,
@@ -442,7 +446,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), resource_quota,
slice_size, "test");
GPR_ASSERT(grpc_tcp_fd(ep) == sv[1] && sv[1] >= 0);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes);
@@ -452,7 +456,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
state.read_bytes = 0;
state.target_read_bytes = written_bytes;
grpc_slice_buffer_init(&state.incoming);
- grpc_closure_init(&state.read_cb, read_cb, &state);
+ grpc_closure_init(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
@@ -472,7 +476,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy(&state.incoming);
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
grpc_tcp_destroy_and_release_fd(&exec_ctx, ep, &fd, &fd_released_cb);
grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(g_mu);
@@ -534,7 +538,7 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
resource_quota, slice_size, "test");
f.server_ep = grpc_tcp_create(grpc_fd_create(sv[1], "fixture:server"),
resource_quota, slice_size, "test");
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
grpc_endpoint_add_to_pollset(&exec_ctx, f.server_ep, g_pollset);
@@ -561,7 +565,8 @@ int main(int argc, char **argv) {
grpc_pollset_init(g_pollset, &g_mu);
grpc_endpoint_tests(configs[0], g_pollset, g_mu);
run_tests();
- grpc_closure_init(&destroyed, destroy_pollset, g_pollset);
+ grpc_closure_init(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c
index 1b8a39c1be..020f005980 100644
--- a/test/core/iomgr/tcp_server_posix_test.c
+++ b/test/core/iomgr/tcp_server_posix_test.c
@@ -104,7 +104,7 @@ static void server_weak_ref_shutdown(grpc_exec_ctx *exec_ctx, void *arg,
static void server_weak_ref_init(server_weak_ref *weak_ref) {
weak_ref->server = NULL;
grpc_closure_init(&weak_ref->server_shutdown, server_weak_ref_shutdown,
- weak_ref);
+ weak_ref, grpc_schedule_on_exec_ctx);
}
/* Make weak_ref->server_shutdown a shutdown_starting cb on server.
@@ -126,6 +126,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
on_connect_result temp_result;
on_connect_result_set(&temp_result, acceptor);
+ gpr_free(acceptor);
gpr_mu_lock(g_mu);
g_result = temp_result;
@@ -365,7 +366,8 @@ int main(int argc, char **argv) {
test_connect(1);
test_connect(10);
- grpc_closure_init(&destroyed, destroy_pollset, g_pollset);
+ grpc_closure_init(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.c
index be8988ab75..8d7ac3fdaa 100644
--- a/test/core/iomgr/timer_list_test.c
+++ b/test/core/iomgr/timer_list_test.c
@@ -57,17 +57,20 @@ static void add_test(void) {
/* 10 ms timers. will expire in the current epoch */
for (i = 0; i < 10; i++) {
- grpc_timer_init(&exec_ctx, &timers[i],
- gpr_time_add(start, gpr_time_from_millis(10, GPR_TIMESPAN)),
- cb, (void *)(intptr_t)i, start);
+ grpc_timer_init(
+ &exec_ctx, &timers[i],
+ gpr_time_add(start, gpr_time_from_millis(10, GPR_TIMESPAN)),
+ grpc_closure_create(cb, (void *)(intptr_t)i, grpc_schedule_on_exec_ctx),
+ start);
}
/* 1010 ms timers. will expire in the next epoch */
for (i = 10; i < 20; i++) {
grpc_timer_init(
&exec_ctx, &timers[i],
- gpr_time_add(start, gpr_time_from_millis(1010, GPR_TIMESPAN)), cb,
- (void *)(intptr_t)i, start);
+ gpr_time_add(start, gpr_time_from_millis(1010, GPR_TIMESPAN)),
+ grpc_closure_create(cb, (void *)(intptr_t)i, grpc_schedule_on_exec_ctx),
+ start);
}
/* collect timers. Only the first batch should be ready. */
@@ -125,16 +128,26 @@ void destruction_test(void) {
grpc_timer_list_init(gpr_time_0(GPR_CLOCK_REALTIME));
memset(cb_called, 0, sizeof(cb_called));
- grpc_timer_init(&exec_ctx, &timers[0], tfm(100), cb, (void *)(intptr_t)0,
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(&exec_ctx, &timers[1], tfm(3), cb, (void *)(intptr_t)1,
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(&exec_ctx, &timers[2], tfm(100), cb, (void *)(intptr_t)2,
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(&exec_ctx, &timers[3], tfm(3), cb, (void *)(intptr_t)3,
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(&exec_ctx, &timers[4], tfm(1), cb, (void *)(intptr_t)4,
- gpr_time_0(GPR_CLOCK_REALTIME));
+ grpc_timer_init(
+ &exec_ctx, &timers[0], tfm(100),
+ grpc_closure_create(cb, (void *)(intptr_t)0, grpc_schedule_on_exec_ctx),
+ gpr_time_0(GPR_CLOCK_REALTIME));
+ grpc_timer_init(
+ &exec_ctx, &timers[1], tfm(3),
+ grpc_closure_create(cb, (void *)(intptr_t)1, grpc_schedule_on_exec_ctx),
+ gpr_time_0(GPR_CLOCK_REALTIME));
+ grpc_timer_init(
+ &exec_ctx, &timers[2], tfm(100),
+ grpc_closure_create(cb, (void *)(intptr_t)2, grpc_schedule_on_exec_ctx),
+ gpr_time_0(GPR_CLOCK_REALTIME));
+ grpc_timer_init(
+ &exec_ctx, &timers[3], tfm(3),
+ grpc_closure_create(cb, (void *)(intptr_t)3, grpc_schedule_on_exec_ctx),
+ gpr_time_0(GPR_CLOCK_REALTIME));
+ grpc_timer_init(
+ &exec_ctx, &timers[4], tfm(1),
+ grpc_closure_create(cb, (void *)(intptr_t)4, grpc_schedule_on_exec_ctx),
+ gpr_time_0(GPR_CLOCK_REALTIME));
GPR_ASSERT(1 == grpc_timer_check(&exec_ctx, tfm(2), NULL));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(1 == cb_called[4][1]);
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index 9bea229466..e1210401c8 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -234,11 +234,12 @@ int main(int argc, char **argv) {
test_receive(1);
test_receive(10);
- grpc_closure_init(&destroyed, destroy_pollset, g_pollset);
+ grpc_closure_init(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
grpc_exec_ctx_finish(&exec_ctx);
gpr_free(g_pollset);
- grpc_iomgr_shutdown();
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/json/BUILD b/test/core/json/BUILD
new file mode 100644
index 0000000000..05d4c6e0c5
--- /dev/null
+++ b/test/core/json/BUILD
@@ -0,0 +1,41 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+licenses(["notice"]) # 3-clause BSD
+
+load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
+
+grpc_fuzzer(
+ name = "json_fuzzer",
+ srcs = ["fuzzer.c"],
+ deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util"],
+ corpus = "corpus",
+ copts = ["-std=c99"],
+)
+
diff --git a/test/core/memory_usage/client.c b/test/core/memory_usage/client.c
new file mode 100644
index 0000000000..f4432bf572
--- /dev/null
+++ b/test/core/memory_usage/client.c
@@ -0,0 +1,316 @@
+/*
+ *
+ * Copyright 2016, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <grpc/grpc.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include <grpc/byte_buffer.h>
+#include <grpc/byte_buffer_reader.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/cmdline.h>
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+#include "src/core/lib/support/string.h"
+#include "test/core/util/memory_counters.h"
+#include "test/core/util/test_config.h"
+
+static grpc_channel *channel;
+static grpc_completion_queue *cq;
+static grpc_op metadata_ops[2];
+static grpc_op status_ops[2];
+static grpc_op snapshot_ops[6];
+static grpc_op *op;
+
+typedef struct {
+ grpc_call *call;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_status_code status;
+ char *details;
+ size_t details_capacity;
+ grpc_metadata_array trailing_metadata_recv;
+} fling_call;
+
+// Statically allocate call data structs. Enough to accomodate 10000 ping-pong
+// calls and 1 extra for the snapshot calls.
+static fling_call calls[10001];
+
+static void *tag(intptr_t t) { return (void *)t; }
+
+// A call is intentionally divided into two steps. First step is to initiate a
+// call (i.e send and recv metadata). A call is outstanding after we initated,
+// so we can measure the call memory usage.
+static void init_ping_pong_request(int call_idx) {
+ grpc_metadata_array_init(&calls[call_idx].initial_metadata_recv);
+
+ memset(metadata_ops, 0, sizeof(metadata_ops));
+ op = metadata_ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata = &calls[call_idx].initial_metadata_recv;
+ op++;
+
+ calls[call_idx].call = grpc_channel_create_call(
+ channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/Reflector/reflectUnary",
+ "localhost", gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call,
+ metadata_ops,
+ (size_t)(op - metadata_ops),
+ tag(call_idx), NULL));
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+}
+
+// Second step is to finish the call (i.e recv status) and destroy the call.
+static void finish_ping_pong_request(int call_idx) {
+ grpc_metadata_array_init(&calls[call_idx].trailing_metadata_recv);
+
+ memset(status_ops, 0, sizeof(status_ops));
+ op = status_ops;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata =
+ &calls[call_idx].trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &calls[call_idx].status;
+ op->data.recv_status_on_client.status_details = &calls[call_idx].details;
+ op->data.recv_status_on_client.status_details_capacity =
+ &calls[call_idx].details_capacity;
+ op++;
+
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call,
+ status_ops,
+ (size_t)(op - status_ops),
+ tag(call_idx), NULL));
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ grpc_metadata_array_destroy(&calls[call_idx].initial_metadata_recv);
+ grpc_metadata_array_destroy(&calls[call_idx].trailing_metadata_recv);
+ gpr_free(calls[call_idx].details);
+ grpc_call_destroy(calls[call_idx].call);
+ calls[call_idx].call = NULL;
+}
+
+static struct grpc_memory_counters send_snapshot_request(
+ int call_idx, const char *call_type) {
+ grpc_metadata_array_init(&calls[call_idx].initial_metadata_recv);
+ grpc_metadata_array_init(&calls[call_idx].trailing_metadata_recv);
+
+ grpc_byte_buffer *response_payload_recv = NULL;
+ memset(snapshot_ops, 0, sizeof(snapshot_ops));
+ op = snapshot_ops;
+
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata = &calls[call_idx].initial_metadata_recv;
+ op++;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message = &response_payload_recv;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata =
+ &calls[call_idx].trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &calls[call_idx].status;
+ op->data.recv_status_on_client.status_details = &calls[call_idx].details;
+ op->data.recv_status_on_client.status_details_capacity =
+ &calls[call_idx].details_capacity;
+ op++;
+
+ calls[call_idx].call = grpc_channel_create_call(
+ channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, call_type, "localhost",
+ gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(
+ calls[call_idx].call, snapshot_ops,
+ (size_t)(op - snapshot_ops), (void *)0, NULL));
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+
+ grpc_byte_buffer_reader reader;
+ grpc_byte_buffer_reader_init(&reader, response_payload_recv);
+ grpc_slice response = grpc_byte_buffer_reader_readall(&reader);
+
+ struct grpc_memory_counters snapshot;
+ snapshot.total_size_absolute =
+ ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response))
+ ->total_size_absolute;
+ snapshot.total_allocs_absolute =
+ ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response))
+ ->total_allocs_absolute;
+ snapshot.total_size_relative =
+ ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response))
+ ->total_size_relative;
+ snapshot.total_allocs_relative =
+ ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response))
+ ->total_allocs_relative;
+
+ grpc_metadata_array_destroy(&calls[call_idx].initial_metadata_recv);
+ grpc_metadata_array_destroy(&calls[call_idx].trailing_metadata_recv);
+ grpc_slice_unref(response);
+ grpc_byte_buffer_reader_destroy(&reader);
+ grpc_byte_buffer_destroy(response_payload_recv);
+ gpr_free(calls[call_idx].details);
+ calls[call_idx].details = NULL;
+ calls[call_idx].details_capacity = 0;
+ grpc_call_destroy(calls[call_idx].call);
+ calls[call_idx].call = NULL;
+
+ return snapshot;
+}
+
+int main(int argc, char **argv) {
+ grpc_memory_counters_init();
+ grpc_slice slice = grpc_slice_from_copied_string("x");
+ char *fake_argv[1];
+
+ char *target = "localhost:443";
+ gpr_cmdline *cl;
+ grpc_event event;
+
+ grpc_init();
+
+ GPR_ASSERT(argc >= 1);
+ fake_argv[0] = argv[0];
+ grpc_test_init(1, fake_argv);
+
+ int warmup_iterations = 100;
+ int benchmark_iterations = 1000;
+
+ cl = gpr_cmdline_create("memory profiling client");
+ gpr_cmdline_add_string(cl, "target", "Target host:port", &target);
+ gpr_cmdline_add_int(cl, "warmup", "Warmup iterations", &warmup_iterations);
+ gpr_cmdline_add_int(cl, "benchmark", "Benchmark iterations",
+ &benchmark_iterations);
+ gpr_cmdline_parse(cl, argc, argv);
+ gpr_cmdline_destroy(cl);
+
+ for (int k = 0; k < (int)(sizeof(calls) / sizeof(fling_call)); k++) {
+ calls[k].details = NULL;
+ calls[k].details_capacity = 0;
+ }
+
+ cq = grpc_completion_queue_create(NULL);
+
+ struct grpc_memory_counters client_channel_start =
+ grpc_memory_counters_snapshot();
+ channel = grpc_insecure_channel_create(target, NULL, NULL);
+
+ int call_idx = 0;
+
+ struct grpc_memory_counters before_server_create =
+ send_snapshot_request(0, "Reflector/GetBeforeSvrCreation");
+ struct grpc_memory_counters after_server_create =
+ send_snapshot_request(0, "Reflector/GetAfterSvrCreation");
+
+ // warmup period
+ for (call_idx = 0; call_idx < warmup_iterations; ++call_idx) {
+ init_ping_pong_request(call_idx + 1);
+ }
+
+ struct grpc_memory_counters server_benchmark_calls_start =
+ send_snapshot_request(0, "Reflector/SimpleSnapshot");
+
+ struct grpc_memory_counters client_benchmark_calls_start =
+ grpc_memory_counters_snapshot();
+
+ // benchmark period
+ for (; call_idx < warmup_iterations + benchmark_iterations; ++call_idx) {
+ init_ping_pong_request(call_idx + 1);
+ }
+
+ struct grpc_memory_counters client_calls_inflight =
+ grpc_memory_counters_snapshot();
+
+ struct grpc_memory_counters server_calls_inflight =
+ send_snapshot_request(0, "Reflector/DestroyCalls");
+
+ do {
+ event = grpc_completion_queue_next(
+ cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(10000, GPR_TIMESPAN)),
+ NULL);
+ } while (event.type != GRPC_QUEUE_TIMEOUT);
+
+ // second step - recv status and destroy call
+ for (call_idx = 0; call_idx < warmup_iterations + benchmark_iterations;
+ ++call_idx) {
+ finish_ping_pong_request(call_idx + 1);
+ }
+
+ struct grpc_memory_counters server_calls_end =
+ send_snapshot_request(0, "Reflector/SimpleSnapshot");
+
+ struct grpc_memory_counters client_channel_end =
+ grpc_memory_counters_snapshot();
+
+ grpc_channel_destroy(channel);
+ grpc_completion_queue_shutdown(cq);
+
+ do {
+ event = grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
+ NULL);
+ } while (event.type != GRPC_QUEUE_SHUTDOWN);
+ grpc_slice_unref(slice);
+
+ grpc_completion_queue_destroy(cq);
+ grpc_shutdown();
+
+ gpr_log(GPR_INFO, "---------client stats--------");
+ gpr_log(GPR_INFO, "client call memory usage: %f bytes per call",
+ (double)(client_calls_inflight.total_size_relative -
+ client_benchmark_calls_start.total_size_relative) /
+ benchmark_iterations);
+ gpr_log(GPR_INFO, "client channel memory usage %zi bytes",
+ client_channel_end.total_size_relative -
+ client_channel_start.total_size_relative);
+
+ gpr_log(GPR_INFO, "---------server stats--------");
+ gpr_log(GPR_INFO, "server create: %zi bytes",
+ after_server_create.total_size_relative -
+ before_server_create.total_size_relative);
+ gpr_log(GPR_INFO, "server call memory usage: %f bytes per call",
+ (double)(server_calls_inflight.total_size_relative -
+ server_benchmark_calls_start.total_size_relative) /
+ benchmark_iterations);
+ gpr_log(GPR_INFO, "server channel memory usage %zi bytes",
+ server_calls_end.total_size_relative -
+ after_server_create.total_size_relative);
+
+ grpc_memory_counters_destroy();
+ return 0;
+}
diff --git a/test/core/memory_usage/memory_usage_test.c b/test/core/memory_usage/memory_usage_test.c
new file mode 100644
index 0000000000..7e7a9d050d
--- /dev/null
+++ b/test/core/memory_usage/memory_usage_test.c
@@ -0,0 +1,93 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/host_port.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/subprocess.h>
+#include "src/core/lib/support/string.h"
+#include "test/core/util/port.h"
+
+int main(int argc, char **argv) {
+ char *me = argv[0];
+ char *lslash = strrchr(me, '/');
+ char root[1024];
+ int port = grpc_pick_unused_port_or_die();
+ char *args[10];
+ int status;
+ gpr_subprocess *svr, *cli;
+ /* figure out where we are */
+ if (lslash) {
+ memcpy(root, me, (size_t)(lslash - me));
+ root[lslash - me] = 0;
+ } else {
+ strcpy(root, ".");
+ }
+ /* start the server */
+ gpr_asprintf(&args[0], "%s/memory_profile_server%s", root,
+ gpr_subprocess_binary_extension());
+ args[1] = "--bind";
+ gpr_join_host_port(&args[2], "::", port);
+ args[3] = "--no-secure";
+ svr = gpr_subprocess_create(4, (const char **)args);
+ gpr_free(args[0]);
+ gpr_free(args[2]);
+
+ /* start the client */
+ gpr_asprintf(&args[0], "%s/memory_profile_client%s", root,
+ gpr_subprocess_binary_extension());
+ args[1] = "--target";
+ gpr_join_host_port(&args[2], "127.0.0.1", port);
+ args[3] = "--warmup=1000";
+ args[4] = "--benchmark=9000";
+ cli = gpr_subprocess_create(5, (const char **)args);
+ gpr_free(args[0]);
+ gpr_free(args[2]);
+
+ /* wait for completion */
+ printf("waiting for client\n");
+ if ((status = gpr_subprocess_join(cli))) {
+ gpr_subprocess_destroy(cli);
+ gpr_subprocess_destroy(svr);
+ return status;
+ }
+ gpr_subprocess_destroy(cli);
+
+ gpr_subprocess_interrupt(svr);
+ status = gpr_subprocess_join(svr);
+ gpr_subprocess_destroy(svr);
+ return status;
+}
diff --git a/test/core/memory_usage/server.c b/test/core/memory_usage/server.c
new file mode 100644
index 0000000000..c0710930b0
--- /dev/null
+++ b/test/core/memory_usage/server.c
@@ -0,0 +1,321 @@
+/*
+ *
+ * Copyright 2016, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <grpc/grpc.h>
+#include <grpc/grpc_security.h>
+
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#ifndef _WIN32
+/* This is for _exit() below, which is temporary. */
+#include <unistd.h>
+#endif
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/cmdline.h>
+#include <grpc/support/host_port.h>
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+#include "test/core/end2end/data/ssl_test_data.h"
+#include "test/core/util/memory_counters.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+static grpc_completion_queue *cq;
+static grpc_server *server;
+static grpc_op metadata_ops[2];
+static grpc_op snapshot_ops[5];
+static grpc_op status_op;
+static int got_sigint = 0;
+static grpc_byte_buffer *payload_buffer = NULL;
+static grpc_byte_buffer *terminal_buffer = NULL;
+static int was_cancelled = 2;
+
+static void *tag(intptr_t t) { return (void *)t; }
+
+typedef enum {
+ FLING_SERVER_NEW_REQUEST = 1,
+ FLING_SERVER_SEND_INIT_METADATA,
+ FLING_SERVER_WAIT_FOR_DESTROY,
+ FLING_SERVER_SEND_STATUS_FLING_CALL,
+ FLING_SERVER_SEND_STATUS_SNAPSHOT,
+ FLING_SERVER_BATCH_SEND_STATUS_FLING_CALL
+} fling_server_tags;
+
+typedef struct {
+ fling_server_tags state;
+ grpc_call *call;
+ grpc_call_details call_details;
+ grpc_metadata_array request_metadata_recv;
+ grpc_metadata_array initial_metadata_send;
+} fling_call;
+
+// hold up to 10000 calls and 6 snaphost calls
+static fling_call calls[100006];
+
+static void request_call_unary(int call_idx) {
+ if (call_idx == (int)(sizeof(calls) / sizeof(fling_call))) {
+ gpr_log(GPR_INFO, "Used all call slots (10000) on server. Server exit.");
+ _exit(0);
+ }
+ grpc_metadata_array_init(&calls[call_idx].request_metadata_recv);
+ grpc_server_request_call(
+ server, &calls[call_idx].call, &calls[call_idx].call_details,
+ &calls[call_idx].request_metadata_recv, cq, cq, &calls[call_idx]);
+}
+
+static void send_initial_metadata_unary(void *tag) {
+ grpc_metadata_array_init(&(*(fling_call *)tag).initial_metadata_send);
+ metadata_ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
+ metadata_ops[0].data.send_initial_metadata.count = 0;
+
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call *)tag).call,
+ metadata_ops, 1, tag, NULL));
+}
+
+static void send_status(void *tag) {
+ status_op.op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ status_op.data.send_status_from_server.status = GRPC_STATUS_OK;
+ status_op.data.send_status_from_server.trailing_metadata_count = 0;
+ status_op.data.send_status_from_server.status_details = "";
+
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call *)tag).call,
+ &status_op, 1, tag, NULL));
+}
+
+static void send_snapshot(void *tag, struct grpc_memory_counters *snapshot) {
+ grpc_op *op;
+
+ grpc_slice snapshot_slice =
+ grpc_slice_new(snapshot, sizeof(*snapshot), gpr_free);
+ payload_buffer = grpc_raw_byte_buffer_create(&snapshot_slice, 1);
+ grpc_metadata_array_init(&(*(fling_call *)tag).initial_metadata_send);
+
+ op = snapshot_ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op++;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message = &terminal_buffer;
+ op++;
+ op->op = GRPC_OP_SEND_MESSAGE;
+ if (payload_buffer == NULL) {
+ gpr_log(GPR_INFO, "NULL payload buffer !!!");
+ }
+ op->data.send_message = payload_buffer;
+ op++;
+ op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.status = GRPC_STATUS_OK;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status_details = "";
+ op++;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op++;
+
+ GPR_ASSERT(GRPC_CALL_OK ==
+ grpc_call_start_batch((*(fling_call *)tag).call, snapshot_ops,
+ (size_t)(op - snapshot_ops), tag, NULL));
+}
+/* We have some sort of deadlock, so let's not exit gracefully for now.
+ When that is resolved, please remove the #include <unistd.h> above. */
+static void sigint_handler(int x) { _exit(0); }
+
+int main(int argc, char **argv) {
+ grpc_memory_counters_init();
+ grpc_event ev;
+ char *addr_buf = NULL;
+ gpr_cmdline *cl;
+ int shutdown_started = 0;
+ int shutdown_finished = 0;
+
+ int secure = 0;
+ char *addr = NULL;
+
+ char *fake_argv[1];
+
+ GPR_ASSERT(argc >= 1);
+ fake_argv[0] = argv[0];
+ grpc_test_init(1, fake_argv);
+
+ grpc_init();
+ srand((unsigned)clock());
+
+ cl = gpr_cmdline_create("fling server");
+ gpr_cmdline_add_string(cl, "bind", "Bind host:port", &addr);
+ gpr_cmdline_add_flag(cl, "secure", "Run with security?", &secure);
+ gpr_cmdline_parse(cl, argc, argv);
+ gpr_cmdline_destroy(cl);
+
+ if (addr == NULL) {
+ gpr_join_host_port(&addr_buf, "::", grpc_pick_unused_port_or_die());
+ addr = addr_buf;
+ }
+ gpr_log(GPR_INFO, "creating server on: %s", addr);
+
+ cq = grpc_completion_queue_create(NULL);
+
+ struct grpc_memory_counters before_server_create =
+ grpc_memory_counters_snapshot();
+ if (secure) {
+ grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key,
+ test_server1_cert};
+ grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create(
+ NULL, &pem_key_cert_pair, 1, 0, NULL);
+ server = grpc_server_create(NULL, NULL);
+ GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds));
+ grpc_server_credentials_release(ssl_creds);
+ } else {
+ server = grpc_server_create(NULL, NULL);
+ GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr));
+ }
+
+ grpc_server_register_completion_queue(server, cq, NULL);
+ grpc_server_start(server);
+
+ struct grpc_memory_counters after_server_create =
+ grpc_memory_counters_snapshot();
+
+ gpr_free(addr_buf);
+ addr = addr_buf = NULL;
+
+ // initialize call instances
+ for (int i = 0; i < (int)(sizeof(calls) / sizeof(fling_call)); i++) {
+ grpc_call_details_init(&calls[i].call_details);
+ calls[i].state = FLING_SERVER_NEW_REQUEST;
+ }
+
+ int next_call_idx = 0;
+ struct grpc_memory_counters current_snapshot;
+
+ request_call_unary(next_call_idx);
+
+ signal(SIGINT, sigint_handler);
+
+ while (!shutdown_finished) {
+ if (got_sigint && !shutdown_started) {
+ gpr_log(GPR_INFO, "Shutting down due to SIGINT");
+ grpc_server_shutdown_and_notify(server, cq, tag(1000));
+ GPR_ASSERT(grpc_completion_queue_pluck(
+ cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL)
+ .type == GRPC_OP_COMPLETE);
+ grpc_completion_queue_shutdown(cq);
+ shutdown_started = 1;
+ }
+ ev = grpc_completion_queue_next(
+ cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000000, GPR_TIMESPAN)),
+ NULL);
+ fling_call *s = ev.tag;
+ switch (ev.type) {
+ case GRPC_OP_COMPLETE:
+ switch (s->state) {
+ case FLING_SERVER_NEW_REQUEST:
+ request_call_unary(++next_call_idx);
+ if (0 ==
+ strcmp(s->call_details.method, "/Reflector/reflectUnary")) {
+ s->state = FLING_SERVER_SEND_INIT_METADATA;
+ send_initial_metadata_unary(s);
+ } else if (0 == strcmp(s->call_details.method,
+ "Reflector/GetBeforeSvrCreation")) {
+ s->state = FLING_SERVER_SEND_STATUS_SNAPSHOT;
+ send_snapshot(s, &before_server_create);
+ } else if (0 == strcmp(s->call_details.method,
+ "Reflector/GetAfterSvrCreation")) {
+ s->state = FLING_SERVER_SEND_STATUS_SNAPSHOT;
+ send_snapshot(s, &after_server_create);
+ } else if (0 == strcmp(s->call_details.method,
+ "Reflector/SimpleSnapshot")) {
+ s->state = FLING_SERVER_SEND_STATUS_SNAPSHOT;
+ current_snapshot = grpc_memory_counters_snapshot();
+ send_snapshot(s, &current_snapshot);
+ } else if (0 == strcmp(s->call_details.method,
+ "Reflector/DestroyCalls")) {
+ s->state = FLING_SERVER_BATCH_SEND_STATUS_FLING_CALL;
+ current_snapshot = grpc_memory_counters_snapshot();
+ send_snapshot(s, &current_snapshot);
+ } else {
+ gpr_log(GPR_ERROR, "Wrong call method");
+ }
+ break;
+ case FLING_SERVER_SEND_INIT_METADATA:
+ s->state = FLING_SERVER_WAIT_FOR_DESTROY;
+ break;
+ case FLING_SERVER_WAIT_FOR_DESTROY:
+ break;
+ case FLING_SERVER_SEND_STATUS_FLING_CALL:
+ grpc_call_destroy(s->call);
+ grpc_call_details_destroy(&s->call_details);
+ grpc_metadata_array_destroy(&s->initial_metadata_send);
+ grpc_metadata_array_destroy(&s->request_metadata_recv);
+ break;
+ case FLING_SERVER_BATCH_SEND_STATUS_FLING_CALL:
+ for (int k = 0; k < (int)(sizeof(calls) / sizeof(fling_call));
+ ++k) {
+ if (calls[k].state == FLING_SERVER_WAIT_FOR_DESTROY) {
+ calls[k].state = FLING_SERVER_SEND_STATUS_FLING_CALL;
+ send_status(&calls[k]);
+ }
+ }
+ // no break here since we want to continue to case
+ // FLING_SERVER_SEND_STATUS_SNAPSHOT to destroy the snapshot call
+ case FLING_SERVER_SEND_STATUS_SNAPSHOT:
+ grpc_byte_buffer_destroy(payload_buffer);
+ grpc_byte_buffer_destroy(terminal_buffer);
+ grpc_call_destroy(s->call);
+ grpc_call_details_destroy(&s->call_details);
+ grpc_metadata_array_destroy(&s->initial_metadata_send);
+ grpc_metadata_array_destroy(&s->request_metadata_recv);
+ terminal_buffer = NULL;
+ payload_buffer = NULL;
+ break;
+ }
+ break;
+ case GRPC_QUEUE_SHUTDOWN:
+ GPR_ASSERT(shutdown_started);
+ shutdown_finished = 1;
+ break;
+ case GRPC_QUEUE_TIMEOUT:
+ break;
+ }
+ }
+
+ grpc_server_destroy(server);
+ grpc_completion_queue_destroy(cq);
+ grpc_shutdown();
+ grpc_memory_counters_destroy();
+ return 0;
+}
diff --git a/test/core/nanopb/BUILD b/test/core/nanopb/BUILD
new file mode 100644
index 0000000000..b02d750f32
--- /dev/null
+++ b/test/core/nanopb/BUILD
@@ -0,0 +1,49 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+licenses(["notice"]) # 3-clause BSD
+
+load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
+
+grpc_fuzzer(
+ name = "fuzzer_response",
+ srcs = ["fuzzer_response.c"],
+ deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util"],
+ corpus = "corpus_response",
+ copts = ["-std=c99"],
+)
+
+grpc_fuzzer(
+ name = "fuzzer_serverlist",
+ srcs = ["fuzzer_serverlist.c"],
+ deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util"],
+ corpus = "corpus_serverlist",
+ copts = ["-std=c99"],
+)
+
diff --git a/test/core/security/b64_test.c b/test/core/security/b64_test.c
index af883f51e9..28af48075e 100644
--- a/test/core/security/b64_test.c
+++ b/test/core/security/b64_test.c
@@ -38,6 +38,8 @@
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "test/core/util/test_config.h"
static int buffers_are_equal(const unsigned char *buf1,
@@ -57,12 +59,14 @@ static void test_simple_encode_decode_b64(int url_safe, int multiline) {
const char *hello = "hello";
char *hello_b64 =
grpc_base64_encode(hello, strlen(hello), url_safe, multiline);
- grpc_slice hello_slice = grpc_base64_decode(hello_b64, url_safe);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_slice hello_slice = grpc_base64_decode(&exec_ctx, hello_b64, url_safe);
GPR_ASSERT(GRPC_SLICE_LENGTH(hello_slice) == strlen(hello));
GPR_ASSERT(strncmp((const char *)GRPC_SLICE_START_PTR(hello_slice), hello,
GRPC_SLICE_LENGTH(hello_slice)) == 0);
- grpc_slice_unref(hello_slice);
+ grpc_slice_unref_internal(&exec_ctx, hello_slice);
+ grpc_exec_ctx_finish(&exec_ctx);
gpr_free(hello_b64);
}
@@ -75,13 +79,15 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
/* Try all the different paddings. */
for (i = 0; i < 3; i++) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
b64 = grpc_base64_encode(orig, sizeof(orig) - i, url_safe, multiline);
- orig_decoded = grpc_base64_decode(b64, url_safe);
+ orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe);
GPR_ASSERT(GRPC_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i));
GPR_ASSERT(buffers_are_equal(orig, GRPC_SLICE_START_PTR(orig_decoded),
sizeof(orig) - i));
- grpc_slice_unref(orig_decoded);
+ grpc_slice_unref_internal(&exec_ctx, orig_decoded);
gpr_free(b64);
+ grpc_exec_ctx_finish(&exec_ctx);
}
}
@@ -117,7 +123,7 @@ static void test_full_range_encode_decode_b64_urlsafe_multiline(void) {
test_full_range_encode_decode_b64(1, 1);
}
-static void test_url_safe_unsafe_mismtach_failure(void) {
+static void test_url_safe_unsafe_mismatch_failure(void) {
unsigned char orig[256];
size_t i;
char *b64;
@@ -125,17 +131,19 @@ static void test_url_safe_unsafe_mismtach_failure(void) {
int url_safe = 1;
for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i;
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0);
- orig_decoded = grpc_base64_decode(b64, !url_safe);
+ orig_decoded = grpc_base64_decode(&exec_ctx, b64, !url_safe);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
- grpc_slice_unref(orig_decoded);
+ grpc_slice_unref_internal(&exec_ctx, orig_decoded);
b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0);
- orig_decoded = grpc_base64_decode(b64, url_safe);
+ orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
- grpc_slice_unref(orig_decoded);
+ grpc_slice_unref_internal(&exec_ctx, orig_decoded);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_rfc4648_test_vectors(void) {
@@ -173,38 +181,40 @@ static void test_rfc4648_test_vectors(void) {
static void test_unpadded_decode(void) {
grpc_slice decoded;
- decoded = grpc_base64_decode("Zm9vYmFy", 0);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmFy", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foobar") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode("Zm9vYmE", 0);
+ decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmE", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fooba") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode("Zm9vYg", 0);
+ decoded = grpc_base64_decode(&exec_ctx, "Zm9vYg", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foob") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode("Zm9v", 0);
+ decoded = grpc_base64_decode(&exec_ctx, "Zm9v", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foo") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode("Zm8", 0);
+ decoded = grpc_base64_decode(&exec_ctx, "Zm8", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fo") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode("Zg", 0);
+ decoded = grpc_base64_decode(&exec_ctx, "Zg", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "f") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode("", 0);
+ decoded = grpc_base64_decode(&exec_ctx, "", 0);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(decoded));
+ grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char **argv) {
@@ -217,7 +227,7 @@ int main(int argc, char **argv) {
test_full_range_encode_decode_b64_multiline();
test_full_range_encode_decode_b64_urlsafe_no_multiline();
test_full_range_encode_decode_b64_urlsafe_multiline();
- test_url_safe_unsafe_mismtach_failure();
+ test_url_safe_unsafe_mismatch_failure();
test_rfc4648_test_vectors();
test_unpadded_decode();
return 0;
diff --git a/test/core/security/create_jwt.c b/test/core/security/create_jwt.c
index 741ace9bdd..ac795f29d2 100644
--- a/test/core/security/create_jwt.c
+++ b/test/core/security/create_jwt.c
@@ -72,6 +72,7 @@ int main(int argc, char **argv) {
char *scope = NULL;
char *json_key_file_path = NULL;
char *service_url = NULL;
+ grpc_init();
gpr_cmdline *cl = gpr_cmdline_create("create_jwt");
gpr_cmdline_add_string(cl, "json_key", "File path of the json key.",
&json_key_file_path);
@@ -102,5 +103,6 @@ int main(int argc, char **argv) {
create_jwt(json_key_file_path, service_url, scope);
gpr_cmdline_destroy(cl);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c
index d4c755088d..0a79292b5b 100644
--- a/test/core/security/credentials_test.c
+++ b/test/core/security/credentials_test.c
@@ -166,24 +166,29 @@ static grpc_httpcli_response http_response(int status, const char *body) {
/* -- Tests. -- */
static void test_empty_md_store(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *store = grpc_credentials_md_store_create(0);
GPR_ASSERT(store->num_entries == 0);
GPR_ASSERT(store->allocated == 0);
- grpc_credentials_md_store_unref(store);
+ grpc_credentials_md_store_unref(&exec_ctx, store);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_ref_unref_empty_md_store(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *store = grpc_credentials_md_store_create(0);
grpc_credentials_md_store_ref(store);
grpc_credentials_md_store_ref(store);
GPR_ASSERT(store->num_entries == 0);
GPR_ASSERT(store->allocated == 0);
- grpc_credentials_md_store_unref(store);
- grpc_credentials_md_store_unref(store);
- grpc_credentials_md_store_unref(store);
+ grpc_credentials_md_store_unref(&exec_ctx, store);
+ grpc_credentials_md_store_unref(&exec_ctx, store);
+ grpc_credentials_md_store_unref(&exec_ctx, store);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_add_to_empty_md_store(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *store = grpc_credentials_md_store_create(0);
const char *key_str = "hello";
const char *value_str = "there blah blah blah blah blah blah blah";
@@ -195,10 +200,12 @@ static void test_add_to_empty_md_store(void) {
GPR_ASSERT(grpc_slice_cmp(value, store->entries[0].value) == 0);
grpc_slice_unref(key);
grpc_slice_unref(value);
- grpc_credentials_md_store_unref(store);
+ grpc_credentials_md_store_unref(&exec_ctx, store);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_add_cstrings_to_empty_md_store(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *store = grpc_credentials_md_store_create(0);
const char *key_str = "hello";
const char *value_str = "there blah blah blah blah blah blah blah";
@@ -206,18 +213,22 @@ static void test_add_cstrings_to_empty_md_store(void) {
GPR_ASSERT(store->num_entries == 1);
GPR_ASSERT(grpc_slice_str_cmp(store->entries[0].key, key_str) == 0);
GPR_ASSERT(grpc_slice_str_cmp(store->entries[0].value, value_str) == 0);
- grpc_credentials_md_store_unref(store);
+ grpc_credentials_md_store_unref(&exec_ctx, store);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_empty_preallocated_md_store(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *store = grpc_credentials_md_store_create(4);
GPR_ASSERT(store->num_entries == 0);
GPR_ASSERT(store->allocated == 4);
GPR_ASSERT(store->entries != NULL);
- grpc_credentials_md_store_unref(store);
+ grpc_credentials_md_store_unref(&exec_ctx, store);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_add_abunch_to_md_store(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *store = grpc_credentials_md_store_create(4);
size_t num_entries = 1000;
const char *key_str = "hello";
@@ -230,16 +241,19 @@ static void test_add_abunch_to_md_store(void) {
GPR_ASSERT(grpc_slice_str_cmp(store->entries[i].key, key_str) == 0);
GPR_ASSERT(grpc_slice_str_cmp(store->entries[i].value, value_str) == 0);
}
- grpc_credentials_md_store_unref(store);
+ grpc_credentials_md_store_unref(&exec_ctx, store);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_ok(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_httpcli_response response =
http_response(200, valid_oauth2_json_response);
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &response, &token_md, &token_lifetime) == GRPC_CREDENTIALS_OK);
+ &exec_ctx, &response, &token_md, &token_lifetime) ==
+ GRPC_CREDENTIALS_OK);
GPR_ASSERT(token_lifetime.tv_sec == 3599);
GPR_ASSERT(token_lifetime.tv_nsec == 0);
GPR_ASSERT(token_md->num_entries == 1);
@@ -248,32 +262,38 @@ static void test_oauth2_token_fetcher_creds_parsing_ok(void) {
GPR_ASSERT(grpc_slice_str_cmp(token_md->entries[0].value,
"Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") ==
0);
- grpc_credentials_md_store_unref(token_md);
+ grpc_credentials_md_store_unref(&exec_ctx, token_md);
grpc_http_response_destroy(&response);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_bad_http_status(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_httpcli_response response =
http_response(401, valid_oauth2_json_response);
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &response, &token_md, &token_lifetime) ==
+ &exec_ctx, &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_empty_http_body(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_httpcli_response response = http_response(200, "");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &response, &token_md, &token_lifetime) ==
+ &exec_ctx, &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_httpcli_response response =
@@ -282,12 +302,14 @@ static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) {
" \"expires_in\":3599, "
" \"token_type\":\"Bearer\"");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &response, &token_md, &token_lifetime) ==
+ &exec_ctx, &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_httpcli_response response = http_response(200,
@@ -295,12 +317,14 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) {
" \"expires_in\":3599, "
" \"token_type\":\"Bearer\"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &response, &token_md, &token_lifetime) ==
+ &exec_ctx, &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token_type(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_httpcli_response response =
@@ -309,13 +333,15 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_type(void) {
" \"expires_in\":3599, "
"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &response, &token_md, &token_lifetime) ==
+ &exec_ctx, &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(
void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_httpcli_response response =
@@ -323,9 +349,10 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(
"{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\","
" \"token_type\":\"Bearer\"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &response, &token_md, &token_lifetime) ==
+ &exec_ctx, &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void check_metadata(expected_md *expected, grpc_credentials_md *md_elems,
@@ -361,7 +388,7 @@ static void check_google_iam_metadata(grpc_exec_ctx *exec_ctx, void *user_data,
GPR_ASSERT(error_details == NULL);
GPR_ASSERT(num_md == 2);
check_metadata(emd, md_elems, num_md);
- grpc_call_credentials_unref(c);
+ grpc_call_credentials_unref(exec_ctx, c);
}
static void test_google_iam_creds(void) {
@@ -385,7 +412,7 @@ static void check_access_token_metadata(
GPR_ASSERT(error_details == NULL);
GPR_ASSERT(num_md == 1);
check_metadata(emd, md_elems, num_md);
- grpc_call_credentials_unref(c);
+ grpc_call_credentials_unref(exec_ctx, c);
}
static void test_access_token_creds(void) {
@@ -401,9 +428,10 @@ static void test_access_token_creds(void) {
}
static grpc_security_status check_channel_oauth2_create_security_connector(
- grpc_channel_credentials *c, grpc_call_credentials *call_creds,
- const char *target, const grpc_channel_args *args,
- grpc_channel_security_connector **sc, grpc_channel_args **new_args) {
+ grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c,
+ grpc_call_credentials *call_creds, const char *target,
+ const grpc_channel_args *args, grpc_channel_security_connector **sc,
+ grpc_channel_args **new_args) {
GPR_ASSERT(strcmp(c->type, "mock") == 0);
GPR_ASSERT(call_creds != NULL);
GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
@@ -411,6 +439,7 @@ static grpc_security_status check_channel_oauth2_create_security_connector(
}
static void test_channel_oauth2_composite_creds(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_channel_args *new_args;
grpc_channel_credentials_vtable vtable = {
NULL, check_channel_oauth2_create_security_connector, NULL};
@@ -424,9 +453,10 @@ static void test_channel_oauth2_composite_creds(void) {
grpc_channel_credentials_release(channel_creds);
grpc_call_credentials_release(oauth2_creds);
GPR_ASSERT(grpc_channel_credentials_create_security_connector(
- channel_oauth2_creds, NULL, NULL, NULL, &new_args) ==
- GRPC_SECURITY_OK);
+ &exec_ctx, channel_oauth2_creds, NULL, NULL, NULL,
+ &new_args) == GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_creds);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void check_oauth2_google_iam_composite_metadata(
@@ -443,7 +473,7 @@ static void check_oauth2_google_iam_composite_metadata(
GPR_ASSERT(error_details == NULL);
GPR_ASSERT(num_md == 3);
check_metadata(emd, md_elems, num_md);
- grpc_call_credentials_unref(c);
+ grpc_call_credentials_unref(exec_ctx, c);
}
static void test_oauth2_google_iam_composite_creds(void) {
@@ -459,8 +489,8 @@ static void test_oauth2_google_iam_composite_creds(void) {
grpc_call_credentials *composite_creds =
grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds,
NULL);
- grpc_call_credentials_unref(oauth2_creds);
- grpc_call_credentials_unref(google_iam_creds);
+ grpc_call_credentials_unref(&exec_ctx, oauth2_creds);
+ grpc_call_credentials_unref(&exec_ctx, google_iam_creds);
GPR_ASSERT(
strcmp(composite_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0);
creds_array =
@@ -478,9 +508,10 @@ static void test_oauth2_google_iam_composite_creds(void) {
static grpc_security_status
check_channel_oauth2_google_iam_create_security_connector(
- grpc_channel_credentials *c, grpc_call_credentials *call_creds,
- const char *target, const grpc_channel_args *args,
- grpc_channel_security_connector **sc, grpc_channel_args **new_args) {
+ grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c,
+ grpc_call_credentials *call_creds, const char *target,
+ const grpc_channel_args *args, grpc_channel_security_connector **sc,
+ grpc_channel_args **new_args) {
const grpc_call_credentials_array *creds_array;
GPR_ASSERT(strcmp(c->type, "mock") == 0);
GPR_ASSERT(call_creds != NULL);
@@ -495,6 +526,7 @@ check_channel_oauth2_google_iam_create_security_connector(
}
static void test_channel_oauth2_google_iam_composite_creds(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_channel_args *new_args;
grpc_channel_credentials_vtable vtable = {
NULL, check_channel_oauth2_google_iam_create_security_connector, NULL};
@@ -517,10 +549,11 @@ static void test_channel_oauth2_google_iam_composite_creds(void) {
grpc_call_credentials_release(google_iam_creds);
GPR_ASSERT(grpc_channel_credentials_create_security_connector(
- channel_oauth2_iam_creds, NULL, NULL, NULL, &new_args) ==
- GRPC_SECURITY_OK);
+ &exec_ctx, channel_oauth2_iam_creds, NULL, NULL, NULL,
+ &new_args) == GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_iam_creds);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void on_oauth2_creds_get_metadata_success(
@@ -565,7 +598,7 @@ static int compute_engine_httpcli_get_success_override(
grpc_httpcli_response *response) {
validate_compute_engine_http_request(request);
*response = http_response(200, valid_oauth2_json_response);
- grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -575,7 +608,7 @@ static int compute_engine_httpcli_get_failure_override(
grpc_httpcli_response *response) {
validate_compute_engine_http_request(request);
*response = http_response(403, "Not Authorized.");
- grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -619,7 +652,7 @@ static void test_compute_engine_creds_success(void) {
on_oauth2_creds_get_metadata_success, (void *)test_user_data);
grpc_exec_ctx_finish(&exec_ctx);
- grpc_call_credentials_unref(compute_engine_creds);
+ grpc_call_credentials_unref(&exec_ctx, compute_engine_creds);
grpc_httpcli_set_override(NULL, NULL);
}
@@ -634,7 +667,7 @@ static void test_compute_engine_creds_failure(void) {
grpc_call_credentials_get_request_metadata(
&exec_ctx, compute_engine_creds, NULL, auth_md_ctx,
on_oauth2_creds_get_metadata_failure, (void *)test_user_data);
- grpc_call_credentials_unref(compute_engine_creds);
+ grpc_call_credentials_unref(&exec_ctx, compute_engine_creds);
grpc_httpcli_set_override(NULL, NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -668,7 +701,7 @@ static int refresh_token_httpcli_post_success(
grpc_closure *on_done, grpc_httpcli_response *response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(200, valid_oauth2_json_response);
- grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -678,7 +711,7 @@ static int refresh_token_httpcli_post_failure(
grpc_closure *on_done, grpc_httpcli_response *response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(403, "Not Authorized.");
- grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -706,7 +739,7 @@ static void test_refresh_token_creds_success(void) {
on_oauth2_creds_get_metadata_success, (void *)test_user_data);
grpc_exec_ctx_flush(&exec_ctx);
- grpc_call_credentials_unref(refresh_token_creds);
+ grpc_call_credentials_unref(&exec_ctx, refresh_token_creds);
grpc_httpcli_set_override(NULL, NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -723,7 +756,7 @@ static void test_refresh_token_creds_failure(void) {
grpc_call_credentials_get_request_metadata(
&exec_ctx, refresh_token_creds, NULL, auth_md_ctx,
on_oauth2_creds_get_metadata_failure, (void *)test_user_data);
- grpc_call_credentials_unref(refresh_token_creds);
+ grpc_call_credentials_unref(&exec_ctx, refresh_token_creds);
grpc_httpcli_set_override(NULL, NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -832,7 +865,7 @@ static void test_jwt_creds_success(void) {
grpc_exec_ctx_flush(&exec_ctx);
gpr_free(json_key_string);
- grpc_call_credentials_unref(jwt_creds);
+ grpc_call_credentials_unref(&exec_ctx, jwt_creds);
grpc_jwt_encode_and_sign_set_override(NULL);
}
@@ -851,7 +884,7 @@ static void test_jwt_creds_signing_failure(void) {
on_jwt_creds_get_metadata_failure, (void *)test_user_data);
gpr_free(json_key_string);
- grpc_call_credentials_unref(jwt_creds);
+ grpc_call_credentials_unref(&exec_ctx, jwt_creds);
grpc_jwt_encode_and_sign_set_override(NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -870,6 +903,7 @@ static void set_google_default_creds_env_var_with_file_contents(
}
static void test_google_default_creds_auth_key(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_service_account_jwt_access_credentials *jwt;
grpc_composite_channel_credentials *creds;
char *json_key = test_json_key_str();
@@ -885,11 +919,13 @@ static void test_google_default_creds_auth_key(void) {
strcmp(jwt->key.client_id,
"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent.com") ==
0);
- grpc_channel_credentials_unref(&creds->base);
+ grpc_channel_credentials_unref(&exec_ctx, &creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_google_default_creds_refresh_token(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_google_refresh_token_credentials *refresh;
grpc_composite_channel_credentials *creds;
grpc_flush_cached_google_default_credentials();
@@ -901,8 +937,9 @@ static void test_google_default_creds_refresh_token(void) {
refresh = (grpc_google_refresh_token_credentials *)creds->call_creds;
GPR_ASSERT(strcmp(refresh->refresh_token.client_id,
"32555999999.apps.googleusercontent.com") == 0);
- grpc_channel_credentials_unref(&creds->base);
+ grpc_channel_credentials_unref(&exec_ctx, &creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
+ grpc_exec_ctx_finish(&exec_ctx);
}
static int default_creds_gce_detection_httpcli_get_success_override(
@@ -917,7 +954,7 @@ static int default_creds_gce_detection_httpcli_get_success_override(
response->hdrs = headers;
GPR_ASSERT(strcmp(request->http.path, "/") == 0);
GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
- grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -975,7 +1012,7 @@ static int default_creds_gce_detection_httpcli_get_failure_override(
GPR_ASSERT(strcmp(request->http.path, "/") == 0);
GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
*response = http_response(200, "");
- grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -1142,6 +1179,8 @@ static void test_get_well_known_google_credentials_file_path(void) {
}
static void test_channel_creds_duplicate_without_call_creds(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+
grpc_channel_credentials *channel_creds =
grpc_fake_transport_security_credentials_create();
@@ -1149,21 +1188,23 @@ static void test_channel_creds_duplicate_without_call_creds(void) {
grpc_channel_credentials_duplicate_without_call_credentials(
channel_creds);
GPR_ASSERT(dup == channel_creds);
- grpc_channel_credentials_unref(dup);
+ grpc_channel_credentials_unref(&exec_ctx, dup);
grpc_call_credentials *call_creds =
grpc_access_token_credentials_create("blah", NULL);
grpc_channel_credentials *composite_creds =
grpc_composite_channel_credentials_create(channel_creds, call_creds,
NULL);
- grpc_call_credentials_unref(call_creds);
+ grpc_call_credentials_unref(&exec_ctx, call_creds);
dup = grpc_channel_credentials_duplicate_without_call_credentials(
composite_creds);
GPR_ASSERT(dup == channel_creds);
- grpc_channel_credentials_unref(dup);
+ grpc_channel_credentials_unref(&exec_ctx, dup);
- grpc_channel_credentials_unref(channel_creds);
- grpc_channel_credentials_unref(composite_creds);
+ grpc_channel_credentials_unref(&exec_ctx, channel_creds);
+ grpc_channel_credentials_unref(&exec_ctx, composite_creds);
+
+ grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char **argv) {
diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c
index 201655881f..5cebb09bb2 100644
--- a/test/core/security/json_token_test.c
+++ b/test/core/security/json_token_test.c
@@ -44,6 +44,7 @@
#include "src/core/lib/json/json.h"
#include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h"
#include "src/core/lib/security/util/b64.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "test/core/util/test_config.h"
/* This JSON key was generated with the GCE console and revoked immediately.
@@ -220,6 +221,7 @@ static void test_parse_json_key_failure_no_private_key(void) {
static grpc_json *parse_json_part_from_jwt(const char *str, size_t len,
char **scratchpad) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
char *b64;
char *decoded;
grpc_json *json;
@@ -227,7 +229,7 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len,
b64 = gpr_malloc(len + 1);
strncpy(b64, str, len);
b64[len] = '\0';
- slice = grpc_base64_decode(b64, 1);
+ slice = grpc_base64_decode(&exec_ctx, b64, 1);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(slice));
decoded = gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1);
strncpy(decoded, (const char *)GRPC_SLICE_START_PTR(slice),
@@ -237,6 +239,7 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len,
gpr_free(b64);
*scratchpad = decoded;
grpc_slice_unref(slice);
+ grpc_exec_ctx_finish(&exec_ctx);
return json;
}
@@ -338,10 +341,12 @@ static void check_jwt_claim(grpc_json *claim, const char *expected_audience,
static void check_jwt_signature(const char *b64_signature, RSA *rsa_key,
const char *signed_data,
size_t signed_data_size) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+
EVP_MD_CTX *md_ctx = EVP_MD_CTX_create();
EVP_PKEY *key = EVP_PKEY_new();
- grpc_slice sig = grpc_base64_decode(b64_signature, 1);
+ grpc_slice sig = grpc_base64_decode(&exec_ctx, b64_signature, 1);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
GPR_ASSERT(GRPC_SLICE_LENGTH(sig) == 128);
@@ -355,9 +360,11 @@ static void check_jwt_signature(const char *b64_signature, RSA *rsa_key,
GPR_ASSERT(EVP_DigestVerifyFinal(md_ctx, GRPC_SLICE_START_PTR(sig),
GRPC_SLICE_LENGTH(sig)) == 1);
- grpc_slice_unref(sig);
+ grpc_slice_unref_internal(&exec_ctx, sig);
if (key != NULL) EVP_PKEY_free(key);
if (md_ctx != NULL) EVP_MD_CTX_destroy(md_ctx);
+
+ grpc_exec_ctx_finish(&exec_ctx);
}
static char *service_account_creds_jwt_encode_and_sign(
diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c
index f8afba8d6d..a9bd976a39 100644
--- a/test/core/security/jwt_verifier_test.c
+++ b/test/core/security/jwt_verifier_test.c
@@ -166,6 +166,13 @@ static const char claims_without_time_constraint[] =
" \"jti\": \"jwtuniqueid\","
" \"foo\": \"bar\"}";
+static const char claims_with_bad_subject[] =
+ "{ \"aud\": \"https://foo.com\","
+ " \"iss\": \"evil@blah.foo.com\","
+ " \"sub\": \"juju@blah.foo.com\","
+ " \"jti\": \"jwtuniqueid\","
+ " \"foo\": \"bar\"}";
+
static const char invalid_claims[] =
"{ \"aud\": \"https://foo.com\","
" \"iss\": 46," /* Issuer cannot be a number. */
@@ -179,13 +186,46 @@ typedef struct {
const char *expected_subject;
} verifier_test_config;
+static void test_jwt_issuer_email_domain(void) {
+ const char *d = grpc_jwt_issuer_email_domain("https://foo.com");
+ GPR_ASSERT(d == NULL);
+ d = grpc_jwt_issuer_email_domain("foo.com");
+ GPR_ASSERT(d == NULL);
+ d = grpc_jwt_issuer_email_domain("");
+ GPR_ASSERT(d == NULL);
+ d = grpc_jwt_issuer_email_domain("@");
+ GPR_ASSERT(d == NULL);
+ d = grpc_jwt_issuer_email_domain("bar@foo");
+ GPR_ASSERT(strcmp(d, "foo") == 0);
+ d = grpc_jwt_issuer_email_domain("bar@foo.com");
+ GPR_ASSERT(strcmp(d, "foo.com") == 0);
+ d = grpc_jwt_issuer_email_domain("bar@blah.foo.com");
+ GPR_ASSERT(strcmp(d, "foo.com") == 0);
+ d = grpc_jwt_issuer_email_domain("bar.blah@blah.foo.com");
+ GPR_ASSERT(strcmp(d, "foo.com") == 0);
+ d = grpc_jwt_issuer_email_domain("bar.blah@baz.blah.foo.com");
+ GPR_ASSERT(strcmp(d, "foo.com") == 0);
+
+ /* This is not a very good parser but make sure we do not crash on these weird
+ inputs. */
+ d = grpc_jwt_issuer_email_domain("@foo");
+ GPR_ASSERT(strcmp(d, "foo") == 0);
+ d = grpc_jwt_issuer_email_domain("bar@.");
+ GPR_ASSERT(d != NULL);
+ d = grpc_jwt_issuer_email_domain("bar@..");
+ GPR_ASSERT(d != NULL);
+ d = grpc_jwt_issuer_email_domain("bar@...");
+ GPR_ASSERT(d != NULL);
+}
+
static void test_claims_success(void) {
grpc_jwt_claims *claims;
grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint);
grpc_json *json = grpc_json_parse_string_with_len(
(char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != NULL);
- claims = grpc_jwt_claims_from_json(json, s);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
GPR_ASSERT(claims != NULL);
GPR_ASSERT(grpc_jwt_claims_json(claims) == json);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), "https://foo.com") == 0);
@@ -194,7 +234,8 @@ static void test_claims_success(void) {
GPR_ASSERT(strcmp(grpc_jwt_claims_id(claims), "jwtuniqueid") == 0);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_OK);
- grpc_jwt_claims_destroy(claims);
+ grpc_jwt_claims_destroy(&exec_ctx, claims);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_expired_claims_failure(void) {
@@ -206,7 +247,8 @@ static void test_expired_claims_failure(void) {
gpr_timespec exp_exp = {120, 0, GPR_CLOCK_REALTIME};
gpr_timespec exp_nbf = {60, 0, GPR_CLOCK_REALTIME};
GPR_ASSERT(json != NULL);
- claims = grpc_jwt_claims_from_json(json, s);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
GPR_ASSERT(claims != NULL);
GPR_ASSERT(grpc_jwt_claims_json(claims) == json);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), "https://foo.com") == 0);
@@ -219,14 +261,17 @@ static void test_expired_claims_failure(void) {
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_TIME_CONSTRAINT_FAILURE);
- grpc_jwt_claims_destroy(claims);
+ grpc_jwt_claims_destroy(&exec_ctx, claims);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_invalid_claims_failure(void) {
grpc_slice s = grpc_slice_from_copied_string(invalid_claims);
grpc_json *json = grpc_json_parse_string_with_len(
(char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
- GPR_ASSERT(grpc_jwt_claims_from_json(json, s) == NULL);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GPR_ASSERT(grpc_jwt_claims_from_json(&exec_ctx, json, s) == NULL);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_bad_audience_claims_failure(void) {
@@ -235,11 +280,28 @@ static void test_bad_audience_claims_failure(void) {
grpc_json *json = grpc_json_parse_string_with_len(
(char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != NULL);
- claims = grpc_jwt_claims_from_json(json, s);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
GPR_ASSERT(claims != NULL);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://bar.com") ==
GRPC_JWT_VERIFIER_BAD_AUDIENCE);
- grpc_jwt_claims_destroy(claims);
+ grpc_jwt_claims_destroy(&exec_ctx, claims);
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+
+static void test_bad_subject_claims_failure(void) {
+ grpc_jwt_claims *claims;
+ grpc_slice s = grpc_slice_from_copied_string(claims_with_bad_subject);
+ grpc_json *json = grpc_json_parse_string_with_len(
+ (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ GPR_ASSERT(json != NULL);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
+ GPR_ASSERT(claims != NULL);
+ GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
+ GRPC_JWT_VERIFIER_BAD_SUBJECT);
+ grpc_jwt_claims_destroy(&exec_ctx, claims);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static char *json_key_str(const char *last_part) {
@@ -294,18 +356,18 @@ static int httpcli_get_google_keys_for_email(
"/robot/v1/metadata/x509/"
"777-abaslkan11hlb6nmim3bpspl31ud@developer."
"gserviceaccount.com") == 0);
- grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, on_done, GRPC_ERROR_NONE);
return 1;
}
-static void on_verification_success(void *user_data,
+static void on_verification_success(grpc_exec_ctx *exec_ctx, void *user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims *claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_OK);
GPR_ASSERT(claims != NULL);
GPR_ASSERT(user_data == (void *)expected_user_data);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), expected_audience) == 0);
- grpc_jwt_claims_destroy(claims);
+ grpc_jwt_claims_destroy(exec_ctx, claims);
}
static void test_jwt_verifier_google_email_issuer_success(void) {
@@ -338,7 +400,7 @@ static int httpcli_get_custom_keys_for_email(
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "keys.bar.com") == 0);
GPR_ASSERT(strcmp(request->http.path, "/jwk/foo@bar.com") == 0);
- grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -372,7 +434,7 @@ static int httpcli_get_jwk_set(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0);
GPR_ASSERT(strcmp(request->http.path, "/oauth2/v3/certs") == 0);
- grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -387,7 +449,7 @@ static int httpcli_get_openid_config(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(strcmp(request->http.path, GRPC_OPENID_CONFIG_URL_SUFFIX) == 0);
grpc_httpcli_set_override(httpcli_get_jwk_set,
httpcli_post_should_not_be_called);
- grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -413,7 +475,8 @@ static void test_jwt_verifier_url_issuer_success(void) {
grpc_httpcli_set_override(NULL, NULL);
}
-static void on_verification_key_retrieval_error(void *user_data,
+static void on_verification_key_retrieval_error(grpc_exec_ctx *exec_ctx,
+ void *user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims *claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR);
@@ -427,7 +490,7 @@ static int httpcli_get_bad_json(grpc_exec_ctx *exec_ctx,
grpc_httpcli_response *response) {
*response = http_response(200, gpr_strdup("{\"bad\": \"stuff\"}"));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
- grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -483,7 +546,11 @@ static void corrupt_jwt_sig(char *jwt) {
uint8_t *sig_bytes;
char *last_dot = strrchr(jwt, '.');
GPR_ASSERT(last_dot != NULL);
- sig = grpc_base64_decode(last_dot + 1, 1);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ sig = grpc_base64_decode(&exec_ctx, last_dot + 1, 1);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
sig_bytes = GRPC_SLICE_START_PTR(sig);
(*sig_bytes)++; /* Corrupt first byte. */
@@ -494,7 +561,8 @@ static void corrupt_jwt_sig(char *jwt) {
grpc_slice_unref(sig);
}
-static void on_verification_bad_signature(void *user_data,
+static void on_verification_bad_signature(grpc_exec_ctx *exec_ctx,
+ void *user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims *claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_SIGNATURE);
@@ -535,7 +603,7 @@ static int httpcli_get_should_not_be_called(grpc_exec_ctx *exec_ctx,
return 1;
}
-static void on_verification_bad_format(void *user_data,
+static void on_verification_bad_format(grpc_exec_ctx *exec_ctx, void *user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims *claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_FORMAT);
@@ -563,10 +631,12 @@ static void test_jwt_verifier_bad_format(void) {
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_init();
+ test_jwt_issuer_email_domain();
test_claims_success();
test_expired_claims_failure();
test_invalid_claims_failure();
test_bad_audience_claims_failure();
+ test_bad_subject_claims_failure();
test_jwt_verifier_google_email_issuer_success();
test_jwt_verifier_custom_email_issuer_success();
test_jwt_verifier_url_issuer_success();
diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c
index 44a209258d..ff77af908a 100644
--- a/test/core/security/oauth2_utils.c
+++ b/test/core/security/oauth2_utils.c
@@ -92,7 +92,8 @@ char *grpc_test_fetch_oauth2_token_with_credentials(
request.pops = grpc_polling_entity_create_from_pollset(pollset);
request.is_done = 0;
- grpc_closure_init(&do_nothing_closure, do_nothing, NULL);
+ grpc_closure_init(&do_nothing_closure, do_nothing, NULL,
+ grpc_schedule_on_exec_ctx);
grpc_call_credentials_get_request_metadata(
&exec_ctx, creds, &request.pops, null_ctx, on_oauth2_response, &request);
diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c
index b5d95004fe..e1d6ff9691 100644
--- a/test/core/security/secure_endpoint_test.c
+++ b/test/core/security/secure_endpoint_test.c
@@ -42,6 +42,7 @@
#include "src/core/lib/iomgr/endpoint_pair.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/security/transport/secure_endpoint.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/tsi/fake_transport_security.h"
#include "test/core/util/test_config.h"
@@ -59,7 +60,7 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
grpc_resource_quota *resource_quota =
grpc_resource_quota_create("secure_endpoint_test");
tcp = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, slice_size);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, tcp.client, g_pollset);
grpc_endpoint_add_to_pollset(&exec_ctx, tcp.server, g_pollset);
@@ -158,7 +159,7 @@ static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
gpr_log(GPR_INFO, "Start test left over");
grpc_slice_buffer_init(&incoming);
- grpc_closure_init(&done_closure, inc_call_ctr, &n);
+ grpc_closure_init(&done_closure, inc_call_ctr, &n, grpc_schedule_on_exec_ctx);
grpc_endpoint_read(&exec_ctx, f.client_ep, &incoming, &done_closure);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(n == 1);
@@ -170,8 +171,8 @@ static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
grpc_endpoint_destroy(&exec_ctx, f.client_ep);
grpc_endpoint_destroy(&exec_ctx, f.server_ep);
grpc_exec_ctx_finish(&exec_ctx);
- grpc_slice_unref(s);
- grpc_slice_buffer_destroy(&incoming);
+ grpc_slice_unref_internal(&exec_ctx, s);
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &incoming);
clean_up();
}
@@ -191,7 +192,8 @@ int main(int argc, char **argv) {
grpc_pollset_init(g_pollset, &g_mu);
grpc_endpoint_tests(configs[0], g_pollset, g_mu);
test_leftover(configs[1], 1);
- grpc_closure_init(&destroyed, destroy_pollset, g_pollset);
+ grpc_closure_init(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
diff --git a/test/core/security/ssl_server_fuzzer.c b/test/core/security/ssl_server_fuzzer.c
index 04969765f5..55e8f5e78d 100644
--- a/test/core/security/ssl_server_fuzzer.c
+++ b/test/core/security/ssl_server_fuzzer.c
@@ -58,17 +58,14 @@ struct handshake_state {
bool done_callback_called;
};
-static void on_secure_handshake_done(grpc_exec_ctx *exec_ctx, void *statep,
- grpc_security_status status,
- grpc_endpoint *secure_endpoint,
- grpc_auth_context *auth_context) {
- struct handshake_state *state = (struct handshake_state *)statep;
+static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
+ grpc_error *error) {
+ grpc_handshaker_args *args = arg;
+ struct handshake_state *state = args->user_data;
GPR_ASSERT(state->done_callback_called == false);
state->done_callback_called = true;
// The fuzzer should not pass the handshake.
- GPR_ASSERT(status != GRPC_SECURITY_OK);
- GPR_ASSERT(secure_endpoint == NULL);
- GPR_ASSERT(auth_context == NULL);
+ GPR_ASSERT(error != GRPC_ERROR_NONE);
}
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
@@ -82,7 +79,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_resource_quota_create("ssl_server_fuzzer");
grpc_endpoint *mock_endpoint =
grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
grpc_mock_endpoint_put_read(
&exec_ctx, mock_endpoint,
@@ -106,17 +103,18 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// Create security connector
grpc_server_security_connector *sc = NULL;
grpc_security_status status =
- grpc_server_credentials_create_security_connector(creds, &sc);
+ grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
GPR_ASSERT(status == GRPC_SECURITY_OK);
- sc->channel_args = NULL;
gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_seconds(1, GPR_TIMESPAN));
struct handshake_state state;
state.done_callback_called = false;
- grpc_server_security_connector_do_handshake(&exec_ctx, sc, NULL,
- mock_endpoint, NULL, deadline,
- on_secure_handshake_done, &state);
+ grpc_handshake_manager *handshake_mgr = grpc_handshake_manager_create();
+ grpc_server_security_connector_add_handshakers(&exec_ctx, sc, handshake_mgr);
+ grpc_handshake_manager_do_handshake(
+ &exec_ctx, handshake_mgr, mock_endpoint, NULL /* channel_args */,
+ deadline, NULL /* acceptor */, on_handshake_done, &state);
grpc_exec_ctx_flush(&exec_ctx);
// If the given string happens to be part of the correct client hello, the
@@ -129,7 +127,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
GPR_ASSERT(state.done_callback_called);
- GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "test");
+ grpc_handshake_manager_destroy(&exec_ctx, handshake_mgr);
+ GRPC_SECURITY_CONNECTOR_UNREF(&exec_ctx, &sc->base, "test");
grpc_server_credentials_release(creds);
grpc_slice_unref(cert_slice);
grpc_slice_unref(key_slice);
diff --git a/test/core/security/verify_jwt.c b/test/core/security/verify_jwt.c
index 043d29e6bb..bbd4a67ac1 100644
--- a/test/core/security/verify_jwt.c
+++ b/test/core/security/verify_jwt.c
@@ -59,7 +59,7 @@ static void print_usage_and_exit(gpr_cmdline *cl, const char *argv0) {
exit(1);
}
-static void on_jwt_verification_done(void *user_data,
+static void on_jwt_verification_done(grpc_exec_ctx *exec_ctx, void *user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims *claims) {
synchronizer *sync = user_data;
@@ -72,7 +72,7 @@ static void on_jwt_verification_done(void *user_data,
grpc_json_dump_to_string((grpc_json *)grpc_jwt_claims_json(claims), 2);
printf("Claims: \n\n%s\n", claims_str);
gpr_free(claims_str);
- grpc_jwt_claims_destroy(claims);
+ grpc_jwt_claims_destroy(exec_ctx, claims);
} else {
GPR_ASSERT(claims == NULL);
fprintf(stderr, "Verification failed with error %s\n",
@@ -93,6 +93,7 @@ int main(int argc, char **argv) {
char *aud = NULL;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_init();
cl = gpr_cmdline_create("JWT verifier tool");
gpr_cmdline_add_string(cl, "jwt", "JSON web token to verify", &jwt);
gpr_cmdline_add_string(cl, "aud", "Audience for the JWT", &aud);
@@ -131,5 +132,6 @@ int main(int argc, char **argv) {
grpc_jwt_verifier_destroy(verifier);
gpr_cmdline_destroy(cl);
+ grpc_shutdown();
return !sync.success;
}
diff --git a/test/core/support/BUILD b/test/core/support/BUILD
new file mode 100644
index 0000000000..dfe952eb37
--- /dev/null
+++ b/test/core/support/BUILD
@@ -0,0 +1,154 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+cc_test(
+ name = "alloc_test",
+ srcs = ["alloc_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "avl_test",
+ srcs = ["avl_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "backoff_test",
+ srcs = ["backoff_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "cmdline_test",
+ srcs = ["cmdline_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "cpu_test",
+ srcs = ["cpu_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "env_test",
+ srcs = ["env_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "histogram_test",
+ srcs = ["histogram_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "host_port_test",
+ srcs = ["host_port_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "log_test",
+ srcs = ["log_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "mpscq_test",
+ srcs = ["mpscq_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "murmur_hash_test",
+ srcs = ["murmur_hash_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "stack_lockfree_test",
+ srcs = ["stack_lockfree_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "string_test",
+ srcs = ["string_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "sync_test",
+ srcs = ["sync_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "thd_test",
+ srcs = ["thd_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "time_test",
+ srcs = ["time_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "tls_test",
+ srcs = ["tls_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
+
+cc_test(
+ name = "useful_test",
+ srcs = ["useful_test.c"],
+ deps = ["//:gpr", "//test/core/util:gpr_test_util"],
+ copts = ['-std=c99']
+)
diff --git a/test/core/support/backoff_test.c b/test/core/support/backoff_test.c
index 13cba7d750..ad6e5a98f2 100644
--- a/test/core/support/backoff_test.c
+++ b/test/core/support/backoff_test.c
@@ -39,61 +39,110 @@
static void test_constant_backoff(void) {
gpr_backoff backoff;
- gpr_backoff_init(&backoff, 1.0, 0.0, 1000, 1000);
+ gpr_backoff_init(&backoff, 200 /* initial timeout */, 1.0 /* multiplier */,
+ 0.0 /* jitter */, 100 /* min timeout */,
+ 1000 /* max timeout */);
gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
gpr_timespec next = gpr_backoff_begin(&backoff, now);
- GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 1000);
+ GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
for (int i = 0; i < 10000; i++) {
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 1000);
+ GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
now = next;
}
}
-static void test_no_jitter_backoff(void) {
+static void test_min_connect(void) {
gpr_backoff backoff;
- gpr_backoff_init(&backoff, 2.0, 0.0, 1, 513);
+ gpr_backoff_init(&backoff, 100 /* initial timeout */, 1.0 /* multiplier */,
+ 0.0 /* jitter */, 200 /* min timeout */,
+ 1000 /* max timeout */);
gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
gpr_timespec next = gpr_backoff_begin(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(3, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
+}
+
+static void test_no_jitter_backoff(void) {
+ gpr_backoff backoff;
+ gpr_backoff_init(&backoff, 2 /* initial timeout */, 2.0 /* multiplier */,
+ 0.0 /* jitter */, 1 /* min timeout */,
+ 513 /* max timeout */);
+ // x_1 = 2
+ // x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 )
+ gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
+ gpr_timespec next = gpr_backoff_begin(&backoff, now);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(7, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(6, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(15, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(14, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(31, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(30, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(63, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(62, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(127, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(126, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(255, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(254, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(511, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(510, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1023, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1022, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1536, GPR_TIMESPAN), next) == 0);
+ // Hit the maximum timeout. From this point onwards, retries will increase
+ // only by max timeout.
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1535, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2049, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2048, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2562, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2561, GPR_TIMESPAN), next) == 0);
+}
+
+static void test_jitter_backoff(void) {
+ const int64_t initial_timeout = 500;
+ const double jitter = 0.1;
+ gpr_backoff backoff;
+ gpr_backoff_init(&backoff, initial_timeout, 1.0 /* multiplier */, jitter,
+ 100 /* min timeout */, 1000 /* max timeout */);
+
+ backoff.rng_state = 0; // force consistent PRNG
+
+ gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
+ gpr_timespec next = gpr_backoff_begin(&backoff, now);
+ GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 500);
+
+ int64_t expected_next_lower_bound =
+ (int64_t)((double)initial_timeout * (1 - jitter));
+ int64_t expected_next_upper_bound =
+ (int64_t)((double)initial_timeout * (1 + jitter));
+
+ for (int i = 0; i < 10000; i++) {
+ next = gpr_backoff_step(&backoff, now);
+
+ // next-now must be within (jitter*100)% of the previous timeout.
+ const int64_t timeout_millis = gpr_time_to_millis(gpr_time_sub(next, now));
+ GPR_ASSERT(timeout_millis >= expected_next_lower_bound);
+ GPR_ASSERT(timeout_millis <= expected_next_upper_bound);
+
+ expected_next_lower_bound =
+ (int64_t)((double)timeout_millis * (1 - jitter));
+ expected_next_upper_bound =
+ (int64_t)((double)timeout_millis * (1 + jitter));
+ now = next;
+ }
}
int main(int argc, char **argv) {
@@ -101,7 +150,9 @@ int main(int argc, char **argv) {
gpr_time_init();
test_constant_backoff();
+ test_min_connect();
test_no_jitter_backoff();
+ test_jitter_backoff();
return 0;
}
diff --git a/test/core/support/string_test.c b/test/core/support/string_test.c
index 78b77fad8e..af232db350 100644
--- a/test/core/support/string_test.c
+++ b/test/core/support/string_test.c
@@ -243,6 +243,8 @@ static void test_int64toa() {
static void test_leftpad() {
char *padded;
+ LOG_TEST_NAME("test_leftpad");
+
padded = gpr_leftpad("foo", ' ', 5);
GPR_ASSERT(0 == strcmp(" foo", padded));
gpr_free(padded);
@@ -273,12 +275,25 @@ static void test_leftpad() {
}
static void test_stricmp(void) {
+ LOG_TEST_NAME("test_stricmp");
+
GPR_ASSERT(0 == gpr_stricmp("hello", "hello"));
GPR_ASSERT(0 == gpr_stricmp("HELLO", "hello"));
GPR_ASSERT(gpr_stricmp("a", "b") < 0);
GPR_ASSERT(gpr_stricmp("b", "a") > 0);
}
+static void test_memrchr(void) {
+ LOG_TEST_NAME("test_memrchr");
+
+ GPR_ASSERT(NULL == gpr_memrchr(NULL, 'a', 0));
+ GPR_ASSERT(NULL == gpr_memrchr("", 'a', 0));
+ GPR_ASSERT(NULL == gpr_memrchr("hello", 'b', 5));
+ GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'h', 5), "hello"));
+ GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'o', 5), "o"));
+ GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'l', 5), "lo"));
+}
+
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
test_strdup();
@@ -291,5 +306,6 @@ int main(int argc, char **argv) {
test_int64toa();
test_leftpad();
test_stricmp();
+ test_memrchr();
return 0;
}
diff --git a/test/core/surface/byte_buffer_reader_test.c b/test/core/surface/byte_buffer_reader_test.c
index d8d7a52d15..2f1f72f0e0 100644
--- a/test/core/surface/byte_buffer_reader_test.c
+++ b/test/core/surface/byte_buffer_reader_test.c
@@ -40,9 +40,10 @@
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-#include "test/core/util/test_config.h"
#include "src/core/lib/compression/message_compress.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
+#include "test/core/util/test_config.h"
#include <string.h>
@@ -145,7 +146,12 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
input_slice = grpc_slice_malloc(input_size);
memset(GRPC_SLICE_START_PTR(input_slice), 'a', input_size);
grpc_slice_buffer_add(&sliceb_in, input_slice); /* takes ownership */
- GPR_ASSERT(grpc_msg_compress(algorithm, &sliceb_in, &sliceb_out));
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GPR_ASSERT(
+ grpc_msg_compress(&exec_ctx, algorithm, &sliceb_in, &sliceb_out));
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
buffer = grpc_raw_compressed_byte_buffer_create(sliceb_out.slices,
sliceb_out.count, algorithm);
diff --git a/test/core/surface/channel_create_test.c b/test/core/surface/channel_create_test.c
index ad7970aab9..654e5324d9 100644
--- a/test/core/surface/channel_create_test.c
+++ b/test/core/surface/channel_create_test.c
@@ -31,9 +31,14 @@
*
*/
+#include <string.h>
+
#include <grpc/grpc.h>
#include <grpc/support/log.h>
+
#include "src/core/ext/client_channel/resolver_registry.h"
+#include "src/core/lib/channel/channel_stack.h"
+#include "src/core/lib/surface/channel.h"
#include "test/core/util/test_config.h"
void test_unknown_scheme_target(void) {
@@ -44,6 +49,13 @@ void test_unknown_scheme_target(void) {
chan = grpc_insecure_channel_create("blah://blah", NULL, NULL);
GPR_ASSERT(chan != NULL);
+
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_element *elem =
+ grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
+ GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
+ grpc_exec_ctx_finish(&exec_ctx);
+
grpc_channel_destroy(chan);
}
diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.c
index f9f4675454..8ebe8d07e4 100644
--- a/test/core/surface/concurrent_connectivity_test.c
+++ b/test/core/surface/concurrent_connectivity_test.c
@@ -105,8 +105,8 @@ void server_thread(void *vargs) {
static void on_connect(grpc_exec_ctx *exec_ctx, void *vargs, grpc_endpoint *tcp,
grpc_pollset *accepting_pollset,
grpc_tcp_server_acceptor *acceptor) {
+ gpr_free(acceptor);
struct server_thread_args *args = (struct server_thread_args *)vargs;
- (void)acceptor;
grpc_endpoint_shutdown(exec_ctx, tcp);
grpc_endpoint_destroy(exec_ctx, tcp);
GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, NULL));
@@ -229,9 +229,9 @@ int main(int argc, char **argv) {
gpr_atm_rel_store(&args.stop, 1);
gpr_thd_join(server);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_shutdown(
- &exec_ctx, args.pollset,
- grpc_closure_create(done_pollset_shutdown, args.pollset));
+ grpc_pollset_shutdown(&exec_ctx, args.pollset,
+ grpc_closure_create(done_pollset_shutdown, args.pollset,
+ grpc_schedule_on_exec_ctx));
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c
index 6afcefca92..b6db6a6b08 100644
--- a/test/core/surface/lame_client_test.c
+++ b/test/core/surface/lame_client_test.c
@@ -62,7 +62,8 @@ void test_transport_op(grpc_channel *channel) {
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_closure_init(&transport_op_cb, verify_connectivity, &state);
+ grpc_closure_init(&transport_op_cb, verify_connectivity, &state,
+ grpc_schedule_on_exec_ctx);
op = grpc_make_transport_op(NULL);
op->on_connectivity_state_change = &transport_op_cb;
@@ -71,7 +72,8 @@ void test_transport_op(grpc_channel *channel) {
elem->filter->start_transport_op(&exec_ctx, elem, op);
grpc_exec_ctx_finish(&exec_ctx);
- grpc_closure_init(&transport_op_cb, do_nothing, NULL);
+ grpc_closure_init(&transport_op_cb, do_nothing, NULL,
+ grpc_schedule_on_exec_ctx);
op = grpc_make_transport_op(&transport_op_cb);
elem->filter->start_transport_op(&exec_ctx, elem, op);
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c
index d4cfa25d44..e0a2c94216 100644
--- a/test/core/surface/public_headers_must_be_c89.c
+++ b/test/core/surface/public_headers_must_be_c89.c
@@ -42,6 +42,8 @@
#include <grpc/impl/codegen/byte_buffer_reader.h>
#include <grpc/impl/codegen/compression_types.h>
#include <grpc/impl/codegen/connectivity_state.h>
+#include <grpc/impl/codegen/exec_ctx_fwd.h>
+#include <grpc/impl/codegen/gpr_slice.h>
#include <grpc/impl/codegen/gpr_types.h>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/impl/codegen/port_platform.h>
diff --git a/test/core/surface/secure_channel_create_test.c b/test/core/surface/secure_channel_create_test.c
index 444ebdc093..ab4067dbe1 100644
--- a/test/core/surface/secure_channel_create_test.c
+++ b/test/core/surface/secure_channel_create_test.c
@@ -51,7 +51,9 @@ void test_unknown_scheme_target(void) {
creds = grpc_fake_transport_security_credentials_create();
chan = grpc_secure_channel_create(creds, "blah://blah", NULL, NULL);
GPR_ASSERT(chan == NULL);
- grpc_channel_credentials_unref(creds);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_credentials_unref(&exec_ctx, creds);
+ grpc_exec_ctx_finish(&exec_ctx);
}
void test_security_connector_already_in_arg(void) {
diff --git a/test/core/surface/sequential_connectivity_test.c b/test/core/surface/sequential_connectivity_test.c
index fe87f119f2..3292718762 100644
--- a/test/core/surface/sequential_connectivity_test.c
+++ b/test/core/surface/sequential_connectivity_test.c
@@ -39,6 +39,7 @@
#include <grpc/support/thd.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@@ -162,7 +163,11 @@ static grpc_channel *secure_test_create_channel(const char *addr) {
grpc_channel_args_copy_and_add(NULL, &ssl_name_override, 1);
grpc_channel *channel =
grpc_secure_channel_create(ssl_creds, addr, new_client_args, NULL);
- grpc_channel_args_destroy(new_client_args);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, new_client_args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
grpc_channel_credentials_release(ssl_creds);
return channel;
}
diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.c
index 6310b6f00b..6c178abdad 100644
--- a/test/core/surface/server_chttp2_test.c
+++ b/test/core/surface/server_chttp2_test.c
@@ -44,8 +44,11 @@
#include "test/core/util/test_config.h"
void test_unparsable_target(void) {
- int port = grpc_server_add_insecure_http2_port(NULL, "[");
+ grpc_channel_args args = {0, NULL};
+ grpc_server *server = grpc_server_create(&args, NULL);
+ int port = grpc_server_add_insecure_http2_port(server, "[");
GPR_ASSERT(port == 0);
+ grpc_server_destroy(server);
}
void test_add_same_port_twice() {
diff --git a/test/core/transport/chttp2/BUILD b/test/core/transport/chttp2/BUILD
new file mode 100644
index 0000000000..94b4830138
--- /dev/null
+++ b/test/core/transport/chttp2/BUILD
@@ -0,0 +1,40 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+licenses(["notice"]) # 3-clause BSD
+
+load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
+
+grpc_fuzzer(
+ name = "hpack_parser_fuzzer",
+ srcs = ["hpack_parser_fuzzer_test.c"],
+ deps = ["//:grpc", "//test/core/util:grpc_test_util"],
+ corpus = "hpack_parser_corpus"
+)
+
diff --git a/test/core/transport/chttp2/bin_decoder_test.c b/test/core/transport/chttp2/bin_decoder_test.c
index 7ddc30291a..221112ab21 100644
--- a/test/core/transport/chttp2/bin_decoder_test.c
+++ b/test/core/transport/chttp2/bin_decoder_test.c
@@ -38,13 +38,14 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/support/string.h"
static int all_ok = 1;
-static void expect_slice_eq(grpc_slice expected, grpc_slice slice, char *debug,
- int line) {
+static void expect_slice_eq(grpc_exec_ctx *exec_ctx, grpc_slice expected,
+ grpc_slice slice, char *debug, int line) {
if (0 != grpc_slice_cmp(slice, expected)) {
char *hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
char *he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII);
@@ -54,92 +55,104 @@ static void expect_slice_eq(grpc_slice expected, grpc_slice slice, char *debug,
gpr_free(he);
all_ok = 0;
}
- grpc_slice_unref(expected);
- grpc_slice_unref(slice);
+ grpc_slice_unref_internal(exec_ctx, expected);
+ grpc_slice_unref_internal(exec_ctx, slice);
}
-static grpc_slice base64_encode(const char *s) {
+static grpc_slice base64_encode(grpc_exec_ctx *exec_ctx, const char *s) {
grpc_slice ss = grpc_slice_from_copied_string(s);
grpc_slice out = grpc_chttp2_base64_encode(ss);
- grpc_slice_unref(ss);
+ grpc_slice_unref_internal(exec_ctx, ss);
return out;
}
-static grpc_slice base64_decode(const char *s) {
+static grpc_slice base64_decode(grpc_exec_ctx *exec_ctx, const char *s) {
grpc_slice ss = grpc_slice_from_copied_string(s);
- grpc_slice out = grpc_chttp2_base64_decode(ss);
- grpc_slice_unref(ss);
+ grpc_slice out = grpc_chttp2_base64_decode(exec_ctx, ss);
+ grpc_slice_unref_internal(exec_ctx, ss);
return out;
}
-static grpc_slice base64_decode_with_length(const char *s,
+static grpc_slice base64_decode_with_length(grpc_exec_ctx *exec_ctx,
+ const char *s,
size_t output_length) {
grpc_slice ss = grpc_slice_from_copied_string(s);
- grpc_slice out = grpc_chttp2_base64_decode_with_length(ss, output_length);
- grpc_slice_unref(ss);
+ grpc_slice out =
+ grpc_chttp2_base64_decode_with_length(exec_ctx, ss, output_length);
+ grpc_slice_unref_internal(exec_ctx, ss);
return out;
}
-#define EXPECT_SLICE_EQ(expected, slice) \
- expect_slice_eq( \
- grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), slice, \
- #slice, __LINE__);
+#define EXPECT_SLICE_EQ(exec_ctx, expected, slice) \
+ expect_slice_eq( \
+ exec_ctx, grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), \
+ slice, #slice, __LINE__);
-#define ENCODE_AND_DECODE(s) \
- EXPECT_SLICE_EQ( \
- s, grpc_chttp2_base64_decode_with_length(base64_encode(s), strlen(s)));
+#define ENCODE_AND_DECODE(exec_ctx, s) \
+ EXPECT_SLICE_EQ(exec_ctx, s, \
+ grpc_chttp2_base64_decode_with_length( \
+ exec_ctx, base64_encode(exec_ctx, s), strlen(s)));
int main(int argc, char **argv) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+
/* ENCODE_AND_DECODE tests grpc_chttp2_base64_decode_with_length(), which
takes encoded base64 strings without pad chars, but output length is
required. */
/* Base64 test vectors from RFC 4648 */
- ENCODE_AND_DECODE("");
- ENCODE_AND_DECODE("f");
- ENCODE_AND_DECODE("foo");
- ENCODE_AND_DECODE("fo");
- ENCODE_AND_DECODE("foob");
- ENCODE_AND_DECODE("fooba");
- ENCODE_AND_DECODE("foobar");
+ ENCODE_AND_DECODE(&exec_ctx, "");
+ ENCODE_AND_DECODE(&exec_ctx, "f");
+ ENCODE_AND_DECODE(&exec_ctx, "foo");
+ ENCODE_AND_DECODE(&exec_ctx, "fo");
+ ENCODE_AND_DECODE(&exec_ctx, "foob");
+ ENCODE_AND_DECODE(&exec_ctx, "fooba");
+ ENCODE_AND_DECODE(&exec_ctx, "foobar");
- ENCODE_AND_DECODE("\xc0\xc1\xc2\xc3\xc4\xc5");
+ ENCODE_AND_DECODE(&exec_ctx, "\xc0\xc1\xc2\xc3\xc4\xc5");
/* Base64 test vectors from RFC 4648, with pad chars */
/* BASE64("") = "" */
- EXPECT_SLICE_EQ("", base64_decode(""));
+ EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, ""));
/* BASE64("f") = "Zg==" */
- EXPECT_SLICE_EQ("f", base64_decode("Zg=="));
+ EXPECT_SLICE_EQ(&exec_ctx, "f", base64_decode(&exec_ctx, "Zg=="));
/* BASE64("fo") = "Zm8=" */
- EXPECT_SLICE_EQ("fo", base64_decode("Zm8="));
+ EXPECT_SLICE_EQ(&exec_ctx, "fo", base64_decode(&exec_ctx, "Zm8="));
/* BASE64("foo") = "Zm9v" */
- EXPECT_SLICE_EQ("foo", base64_decode("Zm9v"));
+ EXPECT_SLICE_EQ(&exec_ctx, "foo", base64_decode(&exec_ctx, "Zm9v"));
/* BASE64("foob") = "Zm9vYg==" */
- EXPECT_SLICE_EQ("foob", base64_decode("Zm9vYg=="));
+ EXPECT_SLICE_EQ(&exec_ctx, "foob", base64_decode(&exec_ctx, "Zm9vYg=="));
/* BASE64("fooba") = "Zm9vYmE=" */
- EXPECT_SLICE_EQ("fooba", base64_decode("Zm9vYmE="));
+ EXPECT_SLICE_EQ(&exec_ctx, "fooba", base64_decode(&exec_ctx, "Zm9vYmE="));
/* BASE64("foobar") = "Zm9vYmFy" */
- EXPECT_SLICE_EQ("foobar", base64_decode("Zm9vYmFy"));
+ EXPECT_SLICE_EQ(&exec_ctx, "foobar", base64_decode(&exec_ctx, "Zm9vYmFy"));
- EXPECT_SLICE_EQ("\xc0\xc1\xc2\xc3\xc4\xc5", base64_decode("wMHCw8TF"));
+ EXPECT_SLICE_EQ(&exec_ctx, "\xc0\xc1\xc2\xc3\xc4\xc5",
+ base64_decode(&exec_ctx, "wMHCw8TF"));
// Test illegal input length in grpc_chttp2_base64_decode
- EXPECT_SLICE_EQ("", base64_decode("a"));
- EXPECT_SLICE_EQ("", base64_decode("ab"));
- EXPECT_SLICE_EQ("", base64_decode("abc"));
+ EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "a"));
+ EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "ab"));
+ EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "abc"));
// Test illegal charactors in grpc_chttp2_base64_decode
- EXPECT_SLICE_EQ("", base64_decode("Zm:v"));
- EXPECT_SLICE_EQ("", base64_decode("Zm=v"));
+ EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "Zm:v"));
+ EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "Zm=v"));
// Test output_length longer than max possible output length in
// grpc_chttp2_base64_decode_with_length
- EXPECT_SLICE_EQ("", base64_decode_with_length("Zg", 2));
- EXPECT_SLICE_EQ("", base64_decode_with_length("Zm8", 3));
- EXPECT_SLICE_EQ("", base64_decode_with_length("Zm9v", 4));
+ EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode_with_length(&exec_ctx, "Zg", 2));
+ EXPECT_SLICE_EQ(&exec_ctx, "",
+ base64_decode_with_length(&exec_ctx, "Zm8", 3));
+ EXPECT_SLICE_EQ(&exec_ctx, "",
+ base64_decode_with_length(&exec_ctx, "Zm9v", 4));
// Test illegal charactors in grpc_chttp2_base64_decode_with_length
- EXPECT_SLICE_EQ("", base64_decode_with_length("Zm:v", 3));
- EXPECT_SLICE_EQ("", base64_decode_with_length("Zm=v", 3));
+ EXPECT_SLICE_EQ(&exec_ctx, "",
+ base64_decode_with_length(&exec_ctx, "Zm:v", 3));
+ EXPECT_SLICE_EQ(&exec_ctx, "",
+ base64_decode_with_length(&exec_ctx, "Zm=v", 3));
+
+ grpc_exec_ctx_finish(&exec_ctx);
return all_ok ? 0 : 1;
}
diff --git a/test/core/transport/chttp2/hpack_encoder_test.c b/test/core/transport/chttp2/hpack_encoder_test.c
index 91421e18f4..1fd2540d65 100644
--- a/test/core/transport/chttp2/hpack_encoder_test.c
+++ b/test/core/transport/chttp2/hpack_encoder_test.c
@@ -41,6 +41,7 @@
#include <grpc/support/string_util.h>
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/metadata.h"
@@ -59,8 +60,9 @@ size_t cap_to_delete = 0;
/* verify that the output generated by encoding the stream matches the
hexstring passed in */
-static void verify(size_t window_available, int eof, size_t expect_window_used,
- const char *expected, size_t nheaders, ...) {
+static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, int eof,
+ size_t expect_window_used, const char *expected,
+ size_t nheaders, ...) {
grpc_slice_buffer output;
grpc_slice merged;
grpc_slice expect = parse_hexstring(expected);
@@ -79,7 +81,7 @@ static void verify(size_t window_available, int eof, size_t expect_window_used,
e[i - 1].next = &e[i];
e[i].prev = &e[i - 1];
}
- e[i].md = grpc_mdelem_from_strings(key, value);
+ e[i].md = grpc_mdelem_from_strings(exec_ctx, key, value);
}
e[0].prev = NULL;
e[nheaders - 1].next = NULL;
@@ -98,11 +100,11 @@ static void verify(size_t window_available, int eof, size_t expect_window_used,
grpc_transport_one_way_stats stats;
memset(&stats, 0, sizeof(stats));
- grpc_chttp2_encode_header(&g_compressor, 0xdeadbeef, &b, eof, 16384, &stats,
- &output);
+ grpc_chttp2_encode_header(exec_ctx, &g_compressor, 0xdeadbeef, &b, eof, 16384,
+ &stats, &output);
merged = grpc_slice_merge(output.slices, output.count);
- grpc_slice_buffer_destroy(&output);
- grpc_metadata_batch_destroy(&b);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &output);
+ grpc_metadata_batch_destroy(exec_ctx, &b);
if (0 != grpc_slice_cmp(merged, expect)) {
char *expect_str = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII);
@@ -115,31 +117,32 @@ static void verify(size_t window_available, int eof, size_t expect_window_used,
g_failure = 1;
}
- grpc_slice_unref(merged);
- grpc_slice_unref(expect);
+ grpc_slice_unref_internal(exec_ctx, merged);
+ grpc_slice_unref_internal(exec_ctx, expect);
}
-static void test_basic_headers(void) {
+static void test_basic_headers(grpc_exec_ctx *exec_ctx) {
int i;
- verify(0, 0, 0, "000005 0104 deadbeef 40 0161 0161", 1, "a", "a");
- verify(0, 0, 0, "000001 0104 deadbeef be", 1, "a", "a");
- verify(0, 0, 0, "000001 0104 deadbeef be", 1, "a", "a");
- verify(0, 0, 0, "000006 0104 deadbeef be 40 0162 0163", 2, "a", "a", "b",
+ verify(exec_ctx, 0, 0, 0, "000005 0104 deadbeef 40 0161 0161", 1, "a", "a");
+ verify(exec_ctx, 0, 0, 0, "000001 0104 deadbeef be", 1, "a", "a");
+ verify(exec_ctx, 0, 0, 0, "000001 0104 deadbeef be", 1, "a", "a");
+ verify(exec_ctx, 0, 0, 0, "000006 0104 deadbeef be 40 0162 0163", 2, "a", "a",
+ "b", "c");
+ verify(exec_ctx, 0, 0, 0, "000002 0104 deadbeef bf be", 2, "a", "a", "b",
"c");
- verify(0, 0, 0, "000002 0104 deadbeef bf be", 2, "a", "a", "b", "c");
- verify(0, 0, 0, "000004 0104 deadbeef 7f 00 0164", 1, "a", "d");
+ verify(exec_ctx, 0, 0, 0, "000004 0104 deadbeef 7f 00 0164", 1, "a", "d");
/* flush out what's there to make a few values look very popular */
for (i = 0; i < 350; i++) {
- verify(0, 0, 0, "000003 0104 deadbeef c0 bf be", 3, "a", "a", "b", "c", "a",
- "d");
+ verify(exec_ctx, 0, 0, 0, "000003 0104 deadbeef c0 bf be", 3, "a", "a", "b",
+ "c", "a", "d");
}
- verify(0, 0, 0, "000006 0104 deadbeef c0 00 016b 0176", 2, "a", "a", "k",
- "v");
+ verify(exec_ctx, 0, 0, 0, "000006 0104 deadbeef c0 00 016b 0176", 2, "a", "a",
+ "k", "v");
/* this could be 000004 0104 deadbeef 0f 30 0176 also */
- verify(0, 0, 0, "000004 0104 deadbeef 0f 2f 0176", 1, "a", "v");
+ verify(exec_ctx, 0, 0, 0, "000004 0104 deadbeef 0f 2f 0176", 1, "a", "v");
}
static void encode_int_to_str(int i, char *p) {
@@ -150,7 +153,7 @@ static void encode_int_to_str(int i, char *p) {
p[2] = 0;
}
-static void test_decode_table_overflow(void) {
+static void test_decode_table_overflow(grpc_exec_ctx *exec_ctx) {
int i;
char key[3], value[3];
char *expect;
@@ -173,22 +176,24 @@ static void test_decode_table_overflow(void) {
}
if (i > 0) {
- verify(0, 0, 0, expect, 2, "aa", "ba", key, value);
+ verify(exec_ctx, 0, 0, 0, expect, 2, "aa", "ba", key, value);
} else {
- verify(0, 0, 0, expect, 1, key, value);
+ verify(exec_ctx, 0, 0, 0, expect, 1, key, value);
}
gpr_free(expect);
}
/* if the above passes, then we must have just knocked this pair out of the
decoder stack, and so we'll be forced to re-encode it */
- verify(0, 0, 0, "000007 0104 deadbeef 40 026161 026261", 1, "aa", "ba");
+ verify(exec_ctx, 0, 0, 0, "000007 0104 deadbeef 40 026161 026261", 1, "aa",
+ "ba");
}
-static void verify_table_size_change_match_elem_size(const char *key,
+static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx,
+ const char *key,
const char *value) {
grpc_slice_buffer output;
- grpc_mdelem *elem = grpc_mdelem_from_strings(key, value);
+ grpc_mdelem *elem = grpc_mdelem_from_strings(exec_ctx, key, value);
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
size_t initial_table_size = g_compressor.table_size;
grpc_linked_mdelem *e = gpr_malloc(sizeof(*e));
@@ -203,25 +208,27 @@ static void verify_table_size_change_match_elem_size(const char *key,
grpc_transport_one_way_stats stats;
memset(&stats, 0, sizeof(stats));
- grpc_chttp2_encode_header(&g_compressor, 0xdeadbeef, &b, 0, 16384, &stats,
- &output);
- grpc_slice_buffer_destroy(&output);
- grpc_metadata_batch_destroy(&b);
+ grpc_chttp2_encode_header(exec_ctx, &g_compressor, 0xdeadbeef, &b, 0, 16384,
+ &stats, &output);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &output);
+ grpc_metadata_batch_destroy(exec_ctx, &b);
GPR_ASSERT(g_compressor.table_size == elem_size + initial_table_size);
gpr_free(e);
}
-static void test_encode_header_size(void) {
- verify_table_size_change_match_elem_size("hello", "world");
- verify_table_size_change_match_elem_size("hello-bin", "world");
+static void test_encode_header_size(grpc_exec_ctx *exec_ctx) {
+ verify_table_size_change_match_elem_size(exec_ctx, "hello", "world");
+ verify_table_size_change_match_elem_size(exec_ctx, "hello-bin", "world");
}
-static void run_test(void (*test)(), const char *name) {
+static void run_test(void (*test)(grpc_exec_ctx *exec_ctx), const char *name) {
gpr_log(GPR_INFO, "RUN TEST: %s", name);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_chttp2_hpack_compressor_init(&g_compressor);
- test();
- grpc_chttp2_hpack_compressor_destroy(&g_compressor);
+ test(&exec_ctx);
+ grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &g_compressor);
+ grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char **argv) {
diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.c b/test/core/transport/chttp2/hpack_parser_fuzzer_test.c
index 95acbf1a68..4e00f49b66 100644
--- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.c
+++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.c
@@ -44,7 +44,7 @@ bool squelch = true;
bool leak_check = true;
static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem *md) {
- GRPC_MDELEM_UNREF(md);
+ GRPC_MDELEM_UNREF(exec_ctx, md);
}
static void dont_log(gpr_log_func_args *args) {}
@@ -53,13 +53,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
grpc_init();
grpc_chttp2_hpack_parser parser;
- grpc_chttp2_hpack_parser_init(&parser);
- parser.on_header = onhdr;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ parser.on_header = onhdr;
GRPC_ERROR_UNREF(
grpc_chttp2_hpack_parser_parse(&exec_ctx, &parser, data, data + size));
+ grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
grpc_exec_ctx_finish(&exec_ctx);
- grpc_chttp2_hpack_parser_destroy(&parser);
grpc_shutdown();
return 0;
}
diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c
index e2813df70c..8f48849c97 100644
--- a/test/core/transport/chttp2/hpack_parser_test.c
+++ b/test/core/transport/chttp2/hpack_parser_test.c
@@ -54,7 +54,7 @@ static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem *md) {
GPR_ASSERT(evalue);
GPR_ASSERT(grpc_slice_str_cmp(md->key->slice, ekey) == 0);
GPR_ASSERT(grpc_slice_str_cmp(md->value->slice, evalue) == 0);
- GRPC_MDELEM_UNREF(md);
+ GRPC_MDELEM_UNREF(exec_ctx, md);
}
static void test_vector(grpc_chttp2_hpack_parser *parser,
@@ -94,8 +94,9 @@ static void test_vector(grpc_chttp2_hpack_parser *parser,
static void test_vectors(grpc_slice_split_mode mode) {
grpc_chttp2_hpack_parser parser;
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_chttp2_hpack_parser_init(&parser);
+ grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
/* D.2.1 */
test_vector(&parser, mode,
"400a 6375 7374 6f6d 2d6b 6579 0d63 7573"
@@ -111,9 +112,9 @@ static void test_vectors(grpc_slice_split_mode mode) {
"password", "secret", NULL);
/* D.2.4 */
test_vector(&parser, mode, "82", ":method", "GET", NULL);
- grpc_chttp2_hpack_parser_destroy(&parser);
+ grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
- grpc_chttp2_hpack_parser_init(&parser);
+ grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
/* D.3.1 */
test_vector(&parser, mode,
"8286 8441 0f77 7777 2e65 7861 6d70 6c65"
@@ -131,9 +132,9 @@ static void test_vectors(grpc_slice_split_mode mode) {
":method", "GET", ":scheme", "https", ":path", "/index.html",
":authority", "www.example.com", "custom-key", "custom-value",
NULL);
- grpc_chttp2_hpack_parser_destroy(&parser);
+ grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
- grpc_chttp2_hpack_parser_init(&parser);
+ grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
/* D.4.1 */
test_vector(&parser, mode,
"8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4"
@@ -151,11 +152,11 @@ static void test_vectors(grpc_slice_split_mode mode) {
":method", "GET", ":scheme", "https", ":path", "/index.html",
":authority", "www.example.com", "custom-key", "custom-value",
NULL);
- grpc_chttp2_hpack_parser_destroy(&parser);
+ grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
- grpc_chttp2_hpack_parser_init(&parser);
- grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
- grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
+ grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_chttp2_hptbl_set_max_bytes(&exec_ctx, &parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&exec_ctx, &parser.table, 256);
/* D.5.1 */
test_vector(&parser, mode,
"4803 3330 3258 0770 7269 7661 7465 611d"
@@ -185,11 +186,11 @@ static void test_vectors(grpc_slice_split_mode mode) {
"https://www.example.com", "content-encoding", "gzip",
"set-cookie",
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
- grpc_chttp2_hpack_parser_destroy(&parser);
+ grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
- grpc_chttp2_hpack_parser_init(&parser);
- grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
- grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
+ grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_chttp2_hptbl_set_max_bytes(&exec_ctx, &parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&exec_ctx, &parser.table, 256);
/* D.6.1 */
test_vector(&parser, mode,
"4882 6402 5885 aec3 771a 4b61 96d0 7abe"
@@ -216,7 +217,9 @@ static void test_vectors(grpc_slice_split_mode mode) {
"https://www.example.com", "content-encoding", "gzip",
"set-cookie",
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
- grpc_chttp2_hpack_parser_destroy(&parser);
+ grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+
+ grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char **argv) {
diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.c
index 1a7e2442ca..ef2ad66b5c 100644
--- a/test/core/transport/chttp2/hpack_table_test.c
+++ b/test/core/transport/chttp2/hpack_table_test.c
@@ -59,9 +59,10 @@ static void assert_index(const grpc_chttp2_hptbl *tbl, uint32_t idx,
}
static void test_static_lookup(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_chttp2_hptbl tbl;
- grpc_chttp2_hptbl_init(&tbl);
+ grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
LOG_TEST("test_static_lookup");
assert_index(&tbl, 1, ":authority", "");
@@ -126,7 +127,8 @@ static void test_static_lookup(void) {
assert_index(&tbl, 60, "via", "");
assert_index(&tbl, 61, "www-authenticate", "");
- grpc_chttp2_hptbl_destroy(&tbl);
+ grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_many_additions(void) {
@@ -137,15 +139,16 @@ static void test_many_additions(void) {
LOG_TEST("test_many_additions");
- grpc_chttp2_hptbl_init(&tbl);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
for (i = 0; i < 100000; i++) {
grpc_mdelem *elem;
gpr_asprintf(&key, "K:%d", i);
gpr_asprintf(&value, "VALUE:%d", i);
- elem = grpc_mdelem_from_strings(key, value);
- GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_strings(&exec_ctx, key, value);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(&exec_ctx, elem);
assert_index(&tbl, 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value);
gpr_free(key);
gpr_free(value);
@@ -158,19 +161,23 @@ static void test_many_additions(void) {
}
}
- grpc_chttp2_hptbl_destroy(&tbl);
+ grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl *tbl,
const char *key,
const char *value) {
- grpc_mdelem *md = grpc_mdelem_from_strings(key, value);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_mdelem *md = grpc_mdelem_from_strings(&exec_ctx, key, value);
grpc_chttp2_hptbl_find_result r = grpc_chttp2_hptbl_find(tbl, md);
- GRPC_MDELEM_UNREF(md);
+ GRPC_MDELEM_UNREF(&exec_ctx, md);
+ grpc_exec_ctx_finish(&exec_ctx);
return r;
}
static void test_find(void) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_chttp2_hptbl tbl;
uint32_t i;
char buffer[32];
@@ -179,16 +186,16 @@ static void test_find(void) {
LOG_TEST("test_find");
- grpc_chttp2_hptbl_init(&tbl);
- elem = grpc_mdelem_from_strings("abc", "xyz");
- GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(elem);
- elem = grpc_mdelem_from_strings("abc", "123");
- GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(elem);
- elem = grpc_mdelem_from_strings("x", "1");
- GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(elem);
+ grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
+ elem = grpc_mdelem_from_strings(&exec_ctx, "abc", "xyz");
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(&exec_ctx, elem);
+ elem = grpc_mdelem_from_strings(&exec_ctx, "abc", "123");
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(&exec_ctx, elem);
+ elem = grpc_mdelem_from_strings(&exec_ctx, "x", "1");
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(&exec_ctx, elem);
r = find_simple(&tbl, "abc", "123");
GPR_ASSERT(r.index == 2 + GRPC_CHTTP2_LAST_STATIC_ENTRY);
@@ -237,9 +244,9 @@ static void test_find(void) {
/* overflow the string buffer, check find still works */
for (i = 0; i < 10000; i++) {
int64_ttoa(i, buffer);
- elem = grpc_mdelem_from_strings("test", buffer);
- GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_strings(&exec_ctx, "test", buffer);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(&exec_ctx, elem);
}
r = find_simple(&tbl, "abc", "123");
@@ -267,7 +274,8 @@ static void test_find(void) {
GPR_ASSERT(r.index != 0);
GPR_ASSERT(r.has_value == 0);
- grpc_chttp2_hptbl_destroy(&tbl);
+ grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
+ grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char **argv) {
diff --git a/test/core/transport/connectivity_state_test.c b/test/core/transport/connectivity_state_test.c
index 1050059eff..3520ef0a80 100644
--- a/test/core/transport/connectivity_state_test.c
+++ b/test/core/transport/connectivity_state_test.c
@@ -86,7 +86,8 @@ static void test_check(void) {
static void test_subscribe_then_unsubscribe(void) {
grpc_connectivity_state_tracker tracker;
- grpc_closure *closure = grpc_closure_create(must_fail, THE_ARG);
+ grpc_closure *closure =
+ grpc_closure_create(must_fail, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_log(GPR_DEBUG, "test_subscribe_then_unsubscribe");
@@ -109,7 +110,8 @@ static void test_subscribe_then_unsubscribe(void) {
static void test_subscribe_then_destroy(void) {
grpc_connectivity_state_tracker tracker;
- grpc_closure *closure = grpc_closure_create(must_succeed, THE_ARG);
+ grpc_closure *closure =
+ grpc_closure_create(must_succeed, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_log(GPR_DEBUG, "test_subscribe_then_destroy");
@@ -128,7 +130,8 @@ static void test_subscribe_then_destroy(void) {
static void test_subscribe_with_failure_then_destroy(void) {
grpc_connectivity_state_tracker tracker;
- grpc_closure *closure = grpc_closure_create(must_fail, THE_ARG);
+ grpc_closure *closure =
+ grpc_closure_create(must_fail, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_SHUTDOWN;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_log(GPR_DEBUG, "test_subscribe_with_failure_then_destroy");
diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c
index 5c89d8530a..3625043d07 100644
--- a/test/core/transport/metadata_test.c
+++ b/test/core/transport/metadata_test.c
@@ -42,6 +42,7 @@
#include <grpc/support/string_util.h>
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
+#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/static_metadata.h"
#include "test/core/util/test_config.h"
@@ -63,6 +64,7 @@ static void test_create_string(void) {
LOG_TEST("test_create_string");
grpc_init();
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
s1 = grpc_mdstr_from_string("hello");
s2 = grpc_mdstr_from_string("hello");
s3 = grpc_mdstr_from_string("very much not hello");
@@ -70,9 +72,10 @@ static void test_create_string(void) {
GPR_ASSERT(s3 != s1);
GPR_ASSERT(grpc_slice_str_cmp(s1->slice, "hello") == 0);
GPR_ASSERT(grpc_slice_str_cmp(s3->slice, "very much not hello") == 0);
- GRPC_MDSTR_UNREF(s1);
- GRPC_MDSTR_UNREF(s2);
- GRPC_MDSTR_UNREF(s3);
+ GRPC_MDSTR_UNREF(&exec_ctx, s1);
+ GRPC_MDSTR_UNREF(&exec_ctx, s2);
+ GRPC_MDSTR_UNREF(&exec_ctx, s3);
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
@@ -82,9 +85,10 @@ static void test_create_metadata(void) {
LOG_TEST("test_create_metadata");
grpc_init();
- m1 = grpc_mdelem_from_strings("a", "b");
- m2 = grpc_mdelem_from_strings("a", "b");
- m3 = grpc_mdelem_from_strings("a", "c");
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ m1 = grpc_mdelem_from_strings(&exec_ctx, "a", "b");
+ m2 = grpc_mdelem_from_strings(&exec_ctx, "a", "b");
+ m3 = grpc_mdelem_from_strings(&exec_ctx, "a", "c");
GPR_ASSERT(m1 == m2);
GPR_ASSERT(m3 != m1);
GPR_ASSERT(m3->key == m1->key);
@@ -92,9 +96,10 @@ static void test_create_metadata(void) {
GPR_ASSERT(grpc_slice_str_cmp(m1->key->slice, "a") == 0);
GPR_ASSERT(grpc_slice_str_cmp(m1->value->slice, "b") == 0);
GPR_ASSERT(grpc_slice_str_cmp(m3->value->slice, "c") == 0);
- GRPC_MDELEM_UNREF(m1);
- GRPC_MDELEM_UNREF(m2);
- GRPC_MDELEM_UNREF(m3);
+ GRPC_MDELEM_UNREF(&exec_ctx, m1);
+ GRPC_MDELEM_UNREF(&exec_ctx, m2);
+ GRPC_MDELEM_UNREF(&exec_ctx, m3);
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
@@ -105,11 +110,14 @@ static void test_create_many_ephemeral_metadata(void) {
LOG_TEST("test_create_many_ephemeral_metadata");
grpc_init();
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
/* add, and immediately delete a bunch of different elements */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
- GRPC_MDELEM_UNREF(grpc_mdelem_from_strings("a", buffer));
+ GRPC_MDELEM_UNREF(&exec_ctx,
+ grpc_mdelem_from_strings(&exec_ctx, "a", buffer));
}
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
@@ -122,22 +130,24 @@ static void test_create_many_persistant_metadata(void) {
LOG_TEST("test_create_many_persistant_metadata");
grpc_init();
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
/* add phase */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
- created[i] = grpc_mdelem_from_strings("a", buffer);
+ created[i] = grpc_mdelem_from_strings(&exec_ctx, "a", buffer);
}
/* verify phase */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
- md = grpc_mdelem_from_strings("a", buffer);
+ md = grpc_mdelem_from_strings(&exec_ctx, "a", buffer);
GPR_ASSERT(md == created[i]);
- GRPC_MDELEM_UNREF(md);
+ GRPC_MDELEM_UNREF(&exec_ctx, md);
}
/* cleanup phase */
for (i = 0; i < MANY; i++) {
- GRPC_MDELEM_UNREF(created[i]);
+ GRPC_MDELEM_UNREF(&exec_ctx, created[i]);
}
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
gpr_free(created);
@@ -147,9 +157,11 @@ static void test_spin_creating_the_same_thing(void) {
LOG_TEST("test_spin_creating_the_same_thing");
grpc_init();
- GRPC_MDELEM_UNREF(grpc_mdelem_from_strings("a", "b"));
- GRPC_MDELEM_UNREF(grpc_mdelem_from_strings("a", "b"));
- GRPC_MDELEM_UNREF(grpc_mdelem_from_strings("a", "b"));
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_from_strings(&exec_ctx, "a", "b"));
+ GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_from_strings(&exec_ctx, "a", "b"));
+ GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_from_strings(&exec_ctx, "a", "b"));
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
@@ -164,6 +176,7 @@ static void test_things_stick_around(void) {
LOG_TEST("test_things_stick_around");
grpc_init();
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
for (i = 0; i < nstrs; i++) {
gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" PRIuPTR "x", i);
@@ -174,7 +187,7 @@ static void test_things_stick_around(void) {
for (i = 0; i < nstrs; i++) {
GRPC_MDSTR_REF(strs[i]);
- GRPC_MDSTR_UNREF(strs[i]);
+ GRPC_MDSTR_UNREF(&exec_ctx, strs[i]);
}
for (i = 0; i < nstrs; i++) {
@@ -186,17 +199,18 @@ static void test_things_stick_around(void) {
}
for (i = 0; i < nstrs; i++) {
- GRPC_MDSTR_UNREF(strs[shuf[i]]);
+ GRPC_MDSTR_UNREF(&exec_ctx, strs[shuf[i]]);
for (j = i + 1; j < nstrs; j++) {
gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" PRIuPTR "x",
shuf[j]);
test = grpc_mdstr_from_string(buffer);
GPR_ASSERT(test == strs[shuf[j]]);
- GRPC_MDSTR_UNREF(test);
+ GRPC_MDSTR_UNREF(&exec_ctx, test);
gpr_free(buffer);
}
}
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
gpr_free(strs);
gpr_free(shuf);
@@ -210,19 +224,21 @@ static void test_slices_work(void) {
LOG_TEST("test_slices_work");
grpc_init();
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
str = grpc_mdstr_from_string(
"123456789012345678901234567890123456789012345678901234567890");
slice = grpc_slice_ref(str->slice);
- GRPC_MDSTR_UNREF(str);
- grpc_slice_unref(slice);
+ GRPC_MDSTR_UNREF(&exec_ctx, str);
+ grpc_slice_unref_internal(&exec_ctx, slice);
str = grpc_mdstr_from_string(
"123456789012345678901234567890123456789012345678901234567890");
slice = grpc_slice_ref(str->slice);
- grpc_slice_unref(slice);
- GRPC_MDSTR_UNREF(str);
+ grpc_slice_unref_internal(&exec_ctx, slice);
+ GRPC_MDSTR_UNREF(&exec_ctx, str);
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
@@ -234,13 +250,15 @@ static void test_base64_and_huffman_works(void) {
LOG_TEST("test_base64_and_huffman_works");
grpc_init();
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
str = grpc_mdstr_from_string("abcdefg");
slice1 = grpc_mdstr_as_base64_encoded_and_huffman_compressed(str);
slice2 = grpc_chttp2_base64_encode_and_huffman_compress(str->slice);
GPR_ASSERT(0 == grpc_slice_cmp(slice1, slice2));
- grpc_slice_unref(slice2);
- GRPC_MDSTR_UNREF(str);
+ grpc_slice_unref_internal(&exec_ctx, slice2);
+ GRPC_MDSTR_UNREF(&exec_ctx, str);
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
@@ -251,29 +269,33 @@ static void test_user_data_works(void) {
LOG_TEST("test_user_data_works");
grpc_init();
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
ud1 = gpr_malloc(sizeof(int));
*ud1 = 1;
ud2 = gpr_malloc(sizeof(int));
*ud2 = 2;
- md = grpc_mdelem_from_strings("abc", "123");
+ md = grpc_mdelem_from_strings(&exec_ctx, "abc", "123");
grpc_mdelem_set_user_data(md, gpr_free, ud1);
grpc_mdelem_set_user_data(md, gpr_free, ud2);
GPR_ASSERT(grpc_mdelem_get_user_data(md, gpr_free) == ud1);
- GRPC_MDELEM_UNREF(md);
+ GRPC_MDELEM_UNREF(&exec_ctx, md);
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
-static void verify_ascii_header_size(const char *key, const char *value) {
- grpc_mdelem *elem = grpc_mdelem_from_strings(key, value);
+static void verify_ascii_header_size(grpc_exec_ctx *exec_ctx, const char *key,
+ const char *value) {
+ grpc_mdelem *elem = grpc_mdelem_from_strings(exec_ctx, key, value);
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
size_t expected_size = 32 + strlen(key) + strlen(value);
GPR_ASSERT(expected_size == elem_size);
- GRPC_MDELEM_UNREF(elem);
+ GRPC_MDELEM_UNREF(exec_ctx, elem);
}
-static void verify_binary_header_size(const char *key, const uint8_t *value,
- size_t value_len) {
- grpc_mdelem *elem = grpc_mdelem_from_string_and_buffer(key, value, value_len);
+static void verify_binary_header_size(grpc_exec_ctx *exec_ctx, const char *key,
+ const uint8_t *value, size_t value_len) {
+ grpc_mdelem *elem =
+ grpc_mdelem_from_string_and_buffer(exec_ctx, key, value, value_len);
GPR_ASSERT(grpc_is_binary_header(key, strlen(key)));
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
grpc_slice value_slice =
@@ -281,33 +303,37 @@ static void verify_binary_header_size(const char *key, const uint8_t *value,
grpc_slice base64_encoded = grpc_chttp2_base64_encode(value_slice);
size_t expected_size = 32 + strlen(key) + GRPC_SLICE_LENGTH(base64_encoded);
GPR_ASSERT(expected_size == elem_size);
- grpc_slice_unref(value_slice);
- grpc_slice_unref(base64_encoded);
- GRPC_MDELEM_UNREF(elem);
+ grpc_slice_unref_internal(exec_ctx, value_slice);
+ grpc_slice_unref_internal(exec_ctx, base64_encoded);
+ GRPC_MDELEM_UNREF(exec_ctx, elem);
}
#define BUFFER_SIZE 64
static void test_mdelem_sizes_in_hpack(void) {
LOG_TEST("test_mdelem_size");
grpc_init();
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
uint8_t binary_value[BUFFER_SIZE] = {0};
for (uint8_t i = 0; i < BUFFER_SIZE; i++) {
binary_value[i] = i;
}
- verify_ascii_header_size("hello", "world");
- verify_ascii_header_size("hello", "worldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
- verify_ascii_header_size(":scheme", "http");
+ verify_ascii_header_size(&exec_ctx, "hello", "world");
+ verify_ascii_header_size(&exec_ctx, "hello",
+ "worldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+ verify_ascii_header_size(&exec_ctx, ":scheme", "http");
for (uint8_t i = 0; i < BUFFER_SIZE; i++) {
- verify_binary_header_size("hello-bin", binary_value, i);
+ verify_binary_header_size(&exec_ctx, "hello-bin", binary_value, i);
}
const char *static_metadata = grpc_static_metadata_strings[0];
memcpy(binary_value, static_metadata, strlen(static_metadata));
- verify_binary_header_size("hello-bin", binary_value, strlen(static_metadata));
+ verify_binary_header_size(&exec_ctx, "hello-bin", binary_value,
+ strlen(static_metadata));
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
diff --git a/test/core/util/BUILD b/test/core/util/BUILD
new file mode 100644
index 0000000000..8769683b23
--- /dev/null
+++ b/test/core/util/BUILD
@@ -0,0 +1,87 @@
+# Copyright 2017, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+licenses(["notice"]) # 3-clause BSD
+
+cc_library(
+ name = "gpr_test_util",
+ srcs = [
+ "test_config.c",
+ "memory_counters.c",
+ ],
+ hdrs = [
+ "test_config.h",
+ "memory_counters.h",
+ ],
+ deps = ["//:gpr"],
+ visibility = ["//:__subpackages__"],
+)
+
+cc_library(
+ name = "grpc_test_util",
+ srcs = [
+ "grpc_profiler.c",
+ "mock_endpoint.c",
+ "parse_hexstring.c",
+ "passthru_endpoint.c",
+ "port_posix.c",
+ "port_server_client.c",
+ "port_windows.c",
+ "reconnect_server.c",
+ "slice_splitter.c",
+ "test_tcp_server.c",
+ ],
+ hdrs = [
+ "grpc_profiler.h",
+ "mock_endpoint.h",
+ "parse_hexstring.h",
+ "passthru_endpoint.h",
+ "port.h",
+ "port_server_client.h",
+ "reconnect_server.h",
+ "slice_splitter.h",
+ "test_tcp_server.h",
+ ],
+ deps = [":gpr_test_util", "//:grpc"],
+ visibility = ["//test:__subpackages__"],
+ copts = ["-std=c99"],
+)
+
+cc_library(
+ name = "one_corpus_entry_fuzzer",
+ srcs = ["one_corpus_entry_fuzzer.c"],
+ deps = [":gpr_test_util", "//:grpc"],
+ visibility = ["//test:__subpackages__"],
+)
+
+sh_library(
+ name = "fuzzer_one_entry_runner",
+ srcs = ["fuzzer_one_entry_runner.sh"],
+ visibility = ["//test:__subpackages__"],
+)
diff --git a/test/core/util/fuzzer_one_entry_runner.sh b/test/core/util/fuzzer_one_entry_runner.sh
new file mode 100755
index 0000000000..a0558a9c09
--- /dev/null
+++ b/test/core/util/fuzzer_one_entry_runner.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Test runner for fuzzer tests from bazel
+
+# Copyright 2017, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+$1 $2
diff --git a/test/core/util/grpc_fuzzer.bzl b/test/core/util/grpc_fuzzer.bzl
new file mode 100644
index 0000000000..2f552a9fdb
--- /dev/null
+++ b/test/core/util/grpc_fuzzer.bzl
@@ -0,0 +1,43 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+def grpc_fuzzer(name, corpus, srcs = [], deps = [], **kwargs):
+ native.cc_binary(
+ name = '%s/one_entry.bin' % name,
+ srcs = srcs,
+ deps = deps + ["//test/core/util:one_corpus_entry_fuzzer"],
+ **kwargs
+ )
+ for entry in native.glob(['%s/*' % corpus]):
+ native.sh_test(
+ name = '%s/one_entry/%s' % (name, entry),
+ data = [':%s/one_entry.bin' % name, entry],
+ srcs = ['//test/core/util:fuzzer_one_entry_runner'],
+ args = ['$(location :%s/one_entry.bin)' % name, '$(location %s)' % entry]
+ )
diff --git a/test/core/util/memory_counters.h b/test/core/util/memory_counters.h
index f332816501..b9b2b3adda 100644
--- a/test/core/util/memory_counters.h
+++ b/test/core/util/memory_counters.h
@@ -34,6 +34,8 @@
#ifndef GRPC_TEST_CORE_UTIL_MEMORY_COUNTERS_H
#define GRPC_TEST_CORE_UTIL_MEMORY_COUNTERS_H
+#include <stddef.h>
+
struct grpc_memory_counters {
size_t total_size_relative;
size_t total_size_absolute;
diff --git a/test/core/util/mock_endpoint.c b/test/core/util/mock_endpoint.c
index bf6d85252a..04793bceab 100644
--- a/test/core/util/mock_endpoint.c
+++ b/test/core/util/mock_endpoint.c
@@ -55,7 +55,7 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
gpr_mu_lock(&m->mu);
if (m->read_buffer.count > 0) {
grpc_slice_buffer_swap(&m->read_buffer, slices);
- grpc_exec_ctx_sched(exec_ctx, cb, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, cb, GRPC_ERROR_NONE);
} else {
m->on_read = cb;
m->on_read_out = slices;
@@ -69,7 +69,7 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
for (size_t i = 0; i < slices->count; i++) {
m->on_write(slices->slices[i]);
}
- grpc_exec_ctx_sched(exec_ctx, cb, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, cb, GRPC_ERROR_NONE);
}
static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
@@ -82,8 +82,8 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep;
gpr_mu_lock(&m->mu);
if (m->on_read) {
- grpc_exec_ctx_sched(exec_ctx, m->on_read,
- GRPC_ERROR_CREATE("Endpoint Shutdown"), NULL);
+ grpc_closure_sched(exec_ctx, m->on_read,
+ GRPC_ERROR_CREATE("Endpoint Shutdown"));
m->on_read = NULL;
}
gpr_mu_unlock(&m->mu);
@@ -144,7 +144,7 @@ void grpc_mock_endpoint_put_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
gpr_mu_lock(&m->mu);
if (m->on_read != NULL) {
grpc_slice_buffer_add(m->on_read_out, slice);
- grpc_exec_ctx_sched(exec_ctx, m->on_read, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, m->on_read, GRPC_ERROR_NONE);
m->on_read = NULL;
} else {
grpc_slice_buffer_add(&m->read_buffer, slice);
diff --git a/test/core/util/passthru_endpoint.c b/test/core/util/passthru_endpoint.c
index b3405f02e9..d42ec7f9e8 100644
--- a/test/core/util/passthru_endpoint.c
+++ b/test/core/util/passthru_endpoint.c
@@ -39,6 +39,8 @@
#include <grpc/support/string_util.h>
#include "src/core/lib/iomgr/sockaddr.h"
+#include "src/core/lib/slice/slice_internal.h"
+
typedef struct passthru_endpoint passthru_endpoint;
typedef struct {
@@ -63,11 +65,10 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
half *m = (half *)ep;
gpr_mu_lock(&m->parent->mu);
if (m->parent->shutdown) {
- grpc_exec_ctx_sched(exec_ctx, cb, GRPC_ERROR_CREATE("Already shutdown"),
- NULL);
+ grpc_closure_sched(exec_ctx, cb, GRPC_ERROR_CREATE("Already shutdown"));
} else if (m->read_buffer.count > 0) {
grpc_slice_buffer_swap(&m->read_buffer, slices);
- grpc_exec_ctx_sched(exec_ctx, cb, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, cb, GRPC_ERROR_NONE);
} else {
m->on_read = cb;
m->on_read_out = slices;
@@ -91,7 +92,7 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
for (size_t i = 0; i < slices->count; i++) {
grpc_slice_buffer_add(m->on_read_out, grpc_slice_ref(slices->slices[i]));
}
- grpc_exec_ctx_sched(exec_ctx, m->on_read, GRPC_ERROR_NONE, NULL);
+ grpc_closure_sched(exec_ctx, m->on_read, GRPC_ERROR_NONE);
m->on_read = NULL;
} else {
for (size_t i = 0; i < slices->count; i++) {
@@ -99,7 +100,7 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
}
}
gpr_mu_unlock(&m->parent->mu);
- grpc_exec_ctx_sched(exec_ctx, cb, error, NULL);
+ grpc_closure_sched(exec_ctx, cb, error);
}
static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
@@ -113,14 +114,12 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
gpr_mu_lock(&m->parent->mu);
m->parent->shutdown = true;
if (m->on_read) {
- grpc_exec_ctx_sched(exec_ctx, m->on_read, GRPC_ERROR_CREATE("Shutdown"),
- NULL);
+ grpc_closure_sched(exec_ctx, m->on_read, GRPC_ERROR_CREATE("Shutdown"));
m->on_read = NULL;
}
m = other_half(m);
if (m->on_read) {
- grpc_exec_ctx_sched(exec_ctx, m->on_read, GRPC_ERROR_CREATE("Shutdown"),
- NULL);
+ grpc_closure_sched(exec_ctx, m->on_read, GRPC_ERROR_CREATE("Shutdown"));
m->on_read = NULL;
}
gpr_mu_unlock(&m->parent->mu);
@@ -133,8 +132,8 @@ static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
if (0 == --p->halves) {
gpr_mu_unlock(&p->mu);
gpr_mu_destroy(&p->mu);
- grpc_slice_buffer_destroy(&p->client.read_buffer);
- grpc_slice_buffer_destroy(&p->server.read_buffer);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &p->client.read_buffer);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &p->server.read_buffer);
grpc_resource_user_unref(exec_ctx, p->client.resource_user);
grpc_resource_user_unref(exec_ctx, p->server.resource_user);
gpr_free(p);
diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c
index b2342feeb4..4baf63dcd7 100644
--- a/test/core/util/port_server_client.c
+++ b/test/core/util/port_server_client.c
@@ -92,7 +92,8 @@ void grpc_free_port_using_server(char *server, int port) {
grpc_pollset *pollset = gpr_malloc(grpc_pollset_size());
grpc_pollset_init(pollset, &pr.mu);
pr.pops = grpc_polling_entity_create_from_pollset(pollset);
- shutdown_closure = grpc_closure_create(destroy_pops_and_shutdown, &pr.pops);
+ shutdown_closure = grpc_closure_create(destroy_pops_and_shutdown, &pr.pops,
+ grpc_schedule_on_exec_ctx);
req.host = server;
gpr_asprintf(&path, "/drop/%d", port);
@@ -103,8 +104,10 @@ void grpc_free_port_using_server(char *server, int port) {
grpc_resource_quota_create("port_server_client/free");
grpc_httpcli_get(&exec_ctx, &context, &pr.pops, resource_quota, &req,
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10),
- grpc_closure_create(freed_port_from_server, &pr), &rsp);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_closure_create(freed_port_from_server, &pr,
+ grpc_schedule_on_exec_ctx),
+ &rsp);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
gpr_mu_lock(pr.mu);
while (!pr.done) {
grpc_pollset_worker *worker = NULL;
@@ -174,9 +177,10 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
grpc_resource_quota_create("port_server_client/pick_retry");
grpc_httpcli_get(exec_ctx, pr->ctx, &pr->pops, resource_quota, &req,
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10),
- grpc_closure_create(got_port_from_server, pr),
+ grpc_closure_create(got_port_from_server, pr,
+ grpc_schedule_on_exec_ctx),
&pr->response);
- grpc_resource_quota_internal_unref(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
return;
}
GPR_ASSERT(response);
@@ -208,7 +212,8 @@ int grpc_pick_port_using_server(char *server) {
grpc_pollset *pollset = gpr_malloc(grpc_pollset_size());
grpc_pollset_init(pollset, &pr.mu);
pr.pops = grpc_polling_entity_create_from_pollset(pollset);
- shutdown_closure = grpc_closure_create(destroy_pops_and_shutdown, &pr.pops);
+ shutdown_closure = grpc_closure_create(destroy_pops_and_shutdown, &pr.pops,
+ grpc_schedule_on_exec_ctx);
pr.port = -1;
pr.server = server;
pr.ctx = &context;
@@ -219,11 +224,12 @@ int grpc_pick_port_using_server(char *server) {
grpc_httpcli_context_init(&context);
grpc_resource_quota *resource_quota =
grpc_resource_quota_create("port_server_client/pick");
- grpc_httpcli_get(&exec_ctx, &context, &pr.pops, resource_quota, &req,
- GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10),
- grpc_closure_create(got_port_from_server, &pr),
- &pr.response);
- grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
+ grpc_httpcli_get(
+ &exec_ctx, &context, &pr.pops, resource_quota, &req,
+ GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10),
+ grpc_closure_create(got_port_from_server, &pr, grpc_schedule_on_exec_ctx),
+ &pr.response);
+ grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(pr.mu);
while (pr.port == -1) {
diff --git a/test/core/util/reconnect_server.c b/test/core/util/reconnect_server.c
index 6509cc5b68..7bf83a74a1 100644
--- a/test/core/util/reconnect_server.c
+++ b/test/core/util/reconnect_server.c
@@ -73,6 +73,7 @@ static void pretty_print_backoffs(reconnect_server *server) {
static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
grpc_pollset *accepting_pollset,
grpc_tcp_server_acceptor *acceptor) {
+ gpr_free(acceptor);
char *peer;
char *last_colon;
reconnect_server *server = (reconnect_server *)arg;
diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c
index 16df91d968..2338b81ab1 100644
--- a/test/core/util/test_tcp_server.c
+++ b/test/core/util/test_tcp_server.c
@@ -57,7 +57,8 @@ void test_tcp_server_init(test_tcp_server *server,
grpc_tcp_server_cb on_connect, void *user_data) {
grpc_init();
server->tcp_server = NULL;
- grpc_closure_init(&server->shutdown_complete, on_server_destroyed, server);
+ grpc_closure_init(&server->shutdown_complete, on_server_destroyed, server,
+ grpc_schedule_on_exec_ctx);
server->shutdown = 0;
server->pollset = gpr_malloc(grpc_pollset_size());
grpc_pollset_init(server->pollset, &server->mu);
@@ -111,7 +112,8 @@ void test_tcp_server_destroy(test_tcp_server *server) {
gpr_timespec shutdown_deadline;
grpc_closure do_nothing_cb;
grpc_tcp_server_unref(&exec_ctx, server->tcp_server);
- grpc_closure_init(&do_nothing_cb, do_nothing, NULL);
+ grpc_closure_init(&do_nothing_cb, do_nothing, NULL,
+ grpc_schedule_on_exec_ctx);
shutdown_deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_seconds(5, GPR_TIMESPAN));
while (!server->shutdown &&