diff options
author | Muxi Yan <mxyan@google.com> | 2017-02-08 15:27:31 -0800 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2017-02-08 15:27:31 -0800 |
commit | acbc5dd6ece72a1eb1032568a0061ef867b8b800 (patch) | |
tree | d991968fe7c2bf8154bef1b798b89bda68dd5719 /test | |
parent | 40d7c627bde4c08d40568f62e6f284a6a615fb71 (diff) | |
parent | da7b06c2f8d0dd89ab92589c55d5233f329083c5 (diff) |
Merge remote-tracking branch 'upstream/master' into packet-coalescing-objc
Diffstat (limited to 'test')
772 files changed, 9029 insertions, 2782 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..fdedfe284e 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); @@ -156,16 +160,17 @@ void grpc_run_bad_client_test( /* Await completion */ GPR_ASSERT( - gpr_event_wait(&a.done_write, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))); + gpr_event_wait(&a.done_write, grpc_timeout_seconds_to_deadline(5))); if (flags & GRPC_BAD_CLIENT_DISCONNECT) { - grpc_endpoint_shutdown(&exec_ctx, sfd.client); + grpc_endpoint_shutdown(&exec_ctx, sfd.client, + GRPC_ERROR_CREATE("Forced Disconnect")); grpc_endpoint_destroy(&exec_ctx, sfd.client); grpc_exec_ctx_finish(&exec_ctx); sfd.client = NULL; } - GPR_ASSERT(gpr_event_wait(&a.done_thd, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))); + GPR_ASSERT(gpr_event_wait(&a.done_thd, grpc_timeout_seconds_to_deadline(5))); if (sfd.client != NULL) { // Validate client stream, if requested. @@ -175,26 +180,28 @@ 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); + gpr_event_wait(&args.read_done, grpc_timeout_seconds_to_deadline(5))); + grpc_slice_buffer_destroy_internal(&exec_ctx, &args.incoming); } // Shutdown. - grpc_endpoint_shutdown(&exec_ctx, sfd.client); + grpc_endpoint_shutdown(&exec_ctx, sfd.client, + GRPC_ERROR_CREATE("Test Shutdown")); grpc_endpoint_destroy(&exec_ctx, sfd.client); grpc_exec_ctx_finish(&exec_ctx); } grpc_server_shutdown_and_notify(a.server, a.cq, NULL); GPR_ASSERT(grpc_completion_queue_pluck( - a.cq, NULL, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), NULL) + a.cq, NULL, grpc_timeout_seconds_to_deadline(1), NULL) .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_client/tests/badreq.c b/test/core/bad_client/tests/badreq.c index 5d9ffef3f2..7b22f880ab 100644 --- a/test/core/bad_client/tests/badreq.c +++ b/test/core/bad_client/tests/badreq.c @@ -46,7 +46,7 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( - cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), NULL) + cq, grpc_timeout_milliseconds_to_deadline(20), NULL) .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/connection_prefix.c b/test/core/bad_client/tests/connection_prefix.c index bc5ed2e393..42787ab90d 100644 --- a/test/core/bad_client/tests/connection_prefix.c +++ b/test/core/bad_client/tests/connection_prefix.c @@ -38,7 +38,7 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( - cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), NULL) + cq, grpc_timeout_milliseconds_to_deadline(20), NULL) .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/headers.c b/test/core/bad_client/tests/headers.c index f872e5006a..ab47821760 100644 --- a/test/core/bad_client/tests/headers.c +++ b/test/core/bad_client/tests/headers.c @@ -42,7 +42,7 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( - cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), NULL) + cq, grpc_timeout_milliseconds_to_deadline(20), NULL) .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/initial_settings_frame.c b/test/core/bad_client/tests/initial_settings_frame.c index b84b67a7e5..890efd8924 100644 --- a/test/core/bad_client/tests/initial_settings_frame.c +++ b/test/core/bad_client/tests/initial_settings_frame.c @@ -41,7 +41,7 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( - cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), NULL) + cq, grpc_timeout_milliseconds_to_deadline(20), NULL) .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/large_metadata.c b/test/core/bad_client/tests/large_metadata.c index 9c804e78c1..f672776a9f 100644 --- a/test/core/bad_client/tests/large_metadata.c +++ b/test/core/bad_client/tests/large_metadata.c @@ -126,8 +126,8 @@ static void server_verifier(grpc_server *server, grpc_completion_queue *cq, CQ_EXPECT_COMPLETION(cqv, tag(101), 1); cq_verify(cqv); - GPR_ASSERT(0 == strcmp(call_details.host, "localhost")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo/bar")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar")); grpc_metadata_array_destroy(&request_metadata_recv); grpc_call_details_destroy(&call_details); @@ -153,16 +153,14 @@ static void server_verifier_sends_too_much_metadata(grpc_server *server, CQ_EXPECT_COMPLETION(cqv, tag(101), 1); cq_verify(cqv); - GPR_ASSERT(0 == strcmp(call_details.host, "localhost")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo/bar")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar")); const size_t metadata_value_size = 16 * 1024; grpc_metadata meta; - meta.key = "key"; - meta.value = gpr_malloc(metadata_value_size + 1); - memset((char *)meta.value, 'a', metadata_value_size); - ((char *)meta.value)[metadata_value_size] = 0; - meta.value_length = metadata_value_size; + meta.key = grpc_slice_from_static_string("key"); + meta.value = grpc_slice_malloc(metadata_value_size); + memset(GRPC_SLICE_START_PTR(meta.value), 'a', metadata_value_size); grpc_op op; memset(&op, 0, sizeof(op)); @@ -176,7 +174,7 @@ static void server_verifier_sends_too_much_metadata(grpc_server *server, CQ_EXPECT_COMPLETION(cqv, tag(102), 0); // Operation fails. cq_verify(cqv); - gpr_free((char *)meta.value); + grpc_slice_unref(meta.value); grpc_metadata_array_destroy(&request_metadata_recv); grpc_call_details_destroy(&call_details); grpc_call_destroy(s); @@ -190,29 +188,26 @@ static void client_validator(grpc_slice_buffer *incoming) { grpc_slice_buffer_trim_end(incoming, 13, &last_frame_buffer); GPR_ASSERT(last_frame_buffer.count == 1); grpc_slice last_frame = last_frame_buffer.slices[0]; - // Construct expected frame. - grpc_slice expected = grpc_slice_malloc(13); - uint8_t *p = GRPC_SLICE_START_PTR(expected); - // Length. - *p++ = 0; - *p++ = 0; - *p++ = 4; - // Frame type (RST_STREAM). - *p++ = 3; - // Flags. - *p++ = 0; + const uint8_t *p = GRPC_SLICE_START_PTR(last_frame); + // Length = 4 + GPR_ASSERT(*p++ == 0); + GPR_ASSERT(*p++ == 0); + GPR_ASSERT(*p++ == 4); + // Frame type (RST_STREAM) + GPR_ASSERT(*p++ == 3); + // Flags + GPR_ASSERT(*p++ == 0); // Stream ID. - *p++ = 0; - *p++ = 0; - *p++ = 0; - *p++ = 1; - // Payload (error code). - *p++ = 0; - *p++ = 0; - *p++ = 0; - *p++ = 11; - // Compare actual and expected. - GPR_ASSERT(grpc_slice_cmp(last_frame, expected) == 0); + GPR_ASSERT(*p++ == 0); + GPR_ASSERT(*p++ == 0); + GPR_ASSERT(*p++ == 0); + GPR_ASSERT(*p++ == 1); + // Payload (error code) + GPR_ASSERT(*p++ == 0); + GPR_ASSERT(*p++ == 0); + GPR_ASSERT(*p++ == 0); + GPR_ASSERT(*p == 0 || *p == 11); + grpc_slice_buffer_destroy(&last_frame_buffer); } diff --git a/test/core/bad_client/tests/simple_request.c b/test/core/bad_client/tests/simple_request.c index c08aa40a0a..608b849d41 100644 --- a/test/core/bad_client/tests/simple_request.c +++ b/test/core/bad_client/tests/simple_request.c @@ -117,8 +117,8 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, CQ_EXPECT_COMPLETION(cqv, tag(101), 1); cq_verify(cqv); - GPR_ASSERT(0 == strcmp(call_details.host, "localhost")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo/bar")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar")); grpc_metadata_array_destroy(&request_metadata_recv); grpc_call_details_destroy(&call_details); @@ -130,7 +130,7 @@ static void failure_verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( - cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), NULL) + cq, grpc_timeout_milliseconds_to_deadline(20), NULL) .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/unknown_frame.c b/test/core/bad_client/tests/unknown_frame.c index 4f483d21f2..1d04699422 100644 --- a/test/core/bad_client/tests/unknown_frame.c +++ b/test/core/bad_client/tests/unknown_frame.c @@ -42,7 +42,7 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( - cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), NULL) + cq, grpc_timeout_milliseconds_to_deadline(20), NULL) .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/window_overflow.c b/test/core/bad_client/tests/window_overflow.c index 0d17dbe448..7db85906f9 100644 --- a/test/core/bad_client/tests/window_overflow.c +++ b/test/core/bad_client/tests/window_overflow.c @@ -61,7 +61,7 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( - cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), NULL) + cq, grpc_timeout_milliseconds_to_deadline(20), NULL) .type == GRPC_QUEUE_TIMEOUT); } } 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/bad_ssl_test.c b/test/core/bad_ssl/bad_ssl_test.c index f8a9fe6cac..bd85585706 100644 --- a/test/core/bad_ssl/bad_ssl_test.c +++ b/test/core/bad_ssl/bad_ssl_test.c @@ -57,11 +57,10 @@ static void run_test(const char *target, size_t nops) { grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; grpc_status_code status; grpc_call_error error; - gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5); + gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); grpc_completion_queue *cq = grpc_completion_queue_create(NULL); cq_verifier *cqv = cq_verifier_create(cq); @@ -80,9 +79,10 @@ static void run_test(const char *target, size_t nops) { grpc_metadata_array_init(&trailing_metadata_recv); channel = grpc_secure_channel_create(ssl_creds, target, &args, NULL); + grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr:1234"); c = grpc_channel_create_call(channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, - "/foo", "foo.test.google.fr:1234", deadline, - NULL); + grpc_slice_from_static_string("/foo"), &host, + deadline, NULL); memset(ops, 0, sizeof(ops)); op = ops; @@ -95,12 +95,11 @@ static void run_test(const char *target, size_t nops) { 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++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -117,7 +116,7 @@ static void run_test(const char *target, size_t nops) { GPR_ASSERT(status != GRPC_STATUS_OK); grpc_call_destroy(c); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); 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/bad_ssl/server_common.c b/test/core/bad_ssl/server_common.c index 14b1892c2e..6a4313eafd 100644 --- a/test/core/bad_ssl/server_common.c +++ b/test/core/bad_ssl/server_common.c @@ -84,7 +84,7 @@ void bad_ssl_run(grpc_server *server) { gpr_log(GPR_INFO, "Shutting down due to SIGINT"); grpc_server_shutdown_and_notify(server, cq, NULL); GPR_ASSERT(grpc_completion_queue_pluck( - cq, NULL, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + cq, NULL, grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_completion_queue_shutdown(cq); shutdown_started = 1; diff --git a/test/core/census/data/context_full.pb b/test/core/census/data/context_full.pb Binary files differindex 80ebcf280b..7b5895cbf1 100644 --- a/test/core/census/data/context_full.pb +++ b/test/core/census/data/context_full.pb diff --git a/test/core/census/data/context_full.txt b/test/core/census/data/context_full.txt index 7901a10c33..7d8df37ea1 100644 --- a/test/core/census/data/context_full.txt +++ b/test/core/census/data/context_full.txt @@ -1,3 +1,4 @@ -trace_id { hi : 5; lo : 1 } +trace_id_hi : 5 +trace_id_lo : 1 span_id : 7 -is_sampled : true +span_options : 1 diff --git a/test/core/census/data/context_no_sample.pb b/test/core/census/data/context_no_sample.pb Binary files differdeleted file mode 100644 index ab7ad7d109..0000000000 --- a/test/core/census/data/context_no_sample.pb +++ /dev/null diff --git a/test/core/census/data/context_no_sample.txt b/test/core/census/data/context_no_sample.txt deleted file mode 100644 index 150298002f..0000000000 --- a/test/core/census/data/context_no_sample.txt +++ /dev/null @@ -1,2 +0,0 @@ -trace_id { hi : 5; lo : 1 } -span_id : 7 diff --git a/test/core/census/data/context_no_span_options.pb b/test/core/census/data/context_no_span_options.pb Binary files differnew file mode 100644 index 0000000000..4b3425ac01 --- /dev/null +++ b/test/core/census/data/context_no_span_options.pb diff --git a/test/core/census/data/context_no_span_options.txt b/test/core/census/data/context_no_span_options.txt new file mode 100644 index 0000000000..4c8398ffd0 --- /dev/null +++ b/test/core/census/data/context_no_span_options.txt @@ -0,0 +1,3 @@ +trace_id_hi : 5 +trace_id_lo : 1 +span_id : 7 diff --git a/test/core/census/data/context_span_only.pb b/test/core/census/data/context_span_only.pb Binary files differindex 2a9527a75a..a9315be91a 100644 --- a/test/core/census/data/context_span_only.pb +++ b/test/core/census/data/context_span_only.pb diff --git a/test/core/census/data/context_span_only.txt b/test/core/census/data/context_span_only.txt index d90de2e614..4e473fce53 100644 --- a/test/core/census/data/context_span_only.txt +++ b/test/core/census/data/context_span_only.txt @@ -1,2 +1,2 @@ span_id : 7 -is_sampled : true +span_options : 1 diff --git a/test/core/census/data/context_trace_only.pb b/test/core/census/data/context_trace_only.pb Binary files differindex 7fdf6f61a3..aabb325f92 100644 --- a/test/core/census/data/context_trace_only.pb +++ b/test/core/census/data/context_trace_only.pb diff --git a/test/core/census/data/context_trace_only.txt b/test/core/census/data/context_trace_only.txt index 9b68a6aa92..e48a6d7457 100644 --- a/test/core/census/data/context_trace_only.txt +++ b/test/core/census/data/context_trace_only.txt @@ -1,2 +1,3 @@ -trace_id { hi : 5; lo : 1 } -is_sampled : true +trace_id_hi : 5 +trace_id_lo : 1 +span_options : 1 diff --git a/test/core/census/mlog_test.c b/test/core/census/mlog_test.c index 36e8a492fd..e2605d1291 100644 --- a/test/core/census/mlog_test.c +++ b/test/core/census/mlog_test.c @@ -185,7 +185,7 @@ static void writer_thread(void* arg) { "written\n", args->index, records_written, args->num_records); } - gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10)); + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(10)); } } // Done. Decrement count and signal. diff --git a/test/core/census/trace_context_test.c b/test/core/census/trace_context_test.c index ee409e8d1a..5963b1a246 100644 --- a/test/core/census/trace_context_test.c +++ b/test/core/census/trace_context_test.c @@ -59,7 +59,6 @@ bool validate_encode_decode_context(google_trace_TraceContext *ctxt1, uint8_t *buffer, size_t buf_size) { google_trace_TraceContext ctxt2 = google_trace_TraceContext_init_zero; size_t msg_length; - GPR_ASSERT(ctxt1->has_trace_id && ctxt1->has_span_id); msg_length = encode_trace_context(ctxt1, buffer, buf_size); if (msg_length == 0) { @@ -70,16 +69,17 @@ bool validate_encode_decode_context(google_trace_TraceContext *ctxt1, return false; } - if (!ctxt2.has_trace_id || !ctxt2.has_span_id) { + if (!ctxt2.has_trace_id_hi || !ctxt2.has_trace_id_lo || !ctxt2.has_span_id) { return false; } - GPR_ASSERT( - ctxt1->trace_id.hi == ctxt2.trace_id.hi && - ctxt1->trace_id.lo == ctxt2.trace_id.lo && - ctxt1->span_id == ctxt2.span_id && - ctxt1->has_is_sampled == ctxt2.has_is_sampled && - (ctxt1->has_is_sampled ? ctxt1->is_sampled == ctxt2.is_sampled : true)); + GPR_ASSERT(ctxt1->trace_id_hi == ctxt2.trace_id_hi && + ctxt1->trace_id_lo == ctxt2.trace_id_lo && + ctxt1->span_id == ctxt2.span_id && + ctxt1->has_span_options == ctxt2.has_span_options && + (ctxt1->has_span_options + ? ctxt1->span_options == ctxt2.span_options + : true)); return true; } @@ -94,7 +94,7 @@ bool validate_decode_context(google_trace_TraceContext *ctxt, uint8_t *buffer, return false; } - if (!ctxt->has_trace_id || !ctxt->has_span_id) { + if (!ctxt->has_trace_id_hi || !ctxt->has_trace_id_lo || !ctxt->has_span_id) { return false; } @@ -144,49 +144,48 @@ static void test_span_only() { &ctxt, "test/core/census/data/context_span_only.pb", false); } -// Test proto-buffer without is_sampled value. -static void test_no_sample() { +// Test proto-buffer without span_options value. +static void test_no_span_options() { google_trace_TraceContext ctxt = google_trace_TraceContext_init_zero; read_and_validate_context_from_file( - &ctxt, "test/core/census/data/context_no_sample.pb", true); - GPR_ASSERT(ctxt.has_is_sampled == false && ctxt.is_sampled == false); + &ctxt, "test/core/census/data/context_no_span_options.pb", true); + GPR_ASSERT(ctxt.has_span_options == false && ctxt.span_options == 0); } static void test_encode_decode() { uint8_t buffer[BUF_SIZE] = {0}; google_trace_TraceContext ctxt1 = google_trace_TraceContext_init_zero; - ctxt1.has_trace_id = true; - ctxt1.trace_id.has_hi = true; - ctxt1.trace_id.has_lo = true; - ctxt1.trace_id.lo = 1; - ctxt1.trace_id.hi = 2; + ctxt1.has_trace_id_hi = true; + ctxt1.has_trace_id_lo = true; + ctxt1.trace_id_lo = 1; + ctxt1.trace_id_hi = 2; ctxt1.has_span_id = true; ctxt1.span_id = 3; validate_encode_decode_context(&ctxt1, buffer, sizeof(buffer)); + // Missing trace_id. This should fail. google_trace_TraceContext ctxt2 = google_trace_TraceContext_init_zero; - ctxt2.has_trace_id = true; - ctxt2.trace_id.has_hi = false; - ctxt2.trace_id.has_lo = false; + ctxt2.has_trace_id_hi = false; + ctxt2.has_trace_id_lo = false; ctxt2.has_span_id = true; validate_encode_decode_context(&ctxt2, buffer, sizeof(buffer)); } -// Test a corrupted proto-buffer. +// Test a corrupted proto-buffer. This should fail. static void test_corrupt() { uint8_t buffer[BUF_SIZE] = {0}; google_trace_TraceContext ctxt1 = google_trace_TraceContext_init_zero; size_t msg_length; - ctxt1.has_trace_id = true; - ctxt1.trace_id.has_hi = true; - ctxt1.trace_id.has_lo = true; - ctxt1.trace_id.lo = 1; - ctxt1.trace_id.hi = 2; + ctxt1.has_trace_id_hi = true; + ctxt1.has_trace_id_lo = true; + ctxt1.trace_id_lo = 1; + ctxt1.trace_id_hi = 2; ctxt1.has_span_id = true; ctxt1.span_id = 3; - ctxt1.is_sampled = true; + ctxt1.has_span_options = true; + ctxt1.span_options = SPAN_OPTIONS_IS_SAMPLED; msg_length = encode_trace_context(&ctxt1, buffer, sizeof(buffer)); /* Corrupt some bytes. 255 (0xFF) should be illegal for the first byte of the @@ -198,19 +197,19 @@ static void test_corrupt() { } static void test_buffer_size() { - // This buffer is too small, so the encode should fail. + // This buffer is too small. This should fail. uint8_t buffer[16] = {0}; google_trace_TraceContext ctxt1 = google_trace_TraceContext_init_zero; size_t msg_length; - ctxt1.has_trace_id = true; - ctxt1.trace_id.has_hi = true; - ctxt1.trace_id.has_lo = true; - ctxt1.trace_id.lo = 1; - ctxt1.trace_id.hi = 2; + ctxt1.has_trace_id_hi = true; + ctxt1.has_trace_id_lo = true; + ctxt1.trace_id_lo = 1; + ctxt1.trace_id_hi = 2; ctxt1.has_span_id = true; ctxt1.span_id = 3; - ctxt1.is_sampled = true; + ctxt1.has_span_options = true; + ctxt1.span_options = SPAN_OPTIONS_IS_SAMPLED; msg_length = encode_trace_context(&ctxt1, buffer, sizeof(buffer)); GPR_ASSERT(msg_length == 0); @@ -224,7 +223,7 @@ int main(int argc, char **argv) { test_span_only(); test_encode_decode(); test_corrupt(); - test_no_sample(); + test_no_span_options(); test_buffer_size(); return 0; 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 b43d05eec3..dd9c544524 100644 --- a/test/core/channel/channel_stack_test.c +++ b/test/core/channel/channel_stack_test.c @@ -39,6 +39,7 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> +#include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" static grpc_error *channel_init_func(grpc_exec_ctx *exec_ctx, @@ -120,7 +121,7 @@ static void test_create_channel_stack(void) { int *channel_data; int *call_data; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_mdstr *path = grpc_mdstr_from_string("/service/method"); + grpc_slice path = grpc_slice_from_static_string("/service/method"); arg.type = GRPC_ARG_INTEGER; arg.key = "test_key"; @@ -157,8 +158,8 @@ static void test_create_channel_stack(void) { GRPC_CHANNEL_STACK_UNREF(&exec_ctx, channel_stack, "done"); + grpc_slice_unref_internal(&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 016610763c..057b90ec84 100644 --- a/test/core/client_channel/lb_policies_test.c +++ b/test/core/client_channel/lb_policies_test.c @@ -157,8 +157,7 @@ static void kill_server(const servers_fixture *f, size_t i) { typedef struct request_data { grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; - char *details; - size_t details_capacity; + grpc_slice details; grpc_status_code status; grpc_call_details *call_details; } request_data; @@ -272,8 +271,6 @@ static request_sequences perform_request(servers_fixture *f, for (iter_num = 0; iter_num < spec->num_iters; iter_num++) { cq_verifier *cqv = cq_verifier_create(f->cq); - rdata->details = NULL; - rdata->details_capacity = 0; was_cancelled = 2; for (i = 0; i < f->num_servers; i++) { @@ -294,8 +291,9 @@ static request_sequences perform_request(servers_fixture *f, } memset(s_valid, 0, f->num_servers * sizeof(int)); + grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr"); c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, - "/foo", "foo.test.google.fr", + grpc_slice_from_static_string("/foo"), &host, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(c); completed_client = 0; @@ -312,7 +310,8 @@ static request_sequences perform_request(servers_fixture *f, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &rdata->initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = + &rdata->initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -321,8 +320,6 @@ static request_sequences perform_request(servers_fixture *f, &rdata->trailing_metadata_recv; op->data.recv_status_on_client.status = &rdata->status; op->data.recv_status_on_client.status_details = &rdata->details; - op->data.recv_status_on_client.status_details_capacity = - &rdata->details_capacity; op->flags = 0; op->reserved = NULL; op++; @@ -330,9 +327,10 @@ static request_sequences perform_request(servers_fixture *f, grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL)); s_idx = -1; - while ((ev = grpc_completion_queue_next( - f->cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(RETRY_TIMEOUT), NULL)) - .type != GRPC_QUEUE_TIMEOUT) { + while ( + (ev = grpc_completion_queue_next( + f->cq, grpc_timeout_milliseconds_to_deadline(RETRY_TIMEOUT), NULL)) + .type != GRPC_QUEUE_TIMEOUT) { GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); read_tag = ((int)(intptr_t)ev.tag); const grpc_connectivity_state conn_state = @@ -365,7 +363,8 @@ static request_sequences perform_request(servers_fixture *f, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -384,12 +383,12 @@ static request_sequences perform_request(servers_fixture *f, } cq_verify(cqv); - gpr_log(GPR_DEBUG, "status=%d; %s", rdata->status, rdata->details); GPR_ASSERT(rdata->status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(rdata->details, "xyz")); - GPR_ASSERT(0 == strcmp(rdata->call_details[s_idx].method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(rdata->details, "xyz")); GPR_ASSERT(0 == - strcmp(rdata->call_details[s_idx].host, "foo.test.google.fr")); + grpc_slice_str_cmp(rdata->call_details[s_idx].method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(rdata->call_details[s_idx].host, + "foo.test.google.fr")); GPR_ASSERT(was_cancelled == 1); grpc_call_destroy(f->server_calls[s_idx]); @@ -408,9 +407,10 @@ static request_sequences perform_request(servers_fixture *f, } } - GPR_ASSERT(grpc_completion_queue_next( - f->cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(RETRY_TIMEOUT), NULL) - .type == GRPC_QUEUE_TIMEOUT); + GPR_ASSERT( + grpc_completion_queue_next( + f->cq, grpc_timeout_milliseconds_to_deadline(RETRY_TIMEOUT), NULL) + .type == GRPC_QUEUE_TIMEOUT); grpc_metadata_array_destroy(&rdata->initial_metadata_recv); grpc_metadata_array_destroy(&rdata->trailing_metadata_recv); @@ -422,7 +422,7 @@ static request_sequences perform_request(servers_fixture *f, for (i = 0; i < f->num_servers; i++) { grpc_call_details_destroy(&rdata->call_details[i]); } - gpr_free(rdata->details); + grpc_slice_unref(rdata->details); } gpr_free(s_valid); @@ -454,10 +454,12 @@ static grpc_call **perform_multirequest(servers_fixture *f, op->flags = 0; op->reserved = NULL; + grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr"); for (i = 0; i < concurrent_calls; i++) { - calls[i] = grpc_channel_create_call( - client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, "/foo", - "foo.test.google.fr", gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + calls[i] = + grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, + grpc_slice_from_static_string("/foo"), &host, + gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(calls[i]); GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[i], ops, (size_t)(op - ops), tag(1), @@ -515,7 +517,7 @@ static grpc_channel *create_client(const servers_fixture *f) { grpc_channel *client; char *client_hostport; char *servers_hostports_str; - grpc_arg arg_array[2]; + grpc_arg arg_array[3]; grpc_channel_args args; servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports, @@ -528,7 +530,10 @@ static grpc_channel *create_client(const servers_fixture *f) { arg_array[1].type = GRPC_ARG_STRING; arg_array[1].key = GRPC_ARG_LB_POLICY_NAME; arg_array[1].value.string = "ROUND_ROBIN"; - args.num_args = 2; + arg_array[2].type = GRPC_ARG_INTEGER; + arg_array[2].key = GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS; + arg_array[2].value.integer = 0; + args.num_args = GPR_ARRAY_SIZE(arg_array); args.args = arg_array; client = grpc_insecure_channel_create(client_hostport, &args, NULL); @@ -563,7 +568,7 @@ static void test_ping() { READY is reached */ while (state != GRPC_CHANNEL_READY) { grpc_channel_watch_connectivity_state( - client, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f->cq, tag(99)); + client, state, grpc_timeout_seconds_to_deadline(3), f->cq, tag(99)); CQ_EXPECT_COMPLETION(cqv, tag(99), 1); cq_verify(cqv); state = grpc_channel_check_connectivity_state(client, 0); @@ -645,7 +650,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. 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 b421720492..cfd37052de 100644 --- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c +++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c @@ -86,7 +86,7 @@ static void on_done(grpc_exec_ctx *exec_ctx, void *ev, grpc_error *error) { static bool wait_loop(int deadline_seconds, gpr_event *ev) { while (deadline_seconds) { gpr_log(GPR_DEBUG, "Test: waiting for %d more seconds", deadline_seconds); - if (gpr_event_wait(ev, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1))) return true; + if (gpr_event_wait(ev, grpc_timeout_seconds_to_deadline(1))) return true; deadline_seconds--; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -108,21 +108,23 @@ int main(int argc, char **argv) { 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/sockaddr_resolver_test.c b/test/core/client_channel/resolvers/sockaddr_resolver_test.c index a9fd85aea1..10df78537c 100644 --- a/test/core/client_channel/resolvers/sockaddr_resolver_test.c +++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.c @@ -49,7 +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; - 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) { @@ -68,8 +68,8 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) { 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); 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 11e57439d5..a0a33667cc 100644 --- a/test/core/client_channel/set_initial_connect_string_test.c +++ b/test/core/client_channel/set_initial_connect_string_test.c @@ -81,7 +81,9 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { state.incoming_buffer.length, strlen(magic_connect_string)); if (state.incoming_buffer.length > strlen(magic_connect_string)) { gpr_atm_rel_store(&state.done_atm, 1); - grpc_endpoint_shutdown(exec_ctx, state.tcp); + grpc_endpoint_shutdown( + exec_ctx, state.tcp, + GRPC_ERROR_CREATE("Incoming buffer longer than magic_connect_string")); grpc_endpoint_destroy(exec_ctx, state.tcp); } else { grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer, @@ -94,7 +96,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, 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; @@ -141,9 +143,11 @@ static void start_rpc(int use_creds, int target_port) { } else { state.channel = grpc_insecure_channel_create(state.target, NULL, NULL); } + grpc_slice host = grpc_slice_from_static_string("localhost"); state.call = grpc_channel_create_call( - state.channel, NULL, GRPC_PROPAGATE_DEFAULTS, state.cq, "/Service/Method", - "localhost", gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + state.channel, NULL, GRPC_PROPAGATE_DEFAULTS, state.cq, + grpc_slice_from_static_string("/Service/Method"), &host, + gpr_inf_future(GPR_CLOCK_REALTIME), NULL); memset(&state.op, 0, sizeof(state.op)); state.op.op = GRPC_OP_SEND_INITIAL_METADATA; state.op.data.send_initial_metadata.count = 0; @@ -158,7 +162,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 { @@ -207,8 +211,7 @@ static void match_initial_magic_string(grpc_slice_buffer *buffer) { size_t magic_length = strlen(magic_connect_string); GPR_ASSERT(buffer->length >= magic_length); for (i = 0, j = 0; i < state.incoming_buffer.count && j < magic_length; i++) { - char *dump = - grpc_dump_slice(state.incoming_buffer.slices[i], GPR_DUMP_ASCII); + char *dump = grpc_slice_to_c_string(state.incoming_buffer.slices[i]); cmp_length = GPR_MIN(strlen(dump), magic_length - j); GPR_ASSERT(strncmp(dump, magic_connect_string + j, cmp_length) == 0); j += cmp_length; diff --git a/test/core/compression/algorithm_test.c b/test/core/compression/algorithm_test.c index bdee748ae6..37397ced8d 100644 --- a/test/core/compression/algorithm_test.c +++ b/test/core/compression/algorithm_test.c @@ -40,6 +40,7 @@ #include <grpc/support/log.h> #include <grpc/support/useful.h> +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/static_metadata.h" #include "test/core/util/test_config.h" @@ -51,29 +52,33 @@ static void test_algorithm_mesh(void) { for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { char *name; grpc_compression_algorithm parsed; - grpc_mdstr *mdstr; - grpc_mdelem *mdelem; + grpc_slice 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)); + GPR_ASSERT(grpc_compression_algorithm_parse( + grpc_slice_from_static_string(name), &parsed)); GPR_ASSERT((int)parsed == i); - mdstr = grpc_mdstr_from_string(name); - GPR_ASSERT(mdstr == grpc_compression_algorithm_mdstr(parsed)); - GPR_ASSERT(parsed == grpc_compression_algorithm_from_mdstr(mdstr)); + mdstr = grpc_slice_from_copied_string(name); + GPR_ASSERT(grpc_slice_eq(mdstr, grpc_compression_algorithm_slice(parsed))); + GPR_ASSERT(parsed == grpc_compression_algorithm_from_slice(mdstr)); 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); + GPR_ASSERT(grpc_slice_eq(GRPC_MDVALUE(mdelem), mdstr)); + GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING)); + grpc_slice_unref_internal(&exec_ctx, mdstr); + GRPC_MDELEM_UNREF(&exec_ctx, mdelem); + grpc_exec_ctx_finish(&exec_ctx); } /* test failure */ - GPR_ASSERT(NULL == - grpc_compression_encoding_mdelem(GRPC_COMPRESS_ALGORITHMS_COUNT)); + GPR_ASSERT(GRPC_MDISNULL( + grpc_compression_encoding_mdelem(GRPC_COMPRESS_ALGORITHMS_COUNT))); } static void test_algorithm_failure(void) { - grpc_mdstr *mdstr; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_slice mdstr; gpr_log(GPR_DEBUG, "test_algorithm_failure"); @@ -81,14 +86,17 @@ static void test_algorithm_failure(void) { NULL) == 0); GPR_ASSERT(grpc_compression_algorithm_name(GRPC_COMPRESS_ALGORITHMS_COUNT + 1, NULL) == 0); - mdstr = grpc_mdstr_from_string("this-is-an-invalid-algorithm"); - GPR_ASSERT(grpc_compression_algorithm_from_mdstr(mdstr) == + mdstr = grpc_slice_from_static_string("this-is-an-invalid-algorithm"); + GPR_ASSERT(grpc_compression_algorithm_from_slice(mdstr) == GRPC_COMPRESS_ALGORITHMS_COUNT); - GPR_ASSERT(grpc_compression_algorithm_mdstr(GRPC_COMPRESS_ALGORITHMS_COUNT) == - NULL); - GPR_ASSERT(grpc_compression_algorithm_mdstr(GRPC_COMPRESS_ALGORITHMS_COUNT + - 1) == NULL); - GRPC_MDSTR_UNREF(mdstr); + GPR_ASSERT(grpc_slice_eq( + grpc_compression_algorithm_slice(GRPC_COMPRESS_ALGORITHMS_COUNT), + grpc_empty_slice())); + GPR_ASSERT(grpc_slice_eq( + grpc_compression_algorithm_slice(GRPC_COMPRESS_ALGORITHMS_COUNT + 1), + grpc_empty_slice())); + grpc_slice_unref_internal(&exec_ctx, mdstr); + grpc_exec_ctx_finish(&exec_ctx); } int main(int argc, char **argv) { diff --git a/test/core/compression/compression_test.c b/test/core/compression/compression_test.c index 4c43746e33..7b2e56dc01 100644 --- a/test/core/compression/compression_test.c +++ b/test/core/compression/compression_test.c @@ -54,7 +54,7 @@ static void test_compression_algorithm_parse(void) { const char *valid_name = valid_names[i]; grpc_compression_algorithm algorithm; const int success = grpc_compression_algorithm_parse( - valid_name, strlen(valid_name), &algorithm); + grpc_slice_from_static_string(valid_name), &algorithm); GPR_ASSERT(success != 0); GPR_ASSERT(algorithm == valid_algorithms[i]); } @@ -64,7 +64,7 @@ static void test_compression_algorithm_parse(void) { grpc_compression_algorithm algorithm; int success; success = grpc_compression_algorithm_parse( - invalid_name, strlen(invalid_name), &algorithm); + grpc_slice_from_static_string(invalid_name), &algorithm); GPR_ASSERT(success == 0); /* the value of "algorithm" is undefined upon failure */ } diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index fc53cd9d36..246a2b3a71 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,11 +105,16 @@ 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)); + GPR_ASSERT(grpc_slice_eq(value, final)); grpc_slice_buffer_destroy(&input); grpc_slice_buffer_destroy(&compressed); @@ -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 30468558e8..42d960c428 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" @@ -134,7 +135,7 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { gpr_log(GPR_DEBUG, "got %" PRIuPTR " bytes, expected %" PRIuPTR " bytes", state.incoming_data_length, EXPECTED_INCOMING_DATA_LENGTH); - if (state.incoming_data_length > EXPECTED_INCOMING_DATA_LENGTH) { + if (state.incoming_data_length >= EXPECTED_INCOMING_DATA_LENGTH) { handle_write(exec_ctx); } else { grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer, @@ -147,8 +148,8 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, 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; @@ -171,16 +172,17 @@ static void start_rpc(int target_port, grpc_status_code expected_status, grpc_status_code status; grpc_call_error error; cq_verifier *cqv; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; state.cq = grpc_completion_queue_create(NULL); cqv = cq_verifier_create(state.cq); gpr_join_host_port(&state.target, "127.0.0.1", target_port); state.channel = grpc_insecure_channel_create(state.target, NULL, NULL); + grpc_slice host = grpc_slice_from_static_string("localhost"); state.call = grpc_channel_create_call( - state.channel, NULL, GRPC_PROPAGATE_DEFAULTS, state.cq, "/Service/Method", - "localhost", gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + state.channel, NULL, GRPC_PROPAGATE_DEFAULTS, state.cq, + grpc_slice_from_static_string("/Service/Method"), &host, + gpr_inf_future(GPR_CLOCK_REALTIME), NULL); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -197,7 +199,7 @@ static void start_rpc(int target_port, grpc_status_code expected_status, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -205,7 +207,6 @@ static void start_rpc(int target_port, grpc_status_code expected_status, 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++; @@ -217,20 +218,20 @@ static void start_rpc(int target_port, grpc_status_code expected_status, CQ_EXPECT_COMPLETION(cqv, tag(1), 1); cq_verify(cqv); - gpr_log(GPR_DEBUG, "Rpc status: %d, details: %s", status, details); GPR_ASSERT(status == expected_status); - GPR_ASSERT(NULL != strstr(details, expected_detail)); + GPR_ASSERT(-1 != grpc_slice_slice(details, grpc_slice_from_static_string( + expected_detail))); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); - gpr_free(details); + grpc_slice_unref(details); 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 { @@ -297,10 +298,11 @@ static void run_test(const char *response_payload, gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME)); /* clean up */ - grpc_endpoint_shutdown(&exec_ctx, state.tcp); + grpc_endpoint_shutdown(&exec_ctx, state.tcp, + GRPC_ERROR_CREATE("Test Shutdown")); 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..16a3005539 100644 --- a/test/core/end2end/connection_refused_test.c +++ b/test/core/end2end/connection_refused_test.c @@ -40,6 +40,7 @@ #include <grpc/support/string_util.h> #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" @@ -52,15 +53,14 @@ static void *tag(intptr_t i) { return (void *)i; } static void run_test(bool wait_for_ready, bool use_service_config) { grpc_channel *chan; grpc_call *call; - gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2); + gpr_timespec deadline = grpc_timeout_seconds_to_deadline(2); grpc_completion_queue *cq; cq_verifier *cqv; grpc_op ops[6]; grpc_op *op; grpc_metadata_array trailing_metadata_recv; grpc_status_code status; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; gpr_log(GPR_INFO, "TEST: wait_for_ready=%d use_service_config=%d", wait_for_ready, use_service_config); @@ -97,9 +97,10 @@ static void run_test(bool wait_for_ready, bool use_service_config) { gpr_join_host_port(&addr, "127.0.0.1", port); gpr_log(GPR_INFO, "server: %s", addr); chan = grpc_insecure_channel_create(addr, args, NULL); - call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, - "/service/method", "nonexistant", deadline, - NULL); + grpc_slice host = grpc_slice_from_static_string("nonexistant"); + call = grpc_channel_create_call( + chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, + grpc_slice_from_static_string("/service/method"), &host, deadline, NULL); gpr_free(addr); @@ -116,7 +117,6 @@ static void run_test(bool wait_for_ready, bool use_service_config) { 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++; @@ -142,10 +142,14 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_channel_destroy(chan); cq_verifier_destroy(cqv); - gpr_free(details); + grpc_slice_unref(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/cq_verifier.c b/test/core/end2end/cq_verifier.c index 57373970c4..9b0106ec84 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -92,8 +92,8 @@ static int has_metadata(const grpc_metadata *md, size_t count, const char *key, const char *value) { size_t i; for (i = 0; i < count; i++) { - if (0 == strcmp(key, md[i].key) && strlen(value) == md[i].value_length && - 0 == memcmp(md[i].value, value, md[i].value_length)) { + if (0 == grpc_slice_str_cmp(md[i].key, key) && + 0 == grpc_slice_str_cmp(md[i].value, value)) { return 1; } } @@ -105,6 +105,22 @@ int contains_metadata(grpc_metadata_array *array, const char *key, return has_metadata(array->metadata, array->count, key, value); } +static int has_metadata_slices(const grpc_metadata *md, size_t count, + grpc_slice key, grpc_slice value) { + size_t i; + for (i = 0; i < count; i++) { + if (grpc_slice_eq(md[i].key, key) && grpc_slice_eq(md[i].value, value)) { + return 1; + } + } + return 0; +} + +int contains_metadata_slices(grpc_metadata_array *array, grpc_slice key, + grpc_slice value) { + return has_metadata_slices(array->metadata, array->count, key, value); +} + static grpc_slice merge_slices(grpc_slice *slices, size_t nslices) { size_t i; size_t len = 0; @@ -233,7 +249,7 @@ static void fail_no_event_received(cq_verifier *v) { } void cq_verify(cq_verifier *v) { - const gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10); + const gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10); while (v->first_expectation != NULL) { grpc_event ev = grpc_completion_queue_next(v->cq, deadline, NULL); if (ev.type == GRPC_QUEUE_TIMEOUT) { diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h index b754de9bbe..035aa270e4 100644 --- a/test/core/end2end/cq_verifier.h +++ b/test/core/end2end/cq_verifier.h @@ -71,5 +71,7 @@ int byte_buffer_eq_slice(grpc_byte_buffer *bb, grpc_slice b); int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string); int contains_metadata(grpc_metadata_array *array, const char *key, const char *value); +int contains_metadata_slices(grpc_metadata_array *array, grpc_slice key, + grpc_slice value); #endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_H */ diff --git a/test/core/end2end/cq_verifier_native.c b/test/core/end2end/cq_verifier_native.c index b1fcb4beed..e0f1d79e83 100644 --- a/test/core/end2end/cq_verifier_native.c +++ b/test/core/end2end/cq_verifier_native.c @@ -67,7 +67,7 @@ void cq_verifier_set_first_expectation(cq_verifier *v, expectation *e) { grpc_event cq_verifier_next_event(cq_verifier *v, int timeout_seconds) { const gpr_timespec deadline = - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(timeout_seconds); + grpc_timeout_seconds_to_deadline(timeout_seconds); return grpc_completion_queue_next(v->cq, deadline, NULL); } diff --git a/test/core/end2end/data/ssl_test_data.h b/test/core/end2end/data/ssl_test_data.h index 4a64af1e27..0b274e0d95 100644 --- a/test/core/end2end/data/ssl_test_data.h +++ b/test/core/end2end/data/ssl_test_data.h @@ -34,6 +34,10 @@ #ifndef GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H #define GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H +#ifdef __cplusplus +extern "C" { +#endif + extern const char test_root_cert[]; extern const char test_server1_cert[]; extern const char test_server1_key[]; @@ -42,4 +46,8 @@ extern const char test_self_signed_client_key[]; extern const char test_signed_client_cert[]; extern const char test_signed_client_key[]; +#ifdef __cplusplus +} +#endif + #endif /* GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H */ diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index 11e8604f56..3623bd7be8 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -57,7 +57,7 @@ static void *tag(intptr_t i) { return (void *)i; } static gpr_timespec ms_from_now(int ms) { - return GRPC_TIMEOUT_MILLIS_TO_DEADLINE(ms); + return grpc_timeout_milliseconds_to_deadline(ms); } static void drain_cq(grpc_completion_queue *cq) { @@ -88,8 +88,7 @@ void test_connect(const char *server_host, const char *client_host, int port, grpc_metadata_array request_metadata_recv; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; grpc_call_details call_details; char *peer; @@ -135,7 +134,7 @@ void test_connect(const char *server_host, const char *client_host, int port, grpc_slice_split(uri_slice, ",", &uri_parts); hosts_with_port = gpr_malloc(sizeof(char *) * uri_parts.count); for (i = 0; i < uri_parts.count; i++) { - char *uri_part_str = grpc_dump_slice(uri_parts.slices[i], GPR_DUMP_ASCII); + char *uri_part_str = grpc_slice_to_c_string(uri_parts.slices[i]); gpr_asprintf(&hosts_with_port[i], "%s:%d", uri_part_str, port); gpr_free(uri_part_str); } @@ -168,8 +167,10 @@ void test_connect(const char *server_host, const char *client_host, int port, } /* Send a trivial request. */ + grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr"); c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, cq, - "/foo", "foo.test.google.fr", deadline, NULL); + grpc_slice_from_static_string("/foo"), &host, + deadline, NULL); GPR_ASSERT(c); memset(ops, 0, sizeof(ops)); @@ -184,7 +185,7 @@ void test_connect(const char *server_host, const char *client_host, int port, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -192,7 +193,6 @@ void test_connect(const char *server_host, const char *client_host, int port, 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++; @@ -216,7 +216,8 @@ void test_connect(const char *server_host, const char *client_host, int port, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op++; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -235,9 +236,10 @@ void test_connect(const char *server_host, const char *client_host, int port, gpr_free(peer); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); + GPR_ASSERT(0 == + grpc_slice_str_cmp(call_details.host, "foo.test.google.fr")); GPR_ASSERT(was_cancelled == 1); grpc_call_destroy(s); @@ -259,7 +261,7 @@ void test_connect(const char *server_host, const char *client_host, int port, /* Destroy server. */ 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) + cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(server); grpc_completion_queue_shutdown(cq); @@ -271,7 +273,7 @@ void test_connect(const char *server_host, const char *client_host, int port, grpc_metadata_array_destroy(&request_metadata_recv); grpc_call_details_destroy(&call_details); - gpr_free(details); + grpc_slice_unref(details); if (picked_port) { grpc_recycle_unused_port(port); } diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c index 663489082f..fdfa31b5fb 100644 --- a/test/core/end2end/end2end_nosec_tests.c +++ b/test/core/end2end/end2end_nosec_tests.c @@ -41,6 +41,8 @@ #include <grpc/support/log.h> +#include "test/core/util/debugger_macros.h" + static bool g_pre_init_called = false; extern void authority_not_supported(grpc_end2end_test_config config); @@ -135,10 +137,15 @@ 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); g_pre_init_called = true; + grpc_summon_debugger_macros(); authority_not_supported_pre_init(); bad_hostname_pre_init(); binary_metadata_pre_init(); @@ -185,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, @@ -240,6 +249,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 +439,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_test_utils.c b/test/core/end2end/end2end_test_utils.c index 46fb4ec1af..8783d8451b 100644 --- a/test/core/end2end/end2end_test_utils.c +++ b/test/core/end2end/end2end_test_utils.c @@ -39,13 +39,27 @@ const char *get_host_override_string(const char *str, grpc_end2end_test_config config) { - return (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER ? str - : NULL); + if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) { + return str; + } else { + return NULL; + } +} + +const grpc_slice *get_host_override_slice(const char *str, + grpc_end2end_test_config config) { + const char *r = get_host_override_string(str, config); + if (r != NULL) { + static grpc_slice ret; + ret = grpc_slice_from_static_string(r); + return &ret; + } + return NULL; } -void validate_host_override_string(const char *pattern, const char *str, +void validate_host_override_string(const char *pattern, grpc_slice str, grpc_end2end_test_config config) { if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) { - GPR_ASSERT(0 == strcmp(str, pattern)); + GPR_ASSERT(0 == grpc_slice_str_cmp(str, pattern)); } } diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c index 25c7c62fde..f529d6a899 100644 --- a/test/core/end2end/end2end_tests.c +++ b/test/core/end2end/end2end_tests.c @@ -41,6 +41,8 @@ #include <grpc/support/log.h> +#include "test/core/util/debugger_macros.h" + static bool g_pre_init_called = false; extern void authority_not_supported(grpc_end2end_test_config config); @@ -137,10 +139,15 @@ 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); g_pre_init_called = true; + grpc_summon_debugger_macros(); authority_not_supported_pre_init(); bad_hostname_pre_init(); binary_metadata_pre_init(); @@ -188,6 +195,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 +253,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 +447,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_tests.h b/test/core/end2end/end2end_tests.h index f25e90b5f6..cb0afd9cd9 100644 --- a/test/core/end2end/end2end_tests.h +++ b/test/core/end2end/end2end_tests.h @@ -72,8 +72,12 @@ void grpc_end2end_tests(int argc, char **argv, grpc_end2end_test_config config); const char *get_host_override_string(const char *str, grpc_end2end_test_config config); +/* Returns a pointer to a statically allocated slice: future invocations + overwrite past invocations, not threadsafe, etc... */ +const grpc_slice *get_host_override_slice(const char *str, + grpc_end2end_test_config config); -void validate_host_override_string(const char *pattern, const char *str, +void validate_host_override_string(const char *pattern, grpc_slice str, grpc_end2end_test_config config); #endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */ diff --git a/test/core/end2end/fake_resolver.c b/test/core/end2end/fake_resolver.c index ed85030797..4f05f69f01 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; } } @@ -153,30 +154,57 @@ static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx, grpc_uri_get_query_arg(args->uri, "lb_enabled"); const bool lb_enabled = lb_enabled_qpart != NULL && strcmp("0", lb_enabled_qpart) != 0; + + // Get the balancer's names. + const char* balancer_names = + grpc_uri_get_query_arg(args->uri, "balancer_names"); + grpc_slice_buffer balancer_names_parts; + grpc_slice_buffer_init(&balancer_names_parts); + if (balancer_names != NULL) { + const grpc_slice balancer_names_slice = + grpc_slice_from_copied_string(balancer_names); + grpc_slice_split(balancer_names_slice, ",", &balancer_names_parts); + grpc_slice_unref(balancer_names_slice); + } + // Construct addresses. grpc_slice path_slice = grpc_slice_new(args->uri->path, strlen(args->uri->path), do_nothing); grpc_slice_buffer path_parts; grpc_slice_buffer_init(&path_parts); grpc_slice_split(path_slice, ",", &path_parts); + if (balancer_names_parts.count > 0 && + path_parts.count != balancer_names_parts.count) { + gpr_log(GPR_ERROR, + "Balancer names present but mismatched with number of addresses: " + "%lu balancer names != %lu addresses", + (unsigned long)balancer_names_parts.count, + (unsigned long)path_parts.count); + return NULL; + } grpc_lb_addresses* addresses = grpc_lb_addresses_create(path_parts.count, NULL /* user_data_vtable */); bool errors_found = false; for (size_t i = 0; i < addresses->num_addresses; i++) { grpc_uri ith_uri = *args->uri; - char* part_str = grpc_dump_slice(path_parts.slices[i], GPR_DUMP_ASCII); + char* part_str = grpc_slice_to_c_string(path_parts.slices[i]); ith_uri.path = part_str; if (!parse_ipv4(&ith_uri, &addresses->addresses[i].address)) { errors_found = true; } gpr_free(part_str); - addresses->addresses[i].is_balancer = lb_enabled; if (errors_found) break; + addresses->addresses[i].is_balancer = lb_enabled; + addresses->addresses[i].balancer_name = + balancer_names_parts.count > 0 + ? grpc_dump_slice(balancer_names_parts.slices[i], GPR_DUMP_ASCII) + : NULL; } - grpc_slice_buffer_destroy(&path_parts); + grpc_slice_buffer_destroy_internal(exec_ctx, &path_parts); + grpc_slice_buffer_destroy_internal(exec_ctx, &balancer_names_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. 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_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c index 11a102a576..01316376e0 100644 --- a/test/core/end2end/fixtures/h2_full+trace.c +++ b/test/core/end2end/fixtures/h2_full+trace.c @@ -117,9 +117,9 @@ int main(int argc, char **argv) { gpr_setenv("GRPC_TRACE", "doesnt-exist,http,all"); #ifdef GRPC_POSIX_SOCKET - g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10.0 : 1.0; + g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; #else - g_fixture_slowdown_factor = 10.0; + g_fixture_slowdown_factor = 10; #endif grpc_test_init(argc, argv); 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..3351652858 100644 --- a/test/core/end2end/fixtures/h2_oauth2.c +++ b/test/core/end2end/fixtures/h2_oauth2.c @@ -59,8 +59,8 @@ static const grpc_metadata *find_metadata(const grpc_metadata *md, const char *value) { size_t i; for (i = 0; i < md_count; i++) { - if (strcmp(key, md[i].key) == 0 && strlen(value) == md[i].value_length && - memcmp(md[i].value, value, md[i].value_length) == 0) { + if (grpc_slice_str_cmp(md[i].key, key) == 0 && + grpc_slice_str_cmp(md[i].value, value) == 0) { return &md[i]; } } @@ -74,7 +74,7 @@ static void process_oauth2_success(void *state, grpc_auth_context *ctx, grpc_process_auth_metadata_done_cb cb, void *user_data) { const grpc_metadata *oauth2 = - find_metadata(md, md_count, "Authorization", oauth2_md); + find_metadata(md, md_count, "authorization", oauth2_md); test_processor_state *s; GPR_ASSERT(state != NULL); @@ -93,7 +93,7 @@ static void process_oauth2_failure(void *state, grpc_auth_context *ctx, grpc_process_auth_metadata_done_cb cb, void *user_data) { const grpc_metadata *oauth2 = - find_metadata(md, md_count, "Authorization", oauth2_md); + find_metadata(md, md_count, "authorization", oauth2_md); test_processor_state *s; GPR_ASSERT(state != NULL); s = (test_processor_state *)state; @@ -154,7 +154,7 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( grpc_channel_credentials *ssl_creds = grpc_ssl_credentials_create(test_root_cert, NULL, NULL); grpc_call_credentials *oauth2_creds = - grpc_md_only_test_credentials_create("Authorization", oauth2_md, 1); + grpc_md_only_test_credentials_create("authorization", oauth2_md, 1); grpc_channel_credentials *ssl_oauth2_creds = grpc_composite_channel_credentials_create(ssl_creds, oauth2_creds, NULL); grpc_arg ssl_name_override = {GRPC_ARG_STRING, @@ -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_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c index 726ed8735c..edf42a4070 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.c +++ b/test/core/end2end/fixtures/h2_sockpair+trace.c @@ -154,9 +154,9 @@ int main(int argc, char **argv) { code paths in trace.c to be taken */ gpr_setenv("GRPC_TRACE", "doesnt-exist,http,all"); #ifdef GRPC_POSIX_SOCKET - g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10.0 : 1.0; + g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; #else - g_fixture_slowdown_factor = 10.0; + g_fixture_slowdown_factor = 10; #endif grpc_test_init(argc, argv); diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.c index 11af7bee1e..6f9cf8fe26 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.c +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.c @@ -144,7 +144,7 @@ static grpc_end2end_test_config configs[] = { int main(int argc, char **argv) { size_t i; - g_fixture_slowdown_factor = 2.0; + g_fixture_slowdown_factor = 2; grpc_test_init(argc, argv); grpc_end2end_tests_pre_init(); 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..f62331eea3 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) @@ -271,7 +275,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -287,7 +291,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -317,9 +321,10 @@ static void simple_request_body(grpc_end2end_test_fixture f, grpc_op *op; grpc_call_error error; + grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr:1234"); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", deadline, - NULL); + grpc_slice_from_static_string("/foo"), &host, + deadline, NULL); GPR_ASSERT(c); memset(ops, 0, sizeof(ops)); 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 80865fc7a6..6fdc86fc12 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); @@ -129,10 +132,13 @@ static void proxy_connection_failed(grpc_exec_ctx* exec_ctx, const char* prefix, grpc_error* error) { const char* msg = grpc_error_string(error); gpr_log(GPR_INFO, "%s: %s", prefix, msg); - grpc_error_free_string(msg); - grpc_endpoint_shutdown(exec_ctx, conn->client_endpoint); - if (conn->server_endpoint != NULL) - grpc_endpoint_shutdown(exec_ctx, conn->server_endpoint); + + grpc_endpoint_shutdown(exec_ctx, conn->client_endpoint, + GRPC_ERROR_REF(error)); + if (conn->server_endpoint != NULL) { + grpc_endpoint_shutdown(exec_ctx, conn->server_endpoint, + GRPC_ERROR_REF(error)); + } proxy_connection_unref(exec_ctx, conn); } @@ -376,15 +382,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); @@ -469,9 +480,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/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.c index beed80df81..cee053e8c5 100644 --- a/test/core/end2end/fixtures/proxy.c +++ b/test/core/end2end/fixtures/proxy.c @@ -80,8 +80,7 @@ typedef struct { grpc_metadata_array p2s_trailing_metadata; grpc_status_code p2s_status; - char *p2s_status_details; - size_t p2s_status_details_capacity; + grpc_slice p2s_status_details; int c2p_server_cancelled; } proxy_call; @@ -112,6 +111,7 @@ grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def, grpc_server_register_completion_queue(proxy->server, proxy->cq, NULL); grpc_server_start(proxy->server); + grpc_call_details_init(&proxy->new_call_details); gpr_thd_options_set_joinable(&opt); GPR_ASSERT(gpr_thd_new(&proxy->thd, thread_main, proxy, &opt)); @@ -153,7 +153,7 @@ static void unrefpc(proxy_call *pc, const char *reason) { grpc_metadata_array_destroy(&pc->c2p_initial_metadata); grpc_metadata_array_destroy(&pc->p2s_initial_metadata); grpc_metadata_array_destroy(&pc->p2s_trailing_metadata); - gpr_free(pc->p2s_status_details); + grpc_slice_unref(pc->p2s_status_details); gpr_free(pc); } } @@ -203,7 +203,7 @@ static void on_p2s_sent_message(void *arg, int success) { op.op = GRPC_OP_RECV_MESSAGE; op.flags = 0; op.reserved = NULL; - op.data.recv_message = &pc->c2p_msg; + op.data.recv_message.recv_message = &pc->c2p_msg; refpc(pc, "on_c2p_recv_msg"); err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_recv_msg, pc), NULL); @@ -228,7 +228,7 @@ static void on_c2p_recv_msg(void *arg, int success) { op.op = GRPC_OP_SEND_MESSAGE; op.flags = 0; op.reserved = NULL; - op.data.send_message = pc->c2p_msg; + op.data.send_message.send_message = pc->c2p_msg; refpc(pc, "on_p2s_sent_message"); err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_sent_message, pc), NULL); @@ -259,7 +259,7 @@ static void on_c2p_sent_message(void *arg, int success) { op.op = GRPC_OP_RECV_MESSAGE; op.flags = 0; op.reserved = NULL; - op.data.recv_message = &pc->p2s_msg; + op.data.recv_message.recv_message = &pc->p2s_msg; refpc(pc, "on_p2s_recv_msg"); err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_recv_msg, pc), NULL); @@ -278,7 +278,7 @@ static void on_p2s_recv_msg(void *arg, int success) { op.op = GRPC_OP_SEND_MESSAGE; op.flags = 0; op.reserved = NULL; - op.data.send_message = pc->p2s_msg; + op.data.send_message.send_message = pc->p2s_msg; refpc(pc, "on_c2p_sent_message"); err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_sent_message, pc), NULL); @@ -309,7 +309,7 @@ static void on_p2s_status(void *arg, int success) { op.data.send_status_from_server.trailing_metadata = pc->p2s_trailing_metadata.metadata; op.data.send_status_from_server.status = pc->p2s_status; - op.data.send_status_from_server.status_details = pc->p2s_status_details; + op.data.send_status_from_server.status_details = &pc->p2s_status_details; refpc(pc, "on_c2p_sent_status"); err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_sent_status, pc), NULL); @@ -339,7 +339,7 @@ static void on_new_call(void *arg, int success) { pc->c2p = proxy->new_call; pc->p2s = grpc_channel_create_call( proxy->client, pc->c2p, GRPC_PROPAGATE_DEFAULTS, proxy->cq, - proxy->new_call_details.method, proxy->new_call_details.host, + proxy->new_call_details.method, &proxy->new_call_details.host, proxy->new_call_details.deadline, NULL); gpr_ref_init(&pc->refs, 1); @@ -347,7 +347,8 @@ static void on_new_call(void *arg, int success) { op.op = GRPC_OP_RECV_INITIAL_METADATA; op.flags = 0; - op.data.recv_initial_metadata = &pc->p2s_initial_metadata; + op.data.recv_initial_metadata.recv_initial_metadata = + &pc->p2s_initial_metadata; refpc(pc, "on_p2s_recv_initial_metadata"); err = grpc_call_start_batch( pc->p2s, &op, 1, new_closure(on_p2s_recv_initial_metadata, pc), NULL); @@ -364,7 +365,7 @@ static void on_new_call(void *arg, int success) { op.op = GRPC_OP_RECV_MESSAGE; op.flags = 0; - op.data.recv_message = &pc->c2p_msg; + op.data.recv_message.recv_message = &pc->c2p_msg; refpc(pc, "on_c2p_recv_msg"); err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_recv_msg, pc), NULL); @@ -372,7 +373,7 @@ static void on_new_call(void *arg, int success) { op.op = GRPC_OP_RECV_MESSAGE; op.flags = 0; - op.data.recv_message = &pc->p2s_msg; + op.data.recv_message.recv_message = &pc->p2s_msg; refpc(pc, "on_p2s_recv_msg"); err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_recv_msg, pc), NULL); @@ -384,8 +385,6 @@ static void on_new_call(void *arg, int success) { &pc->p2s_trailing_metadata; op.data.recv_status_on_client.status = &pc->p2s_status; op.data.recv_status_on_client.status_details = &pc->p2s_status_details; - op.data.recv_status_on_client.status_details_capacity = - &pc->p2s_status_details_capacity; refpc(pc, "on_p2s_status"); err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_status, pc), NULL); @@ -401,6 +400,9 @@ static void on_new_call(void *arg, int success) { request_call(proxy); + grpc_call_details_destroy(&proxy->new_call_details); + grpc_call_details_init(&proxy->new_call_details); + unrefpc(pc, "init"); } else { GPR_ASSERT(proxy->new_call == NULL); 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 746134c85b..0de8b9459a 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -44,6 +44,7 @@ #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/tcp_client.h" #include "src/core/lib/iomgr/timer.h" +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/server.h" #include "src/core/lib/transport/metadata.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -90,7 +91,7 @@ static uint8_t next_byte(input_stream *inp) { static void end(input_stream *inp) { inp->cur = inp->end; } -static char *read_string(input_stream *inp) { +static char *read_string(input_stream *inp, bool *special) { char *str = NULL; size_t cap = 0; size_t sz = 0; @@ -102,18 +103,56 @@ static char *read_string(input_stream *inp) { } c = (char)next_byte(inp); str[sz++] = c; - } while (c != 0); + } while (c != 0 && c != 1); + if (special != NULL) { + *special = (c == 1); + } + if (c == 1) { + str[sz - 1] = 0; + } return str; } -static void read_buffer(input_stream *inp, char **buffer, size_t *length) { +static void read_buffer(input_stream *inp, char **buffer, size_t *length, + bool *special) { *length = next_byte(inp); + if (*length == 255) { + if (special != NULL) *special = true; + *length = next_byte(inp); + } else { + if (special != NULL) *special = false; + } *buffer = gpr_malloc(*length); for (size_t i = 0; i < *length; i++) { (*buffer)[i] = (char)next_byte(inp); } } +static grpc_slice maybe_intern(grpc_slice s, bool intern) { + grpc_slice r = intern ? grpc_slice_intern(s) : grpc_slice_ref(s); + grpc_slice_unref(s); + return r; +} + +static grpc_slice read_string_like_slice(input_stream *inp) { + bool special; + char *s = read_string(inp, &special); + grpc_slice r = maybe_intern(grpc_slice_from_copied_string(s), special); + gpr_free(s); + return r; +} + +static grpc_slice read_buffer_like_slice(input_stream *inp) { + char *buffer; + size_t length; + bool special; + read_buffer(inp, &buffer, &length, &special); + grpc_slice r = + maybe_intern(grpc_slice_from_copied_buffer(buffer, length), special); + gpr_free(buffer); + return r; +} + static uint32_t read_uint22(input_stream *inp) { uint8_t b = next_byte(inp); uint32_t x = b & 0x7f; @@ -170,12 +209,12 @@ static grpc_channel_args *read_args(input_stream *inp) { switch (next_byte(inp)) { case 1: args[i].type = GRPC_ARG_STRING; - args[i].key = read_string(inp); - args[i].value.string = read_string(inp); + args[i].key = read_string(inp, NULL); + args[i].value.string = read_string(inp, NULL); break; case 2: args[i].type = GRPC_ARG_INTEGER; - args[i].key = read_string(inp); + args[i].key = read_string(inp, NULL); args[i].value.integer = read_int(inp); break; case 3: @@ -217,7 +256,7 @@ static const char *read_cred_artifact(cred_artifact_ctx *ctx, input_stream *inp, size_t num_builtins) { uint8_t b = next_byte(inp); if (b == 0) return NULL; - if (b == 1) return ctx->release[ctx->num_release++] = read_string(inp); + if (b == 1) return ctx->release[ctx->num_release++] = read_string(inp, NULL); if (b >= num_builtins + 1) { end(inp); return NULL; @@ -349,11 +388,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 +408,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,11 +438,11 @@ 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; - grpc_passthru_endpoint_create(&client, &server, g_resource_quota); + grpc_passthru_endpoint_create(&client, &server, g_resource_quota, NULL); *fc->ep = client; grpc_transport *transport = @@ -410,7 +450,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 +461,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 +470,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, @@ -506,8 +547,7 @@ typedef struct call_state { grpc_status_code status; grpc_metadata_array recv_initial_metadata; grpc_metadata_array recv_trailing_metadata; - char *recv_status_details; - size_t recv_status_details_capacity; + grpc_slice recv_status_details; int cancelled; int pending_ops; grpc_call_details call_details; @@ -521,6 +561,11 @@ typedef struct call_state { size_t cap_to_free; void **to_free; + // array of slices to unref + size_t num_slices_to_unref; + size_t cap_slices_to_unref; + grpc_slice **slices_to_unref; + struct call_state *next; struct call_state *prev; } call_state; @@ -556,13 +601,18 @@ static call_state *maybe_delete_call_state(call_state *call) { call->next->prev = call->prev; grpc_metadata_array_destroy(&call->recv_initial_metadata); grpc_metadata_array_destroy(&call->recv_trailing_metadata); - gpr_free(call->recv_status_details); + grpc_slice_unref(call->recv_status_details); grpc_call_details_destroy(&call->call_details); + for (size_t i = 0; i < call->num_slices_to_unref; i++) { + grpc_slice_unref(*call->slices_to_unref[i]); + gpr_free(call->slices_to_unref[i]); + } for (size_t i = 0; i < call->num_to_free; i++) { gpr_free(call->to_free[i]); } gpr_free(call->to_free); + gpr_free(call->slices_to_unref); gpr_free(call); @@ -578,6 +628,19 @@ static void add_to_free(call_state *call, void *p) { call->to_free[call->num_to_free++] = p; } +static grpc_slice *add_slice_to_unref(call_state *call, grpc_slice s) { + if (call->num_slices_to_unref == call->cap_slices_to_unref) { + call->cap_slices_to_unref = GPR_MAX(8, 2 * call->cap_slices_to_unref); + call->slices_to_unref = + gpr_realloc(call->slices_to_unref, + sizeof(*call->slices_to_unref) * call->cap_slices_to_unref); + } + call->slices_to_unref[call->num_slices_to_unref] = + gpr_malloc(sizeof(grpc_slice)); + *call->slices_to_unref[call->num_slices_to_unref++] = s; + return call->slices_to_unref[call->num_slices_to_unref - 1]; +} + static void read_metadata(input_stream *inp, size_t *count, grpc_metadata **metadata, call_state *cs) { *count = next_byte(inp); @@ -585,12 +648,11 @@ static void read_metadata(input_stream *inp, size_t *count, *metadata = gpr_malloc(*count * sizeof(**metadata)); memset(*metadata, 0, *count * sizeof(**metadata)); for (size_t i = 0; i < *count; i++) { - (*metadata)[i].key = read_string(inp); - read_buffer(inp, (char **)&(*metadata)[i].value, - &(*metadata)[i].value_length); + (*metadata)[i].key = read_string_like_slice(inp); + (*metadata)[i].value = read_buffer_like_slice(inp); (*metadata)[i].flags = read_uint32(inp); - add_to_free(cs, (void *)(*metadata)[i].key); - add_to_free(cs, (void *)(*metadata)[i].value); + add_slice_to_unref(cs, (*metadata)[i].key); + add_slice_to_unref(cs, (*metadata)[i].value); } } else { *metadata = gpr_malloc(1); @@ -654,7 +716,7 @@ static validator *make_finished_batch_validator(call_state *cs, } int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - grpc_test_only_set_metadata_hash_seed(0); + grpc_test_only_set_slice_hash_seed(0); if (squelch) gpr_set_log_function(dont_log); input_stream inp = {data, data + size}; grpc_resolve_address = my_resolve_address; @@ -740,13 +802,17 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { // create an insecure channel case 2: { if (g_channel == NULL) { - char *target = read_string(&inp); + char *target = read_string(&inp, NULL); char *target_uri; gpr_asprintf(&target_uri, "dns:%s", target); 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 +836,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; @@ -861,8 +931,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { parent_call = g_active_call->call; } uint32_t propagation_mask = read_uint32(&inp); - char *method = read_string(&inp); - char *host = read_string(&inp); + grpc_slice method = read_string_like_slice(&inp); + grpc_slice host = read_string_like_slice(&inp); gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_micros(read_uint32(&inp), GPR_TIMESPAN)); @@ -871,12 +941,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { call_state *cs = new_call(g_active_call, CLIENT); cs->call = grpc_channel_create_call(g_channel, parent_call, propagation_mask, - cq, method, host, deadline, NULL); + cq, method, &host, deadline, NULL); } else { end(&inp); } - gpr_free(method); - gpr_free(host); + grpc_slice_unref(method); + grpc_slice_unref(host); break; } // switch the 'current' call @@ -923,8 +993,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { ok = false; } else { has_ops |= 1 << GRPC_OP_SEND_MESSAGE; - g_active_call->send_message = op->data.send_message = - read_message(&inp); + g_active_call->send_message = + op->data.send_message.send_message = read_message(&inp); } break; case GRPC_OP_SEND_CLOSE_FROM_CLIENT: @@ -941,18 +1011,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { g_active_call); op->data.send_status_from_server.status = next_byte(&inp); op->data.send_status_from_server.status_details = - read_string(&inp); + add_slice_to_unref(g_active_call, + read_buffer_like_slice(&inp)); break; case GRPC_OP_RECV_INITIAL_METADATA: op->op = GRPC_OP_RECV_INITIAL_METADATA; has_ops |= 1 << GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = + op->data.recv_initial_metadata.recv_initial_metadata = &g_active_call->recv_initial_metadata; break; case GRPC_OP_RECV_MESSAGE: op->op = GRPC_OP_RECV_MESSAGE; has_ops |= 1 << GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &g_active_call->recv_message; + op->data.recv_message.recv_message = &g_active_call->recv_message; break; case GRPC_OP_RECV_STATUS_ON_CLIENT: op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; @@ -961,8 +1032,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { &g_active_call->recv_trailing_metadata; op->data.recv_status_on_client.status_details = &g_active_call->recv_status_details; - op->data.recv_status_on_client.status_details_capacity = - &g_active_call->recv_status_details_capacity; break; case GRPC_OP_RECV_CLOSE_ON_SERVER: op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -990,22 +1059,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_byte_buffer_destroy(g_active_call->send_message); g_active_call->send_message = NULL; } - for (i = 0; i < num_ops; i++) { - op = &ops[i]; - switch (op->op) { - case GRPC_OP_SEND_STATUS_FROM_SERVER: - gpr_free((void *)op->data.send_status_from_server.status_details); - break; - case GRPC_OP_SEND_MESSAGE: - case GRPC_OP_SEND_INITIAL_METADATA: - case GRPC_OP_SEND_CLOSE_FROM_CLIENT: - case GRPC_OP_RECV_INITIAL_METADATA: - case GRPC_OP_RECV_MESSAGE: - case GRPC_OP_RECV_STATUS_ON_CLIENT: - case GRPC_OP_RECV_CLOSE_ON_SERVER: - break; - } - } gpr_free(ops); break; @@ -1050,14 +1103,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { } // enable a tracer case 17: { - char *tracer = read_string(&inp); + char *tracer = read_string(&inp, NULL); grpc_tracer_set_enabled(tracer, 1); gpr_free(tracer); break; } // disable a tracer case 18: { - char *tracer = read_string(&inp); + char *tracer = read_string(&inp, NULL); grpc_tracer_set_enabled(tracer, 0); gpr_free(tracer); break; @@ -1099,14 +1152,18 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { // create a secure channel case 22: { if (g_channel == NULL) { - char *target = read_string(&inp); + char *target = read_string(&inp, NULL); char *target_uri; gpr_asprintf(&target_uri, "dns:%s", target); grpc_channel_args *args = read_args(&inp); 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/008d276f01f9371a5956cccf2eeeadb790728a84 b/test/core/end2end/fuzzers/api_fuzzer_corpus/008d276f01f9371a5956cccf2eeeadb790728a84 Binary files differnew file mode 100644 index 0000000000..88f358cf9a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/008d276f01f9371a5956cccf2eeeadb790728a84 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/00ba96baafa4595f2d41c2fcf0a27f4e9be5c44d b/test/core/end2end/fuzzers/api_fuzzer_corpus/00ba96baafa4595f2d41c2fcf0a27f4e9be5c44d Binary files differnew file mode 100644 index 0000000000..6945952ac5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/00ba96baafa4595f2d41c2fcf0a27f4e9be5c44d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0163bae995fe67a902eabf9f2644726d4767184c b/test/core/end2end/fuzzers/api_fuzzer_corpus/0163bae995fe67a902eabf9f2644726d4767184c Binary files differnew file mode 100644 index 0000000000..b0583e0b7d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0163bae995fe67a902eabf9f2644726d4767184c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0242a9f4d4fafc96ee9ed762b610e3c68d6efdec b/test/core/end2end/fuzzers/api_fuzzer_corpus/0242a9f4d4fafc96ee9ed762b610e3c68d6efdec Binary files differnew file mode 100644 index 0000000000..392ad08c09 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0242a9f4d4fafc96ee9ed762b610e3c68d6efdec diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/039c25bc070936901fc95f63ce9cc3058158fb6d b/test/core/end2end/fuzzers/api_fuzzer_corpus/039c25bc070936901fc95f63ce9cc3058158fb6d Binary files differnew file mode 100644 index 0000000000..fd96a32975 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/039c25bc070936901fc95f63ce9cc3058158fb6d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/03eb66a763e065772bbb09e9a55baf081814ff25 b/test/core/end2end/fuzzers/api_fuzzer_corpus/03eb66a763e065772bbb09e9a55baf081814ff25 Binary files differnew file mode 100644 index 0000000000..c54a6b4028 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/03eb66a763e065772bbb09e9a55baf081814ff25 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/053b47093c2145d00b8d53ea58b80afcc876109b b/test/core/end2end/fuzzers/api_fuzzer_corpus/053b47093c2145d00b8d53ea58b80afcc876109b Binary files differnew file mode 100644 index 0000000000..e08913c002 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/053b47093c2145d00b8d53ea58b80afcc876109b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/06a298ad14533924c9fcb2df0d462c44a206f64b b/test/core/end2end/fuzzers/api_fuzzer_corpus/06a298ad14533924c9fcb2df0d462c44a206f64b Binary files differnew file mode 100644 index 0000000000..cf961eb403 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/06a298ad14533924c9fcb2df0d462c44a206f64b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/06d20c59bcbeb0deff39619455a713691191bccd b/test/core/end2end/fuzzers/api_fuzzer_corpus/06d20c59bcbeb0deff39619455a713691191bccd Binary files differnew file mode 100644 index 0000000000..87426c9da6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/06d20c59bcbeb0deff39619455a713691191bccd diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/070aca38b5cd06626dfc98126ef1225595800427 b/test/core/end2end/fuzzers/api_fuzzer_corpus/070aca38b5cd06626dfc98126ef1225595800427 Binary files differnew file mode 100644 index 0000000000..0be853bf97 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/070aca38b5cd06626dfc98126ef1225595800427 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/07867ad24a27ff8675dc36a1d8da833f9ee9434b b/test/core/end2end/fuzzers/api_fuzzer_corpus/07867ad24a27ff8675dc36a1d8da833f9ee9434b Binary files differnew file mode 100644 index 0000000000..06986fe7ae --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/07867ad24a27ff8675dc36a1d8da833f9ee9434b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/08398518b9b4e98d4625dfb063ab0b6d9399a239 b/test/core/end2end/fuzzers/api_fuzzer_corpus/08398518b9b4e98d4625dfb063ab0b6d9399a239 Binary files differnew file mode 100644 index 0000000000..fc5719382d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/08398518b9b4e98d4625dfb063ab0b6d9399a239 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/08455b3ef9d516deb8155d8db7d51c43ce0ff07a b/test/core/end2end/fuzzers/api_fuzzer_corpus/08455b3ef9d516deb8155d8db7d51c43ce0ff07a Binary files differnew file mode 100644 index 0000000000..4b698ba9ee --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/08455b3ef9d516deb8155d8db7d51c43ce0ff07a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0914e4f6ee18c9d15b8df1858a7745b86d875970 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0914e4f6ee18c9d15b8df1858a7745b86d875970 Binary files differnew file mode 100644 index 0000000000..489deadb23 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0914e4f6ee18c9d15b8df1858a7745b86d875970 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/091f02cc858a89253748b7d1051b8728d0e34015 b/test/core/end2end/fuzzers/api_fuzzer_corpus/091f02cc858a89253748b7d1051b8728d0e34015 Binary files differnew file mode 100644 index 0000000000..4435741946 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/091f02cc858a89253748b7d1051b8728d0e34015 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/095e3fa32a271ef9326d4dcd59fbd003977fdcfa b/test/core/end2end/fuzzers/api_fuzzer_corpus/095e3fa32a271ef9326d4dcd59fbd003977fdcfa Binary files differnew file mode 100644 index 0000000000..d9b1ae3fce --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/095e3fa32a271ef9326d4dcd59fbd003977fdcfa diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/096f9413b1bf712e092cf8bd70754014d6242f12 b/test/core/end2end/fuzzers/api_fuzzer_corpus/096f9413b1bf712e092cf8bd70754014d6242f12 Binary files differnew file mode 100644 index 0000000000..c04f03c9ea --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/096f9413b1bf712e092cf8bd70754014d6242f12 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/097f758de0f31691fac6637bf8ac5ac946d5b079 b/test/core/end2end/fuzzers/api_fuzzer_corpus/097f758de0f31691fac6637bf8ac5ac946d5b079 Binary files differnew file mode 100644 index 0000000000..17554b479a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/097f758de0f31691fac6637bf8ac5ac946d5b079 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/099cc7faaaa2620df22c9bcd6e6d49730e4788b3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/099cc7faaaa2620df22c9bcd6e6d49730e4788b3 Binary files differnew file mode 100644 index 0000000000..f16a04a177 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/099cc7faaaa2620df22c9bcd6e6d49730e4788b3 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0a3f1f614446ded112775bbbc5c61513ad78e12e b/test/core/end2end/fuzzers/api_fuzzer_corpus/0a3f1f614446ded112775bbbc5c61513ad78e12e Binary files differnew file mode 100644 index 0000000000..c8d28f8d07 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0a3f1f614446ded112775bbbc5c61513ad78e12e diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0a4b84c2a50ba66f06c99e945912972cdcfc96be b/test/core/end2end/fuzzers/api_fuzzer_corpus/0a4b84c2a50ba66f06c99e945912972cdcfc96be Binary files differnew file mode 100644 index 0000000000..d0f43e9d91 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0a4b84c2a50ba66f06c99e945912972cdcfc96be diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0a85889229b729883f4c0420d1a13d9f0a2ca7c2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0a85889229b729883f4c0420d1a13d9f0a2ca7c2 Binary files differnew file mode 100644 index 0000000000..dd537e387d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0a85889229b729883f4c0420d1a13d9f0a2ca7c2 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0ab436006cb2ecd8ecb2400fed982886e4589360 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0ab436006cb2ecd8ecb2400fed982886e4589360 Binary files differnew file mode 100644 index 0000000000..f6e83c8a5b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0ab436006cb2ecd8ecb2400fed982886e4589360 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0c26c7da58087406c491efb8f8f721eb934e6a5a b/test/core/end2end/fuzzers/api_fuzzer_corpus/0c26c7da58087406c491efb8f8f721eb934e6a5a Binary files differnew file mode 100644 index 0000000000..e6a2e760bb --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0c26c7da58087406c491efb8f8f721eb934e6a5a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0cd9696699bd190463ecef91968624601b64cd8b b/test/core/end2end/fuzzers/api_fuzzer_corpus/0cd9696699bd190463ecef91968624601b64cd8b Binary files differnew file mode 100644 index 0000000000..92125efaa5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0cd9696699bd190463ecef91968624601b64cd8b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0d19e60f4eb1b729e272dd5dec68e8b67f03a5f4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0d19e60f4eb1b729e272dd5dec68e8b67f03a5f4 Binary files differnew file mode 100644 index 0000000000..2889e7040e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0d19e60f4eb1b729e272dd5dec68e8b67f03a5f4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0d25b57b2ac671377f8042015896619c09a2f9b5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0d25b57b2ac671377f8042015896619c09a2f9b5 Binary files differnew file mode 100644 index 0000000000..5312ff2ddd --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0d25b57b2ac671377f8042015896619c09a2f9b5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0dfc84a6703bdbe9a6acb72e178353d5d69f5814 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0dfc84a6703bdbe9a6acb72e178353d5d69f5814 Binary files differnew file mode 100644 index 0000000000..119f151676 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0dfc84a6703bdbe9a6acb72e178353d5d69f5814 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0e7a05178db60007ff4a8dea0e22b60825976c51 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0e7a05178db60007ff4a8dea0e22b60825976c51 Binary files differnew file mode 100644 index 0000000000..ac4d9dc1ed --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0e7a05178db60007ff4a8dea0e22b60825976c51 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0ec11a92c1830b4c2f56a0979dd9e3c7162bd624 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0ec11a92c1830b4c2f56a0979dd9e3c7162bd624 Binary files differnew file mode 100644 index 0000000000..cdd1a44c89 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0ec11a92c1830b4c2f56a0979dd9e3c7162bd624 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0f01df12331467c4eed400465254eda05eaeb110 b/test/core/end2end/fuzzers/api_fuzzer_corpus/0f01df12331467c4eed400465254eda05eaeb110 Binary files differnew file mode 100644 index 0000000000..09bf4db585 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0f01df12331467c4eed400465254eda05eaeb110 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/0feaff8d6ad28109f35d6c6080504456b242c8ce b/test/core/end2end/fuzzers/api_fuzzer_corpus/0feaff8d6ad28109f35d6c6080504456b242c8ce Binary files differnew file mode 100644 index 0000000000..40ae0b5137 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/0feaff8d6ad28109f35d6c6080504456b242c8ce diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/10b47823e11c988222f5f778146f9cf922b286bf b/test/core/end2end/fuzzers/api_fuzzer_corpus/10b47823e11c988222f5f778146f9cf922b286bf Binary files differnew file mode 100644 index 0000000000..d0412a2385 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/10b47823e11c988222f5f778146f9cf922b286bf diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/122b6fc72956541812dd653b726b073b77ca33be b/test/core/end2end/fuzzers/api_fuzzer_corpus/122b6fc72956541812dd653b726b073b77ca33be Binary files differnew file mode 100644 index 0000000000..e6eb181351 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/122b6fc72956541812dd653b726b073b77ca33be diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/128a7ef7f9b87c4f299d3cafe2dfdb9b161756bd b/test/core/end2end/fuzzers/api_fuzzer_corpus/128a7ef7f9b87c4f299d3cafe2dfdb9b161756bd Binary files differnew file mode 100644 index 0000000000..9be7c77a7b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/128a7ef7f9b87c4f299d3cafe2dfdb9b161756bd diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/14064ac4844c709b247a4345a92d8be9766785c4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/14064ac4844c709b247a4345a92d8be9766785c4 Binary files differnew file mode 100644 index 0000000000..fa731d4a05 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/14064ac4844c709b247a4345a92d8be9766785c4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/14ee9fbfe5284650e3a3de83ecc3e09abdc48c16 b/test/core/end2end/fuzzers/api_fuzzer_corpus/14ee9fbfe5284650e3a3de83ecc3e09abdc48c16 Binary files differnew file mode 100644 index 0000000000..54d8626e79 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/14ee9fbfe5284650e3a3de83ecc3e09abdc48c16 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/163cf93cebfb32d617830aa4e69e8b5f59bd3a08 b/test/core/end2end/fuzzers/api_fuzzer_corpus/163cf93cebfb32d617830aa4e69e8b5f59bd3a08 Binary files differnew file mode 100644 index 0000000000..0a02d52bc2 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/163cf93cebfb32d617830aa4e69e8b5f59bd3a08 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/174ea33060bccea880dfdcfa12c5349e8eb4cb2a b/test/core/end2end/fuzzers/api_fuzzer_corpus/174ea33060bccea880dfdcfa12c5349e8eb4cb2a Binary files differnew file mode 100644 index 0000000000..da32e95013 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/174ea33060bccea880dfdcfa12c5349e8eb4cb2a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/17582452219fc4a27058a789f416a56631461296 b/test/core/end2end/fuzzers/api_fuzzer_corpus/17582452219fc4a27058a789f416a56631461296 Binary files differnew file mode 100644 index 0000000000..80a59659e1 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/17582452219fc4a27058a789f416a56631461296 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1776f4c32c11490c65b81d0b7ae2ece4a3d1e9a7 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1776f4c32c11490c65b81d0b7ae2ece4a3d1e9a7 Binary files differnew file mode 100644 index 0000000000..64ceda1e16 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1776f4c32c11490c65b81d0b7ae2ece4a3d1e9a7 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/17a1354d2bfe982e9db1bac550fe01dd105f81c3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/17a1354d2bfe982e9db1bac550fe01dd105f81c3 Binary files differnew file mode 100644 index 0000000000..6918b8a498 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/17a1354d2bfe982e9db1bac550fe01dd105f81c3 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/17bc3a2ae619ef05ad35b147f4916c0453ebacf1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/17bc3a2ae619ef05ad35b147f4916c0453ebacf1 Binary files differnew file mode 100644 index 0000000000..c7c2613e75 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/17bc3a2ae619ef05ad35b147f4916c0453ebacf1 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/17e562d437fd283e58a5621c33b13191333b279f b/test/core/end2end/fuzzers/api_fuzzer_corpus/17e562d437fd283e58a5621c33b13191333b279f Binary files differnew file mode 100644 index 0000000000..28b70b3cff --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/17e562d437fd283e58a5621c33b13191333b279f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1847f224b543fd0592e9cf365b8eddb61c140d82 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1847f224b543fd0592e9cf365b8eddb61c140d82 Binary files differnew file mode 100644 index 0000000000..f8c75b573c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1847f224b543fd0592e9cf365b8eddb61c140d82 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1901234bd7c9cb6ee19ff8b17179c481bdc7c5f2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1901234bd7c9cb6ee19ff8b17179c481bdc7c5f2 Binary files differnew file mode 100644 index 0000000000..ef09a0eaf5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1901234bd7c9cb6ee19ff8b17179c481bdc7c5f2 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/19fdd6cdeee7a5cbc991d0e3242c23d5aaff2fbf b/test/core/end2end/fuzzers/api_fuzzer_corpus/19fdd6cdeee7a5cbc991d0e3242c23d5aaff2fbf Binary files differnew file mode 100644 index 0000000000..38d23faffd --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/19fdd6cdeee7a5cbc991d0e3242c23d5aaff2fbf diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1b331dfc1d9d535063f0cc6f7a709499a5f8cb59 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1b331dfc1d9d535063f0cc6f7a709499a5f8cb59 Binary files differnew file mode 100644 index 0000000000..b67ad3729d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1b331dfc1d9d535063f0cc6f7a709499a5f8cb59 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1b50ba2e44a359f37205ae476682495cff96838d b/test/core/end2end/fuzzers/api_fuzzer_corpus/1b50ba2e44a359f37205ae476682495cff96838d Binary files differnew file mode 100644 index 0000000000..bc8e2331a5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1b50ba2e44a359f37205ae476682495cff96838d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1c0dc85faed94bb89bc90f87799d7383cf9907cf b/test/core/end2end/fuzzers/api_fuzzer_corpus/1c0dc85faed94bb89bc90f87799d7383cf9907cf Binary files differnew file mode 100644 index 0000000000..c83ac858d6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1c0dc85faed94bb89bc90f87799d7383cf9907cf diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1c968074e9dcd8e9922e6c01ecfedcaf7b2fe5a3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1c968074e9dcd8e9922e6c01ecfedcaf7b2fe5a3 Binary files differnew file mode 100644 index 0000000000..2591059a44 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1c968074e9dcd8e9922e6c01ecfedcaf7b2fe5a3 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1ca16103f5175b0607b579e0c3734b59843e27b0 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1ca16103f5175b0607b579e0c3734b59843e27b0 Binary files differnew file mode 100644 index 0000000000..006d8e8437 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1ca16103f5175b0607b579e0c3734b59843e27b0 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1cae148c387cd20a1742d902543c2c8396589479 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1cae148c387cd20a1742d902543c2c8396589479 Binary files differnew file mode 100644 index 0000000000..3869d83f4f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1cae148c387cd20a1742d902543c2c8396589479 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1cfd4875b6708b439f1db655abfdd57c1141348a b/test/core/end2end/fuzzers/api_fuzzer_corpus/1cfd4875b6708b439f1db655abfdd57c1141348a Binary files differnew file mode 100644 index 0000000000..37a9bcf9d3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1cfd4875b6708b439f1db655abfdd57c1141348a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1d10780f4cb83cb9f6762548ae133d2115c4354f b/test/core/end2end/fuzzers/api_fuzzer_corpus/1d10780f4cb83cb9f6762548ae133d2115c4354f Binary files differnew file mode 100644 index 0000000000..a4c1921b5e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1d10780f4cb83cb9f6762548ae133d2115c4354f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1dba0d6c34b03b19e648e2fc9cb3aa7a13e713a2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1dba0d6c34b03b19e648e2fc9cb3aa7a13e713a2 Binary files differnew file mode 100644 index 0000000000..ffa1c18aa7 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1dba0d6c34b03b19e648e2fc9cb3aa7a13e713a2 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1de191d81c4c7bf0e026bff0a040165c084fd630 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1de191d81c4c7bf0e026bff0a040165c084fd630 Binary files differnew file mode 100644 index 0000000000..52fdbc5c47 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1de191d81c4c7bf0e026bff0a040165c084fd630 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1e1f1e0230004479b502603a1b60552192559679 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1e1f1e0230004479b502603a1b60552192559679 Binary files differnew file mode 100644 index 0000000000..18b642caa2 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1e1f1e0230004479b502603a1b60552192559679 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/1f3f61bbe6ea0c7e9b447f134742b3e7909b9198 b/test/core/end2end/fuzzers/api_fuzzer_corpus/1f3f61bbe6ea0c7e9b447f134742b3e7909b9198 Binary files differnew file mode 100644 index 0000000000..27491bad75 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/1f3f61bbe6ea0c7e9b447f134742b3e7909b9198 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/20ff1f8d5d34cb01d58aa334dc46a6644e6e1d12 b/test/core/end2end/fuzzers/api_fuzzer_corpus/20ff1f8d5d34cb01d58aa334dc46a6644e6e1d12 Binary files differnew file mode 100644 index 0000000000..fc747d4a72 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/20ff1f8d5d34cb01d58aa334dc46a6644e6e1d12 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/224b2255a1bd250102481abc3e823090650e231e b/test/core/end2end/fuzzers/api_fuzzer_corpus/224b2255a1bd250102481abc3e823090650e231e Binary files differnew file mode 100644 index 0000000000..6dee8f3e8d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/224b2255a1bd250102481abc3e823090650e231e diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/22c7bfb3460529c77255e9cb82ef8f7d8381f8f3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/22c7bfb3460529c77255e9cb82ef8f7d8381f8f3 Binary files differnew file mode 100644 index 0000000000..b5f6a8572c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/22c7bfb3460529c77255e9cb82ef8f7d8381f8f3 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/23746fe5e477430aec8b12e9d7de0f86f6a6e191 b/test/core/end2end/fuzzers/api_fuzzer_corpus/23746fe5e477430aec8b12e9d7de0f86f6a6e191 Binary files differnew file mode 100644 index 0000000000..735003e24e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/23746fe5e477430aec8b12e9d7de0f86f6a6e191 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/2378c3f1206f20711468391ce739116ffe58374b b/test/core/end2end/fuzzers/api_fuzzer_corpus/2378c3f1206f20711468391ce739116ffe58374b Binary files differnew file mode 100644 index 0000000000..ca3ce31cbe --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/2378c3f1206f20711468391ce739116ffe58374b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/247a7d3e0061dd0f32c3f6b2fc43a08e2cc8cf72 b/test/core/end2end/fuzzers/api_fuzzer_corpus/247a7d3e0061dd0f32c3f6b2fc43a08e2cc8cf72 Binary files differnew file mode 100644 index 0000000000..667761ed63 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/247a7d3e0061dd0f32c3f6b2fc43a08e2cc8cf72 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/25c05b84c4b4f1a93f0f72d368c3c3644b564881 b/test/core/end2end/fuzzers/api_fuzzer_corpus/25c05b84c4b4f1a93f0f72d368c3c3644b564881 Binary files differnew file mode 100644 index 0000000000..0cde771ff9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/25c05b84c4b4f1a93f0f72d368c3c3644b564881 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/26794761df5dc7f093d2395b81a32af5e6b54392 b/test/core/end2end/fuzzers/api_fuzzer_corpus/26794761df5dc7f093d2395b81a32af5e6b54392 Binary files differnew file mode 100644 index 0000000000..1eaa5be9ee --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/26794761df5dc7f093d2395b81a32af5e6b54392 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/268d8763bb7846f4c9ebb4fbea476a5bc8fcc389 b/test/core/end2end/fuzzers/api_fuzzer_corpus/268d8763bb7846f4c9ebb4fbea476a5bc8fcc389 Binary files differnew file mode 100644 index 0000000000..abf4177944 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/268d8763bb7846f4c9ebb4fbea476a5bc8fcc389 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/289c2b6211858aa4a46b5b489bc4c9dd47828d21 b/test/core/end2end/fuzzers/api_fuzzer_corpus/289c2b6211858aa4a46b5b489bc4c9dd47828d21 Binary files differnew file mode 100644 index 0000000000..3e05110d4d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/289c2b6211858aa4a46b5b489bc4c9dd47828d21 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/28cbfc7c1b760d216cc592a273088b31833ee707 b/test/core/end2end/fuzzers/api_fuzzer_corpus/28cbfc7c1b760d216cc592a273088b31833ee707 Binary files differnew file mode 100644 index 0000000000..17031bab65 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/28cbfc7c1b760d216cc592a273088b31833ee707 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/28fc3136371b5bcac84045ab6cc93e77298760e2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/28fc3136371b5bcac84045ab6cc93e77298760e2 Binary files differnew file mode 100644 index 0000000000..c31dfa7807 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/28fc3136371b5bcac84045ab6cc93e77298760e2 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/2a4fc709f61977f0f6c75760af2b33007ecd5941 b/test/core/end2end/fuzzers/api_fuzzer_corpus/2a4fc709f61977f0f6c75760af2b33007ecd5941 Binary files differnew file mode 100644 index 0000000000..8c978ebb5e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/2a4fc709f61977f0f6c75760af2b33007ecd5941 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/2bb76eff88c5af98c4b8828047837fe97b50cfeb b/test/core/end2end/fuzzers/api_fuzzer_corpus/2bb76eff88c5af98c4b8828047837fe97b50cfeb Binary files differnew file mode 100644 index 0000000000..0e8dcdbec1 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/2bb76eff88c5af98c4b8828047837fe97b50cfeb diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/2ce3268455c461a30eb30f4792087df411548c13 b/test/core/end2end/fuzzers/api_fuzzer_corpus/2ce3268455c461a30eb30f4792087df411548c13 Binary files differnew file mode 100644 index 0000000000..366221f79b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/2ce3268455c461a30eb30f4792087df411548c13 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/2d03c424dd0677a68f28bb94536f49844d79d00a b/test/core/end2end/fuzzers/api_fuzzer_corpus/2d03c424dd0677a68f28bb94536f49844d79d00a Binary files differnew file mode 100644 index 0000000000..a4fb251542 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/2d03c424dd0677a68f28bb94536f49844d79d00a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/2d743ec0a0826177cfa7ffb335c0034f482e70e5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/2d743ec0a0826177cfa7ffb335c0034f482e70e5 Binary files differnew file mode 100644 index 0000000000..5449b346c0 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/2d743ec0a0826177cfa7ffb335c0034f482e70e5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/2dbe958ef23ade1b8bbb9669e590fa99454970b4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/2dbe958ef23ade1b8bbb9669e590fa99454970b4 Binary files differnew file mode 100644 index 0000000000..e03e3b8346 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/2dbe958ef23ade1b8bbb9669e590fa99454970b4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/2df7ea9c0c488fc8f79d33b6bce5667a2f051a65 b/test/core/end2end/fuzzers/api_fuzzer_corpus/2df7ea9c0c488fc8f79d33b6bce5667a2f051a65 Binary files differnew file mode 100644 index 0000000000..61278e101f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/2df7ea9c0c488fc8f79d33b6bce5667a2f051a65 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/2feac28b1f508d6086f4cb0972800a77e1d01201 b/test/core/end2end/fuzzers/api_fuzzer_corpus/2feac28b1f508d6086f4cb0972800a77e1d01201 Binary files differnew file mode 100644 index 0000000000..da5b4523d4 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/2feac28b1f508d6086f4cb0972800a77e1d01201 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/30738789e20323323196dd3e6435fa278e73279e b/test/core/end2end/fuzzers/api_fuzzer_corpus/30738789e20323323196dd3e6435fa278e73279e Binary files differnew file mode 100644 index 0000000000..a85ff98407 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/30738789e20323323196dd3e6435fa278e73279e diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/307aaef3b3982cf8d4780a1f896d5392037c5db2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/307aaef3b3982cf8d4780a1f896d5392037c5db2 Binary files differnew file mode 100644 index 0000000000..f38bf0e0cb --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/307aaef3b3982cf8d4780a1f896d5392037c5db2 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3082fa77cc2942ae425a6577d1f9c0dddd2949be b/test/core/end2end/fuzzers/api_fuzzer_corpus/3082fa77cc2942ae425a6577d1f9c0dddd2949be Binary files differnew file mode 100644 index 0000000000..380f2805f0 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/3082fa77cc2942ae425a6577d1f9c0dddd2949be diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/308fbf16b3f3747423b2ff69ef5930b01ca9b728 b/test/core/end2end/fuzzers/api_fuzzer_corpus/308fbf16b3f3747423b2ff69ef5930b01ca9b728 Binary files differnew file mode 100644 index 0000000000..3cd23c5d8e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/308fbf16b3f3747423b2ff69ef5930b01ca9b728 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/30d2e4b3cac45cbcfe76459c90c49e085914c154 b/test/core/end2end/fuzzers/api_fuzzer_corpus/30d2e4b3cac45cbcfe76459c90c49e085914c154 Binary files differnew file mode 100644 index 0000000000..1fbfcfe3b2 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/30d2e4b3cac45cbcfe76459c90c49e085914c154 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/315d27e12f2214a56fb9901dacff14852ff2ac0f b/test/core/end2end/fuzzers/api_fuzzer_corpus/315d27e12f2214a56fb9901dacff14852ff2ac0f Binary files differnew file mode 100644 index 0000000000..379a1576a9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/315d27e12f2214a56fb9901dacff14852ff2ac0f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/31d8226b1d767fc895e87d7feede0e2d7c6c0b66 b/test/core/end2end/fuzzers/api_fuzzer_corpus/31d8226b1d767fc895e87d7feede0e2d7c6c0b66 Binary files differnew file mode 100644 index 0000000000..7ace4ffc84 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/31d8226b1d767fc895e87d7feede0e2d7c6c0b66 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/33252c0d4edb12370235c0179abd87a5efb59d29 b/test/core/end2end/fuzzers/api_fuzzer_corpus/33252c0d4edb12370235c0179abd87a5efb59d29 Binary files differnew file mode 100644 index 0000000000..378afc002f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/33252c0d4edb12370235c0179abd87a5efb59d29 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/33d926a04c1868c3393b3129968ffd32049a1c64 b/test/core/end2end/fuzzers/api_fuzzer_corpus/33d926a04c1868c3393b3129968ffd32049a1c64 Binary files differnew file mode 100644 index 0000000000..dc8950f16f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/33d926a04c1868c3393b3129968ffd32049a1c64 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/33e01fe9738c887b159ca5add342b22c13e526cf b/test/core/end2end/fuzzers/api_fuzzer_corpus/33e01fe9738c887b159ca5add342b22c13e526cf Binary files differnew file mode 100644 index 0000000000..9b3060c517 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/33e01fe9738c887b159ca5add342b22c13e526cf diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/33f0e1b78dd158df720604cbb4c9a0c90eece435 b/test/core/end2end/fuzzers/api_fuzzer_corpus/33f0e1b78dd158df720604cbb4c9a0c90eece435 Binary files differnew file mode 100644 index 0000000000..df5e44292e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/33f0e1b78dd158df720604cbb4c9a0c90eece435 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/34e2445f42fd82c5ce229782a93764def3aae0e7 b/test/core/end2end/fuzzers/api_fuzzer_corpus/34e2445f42fd82c5ce229782a93764def3aae0e7 Binary files differnew file mode 100644 index 0000000000..74452235d9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/34e2445f42fd82c5ce229782a93764def3aae0e7 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/352599b2850ac5a96ec656788c897c4b36114cc4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/352599b2850ac5a96ec656788c897c4b36114cc4 Binary files differnew file mode 100644 index 0000000000..4e28b817e4 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/352599b2850ac5a96ec656788c897c4b36114cc4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/35d6503b48b5acc5486a158696ae98a98f46e1a4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/35d6503b48b5acc5486a158696ae98a98f46e1a4 Binary files differnew file mode 100644 index 0000000000..348387f6fe --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/35d6503b48b5acc5486a158696ae98a98f46e1a4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/35ea066b0fc90521bd8401ef4c52cdc9897d35d4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/35ea066b0fc90521bd8401ef4c52cdc9897d35d4 Binary files differnew file mode 100644 index 0000000000..e56a34bb71 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/35ea066b0fc90521bd8401ef4c52cdc9897d35d4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/35f172b0168cd0b2da4509c3463c2502274e01a6 b/test/core/end2end/fuzzers/api_fuzzer_corpus/35f172b0168cd0b2da4509c3463c2502274e01a6 Binary files differnew file mode 100644 index 0000000000..f3798b48a0 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/35f172b0168cd0b2da4509c3463c2502274e01a6 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3698d88414f52b7c4759bfdadb53161b226faf8c b/test/core/end2end/fuzzers/api_fuzzer_corpus/3698d88414f52b7c4759bfdadb53161b226faf8c Binary files differnew file mode 100644 index 0000000000..945061292d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/3698d88414f52b7c4759bfdadb53161b226faf8c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/36dd4f4239b63b9cf379b354de0dc72e6356fba5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/36dd4f4239b63b9cf379b354de0dc72e6356fba5 Binary files differnew file mode 100644 index 0000000000..214d1b660d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/36dd4f4239b63b9cf379b354de0dc72e6356fba5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/38259d219a41c1bc60e3867dc60e3473f98cef64 b/test/core/end2end/fuzzers/api_fuzzer_corpus/38259d219a41c1bc60e3867dc60e3473f98cef64 Binary files differnew file mode 100644 index 0000000000..22707d973f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/38259d219a41c1bc60e3867dc60e3473f98cef64 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/390daee799863cdd0533f35b15b5c0a4f5d79a79 b/test/core/end2end/fuzzers/api_fuzzer_corpus/390daee799863cdd0533f35b15b5c0a4f5d79a79 Binary files differnew file mode 100644 index 0000000000..6feaf9e8d0 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/390daee799863cdd0533f35b15b5c0a4f5d79a79 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3a3346314bb9ddaf14877b653cfd506b6ad34fab b/test/core/end2end/fuzzers/api_fuzzer_corpus/3a3346314bb9ddaf14877b653cfd506b6ad34fab Binary files differnew file mode 100644 index 0000000000..1695b94414 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/3a3346314bb9ddaf14877b653cfd506b6ad34fab diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3c942f9491b1e8b5bb9761a4dbb1bc7165850dfc b/test/core/end2end/fuzzers/api_fuzzer_corpus/3c942f9491b1e8b5bb9761a4dbb1bc7165850dfc Binary files differnew file mode 100644 index 0000000000..a53d26dead --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/3c942f9491b1e8b5bb9761a4dbb1bc7165850dfc diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3c9a414ad8fcc53c3271bbc8375086d8d1fa450c b/test/core/end2end/fuzzers/api_fuzzer_corpus/3c9a414ad8fcc53c3271bbc8375086d8d1fa450c Binary files differnew file mode 100644 index 0000000000..e46e0ab65b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/3c9a414ad8fcc53c3271bbc8375086d8d1fa450c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3cac506501825fadf2e4adf7619d16f72cfd8832 b/test/core/end2end/fuzzers/api_fuzzer_corpus/3cac506501825fadf2e4adf7619d16f72cfd8832 Binary files differnew file mode 100644 index 0000000000..62447e4f08 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/3cac506501825fadf2e4adf7619d16f72cfd8832 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3cc56c99c6046f0d66c50c4062d90608064fd742 b/test/core/end2end/fuzzers/api_fuzzer_corpus/3cc56c99c6046f0d66c50c4062d90608064fd742 Binary files differnew file mode 100644 index 0000000000..4dbb2b9544 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/3cc56c99c6046f0d66c50c4062d90608064fd742 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3d929a8f8e77e038ddaecf9d149189cfeeec30fc b/test/core/end2end/fuzzers/api_fuzzer_corpus/3d929a8f8e77e038ddaecf9d149189cfeeec30fc Binary files differnew file mode 100644 index 0000000000..b6363011f3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/3d929a8f8e77e038ddaecf9d149189cfeeec30fc diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3de19989758b5b68b29af3dfc6c0e55d414dca32 b/test/core/end2end/fuzzers/api_fuzzer_corpus/3de19989758b5b68b29af3dfc6c0e55d414dca32 Binary files differnew file mode 100644 index 0000000000..e51ac9d8a9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/3de19989758b5b68b29af3dfc6c0e55d414dca32 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3e82319f1a44ea9224d65feb07ee0ef622709dac b/test/core/end2end/fuzzers/api_fuzzer_corpus/3e82319f1a44ea9224d65feb07ee0ef622709dac Binary files differnew file mode 100644 index 0000000000..26735fe923 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/3e82319f1a44ea9224d65feb07ee0ef622709dac diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/3f2429e3255ae36fecb57559b57d2b0cb88f5dd1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/3f2429e3255ae36fecb57559b57d2b0cb88f5dd1 Binary files differnew file mode 100644 index 0000000000..83419944d4 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/3f2429e3255ae36fecb57559b57d2b0cb88f5dd1 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/4004d9ccc668572796770fb3401376844e1574ae b/test/core/end2end/fuzzers/api_fuzzer_corpus/4004d9ccc668572796770fb3401376844e1574ae Binary files differnew file mode 100644 index 0000000000..81687230a1 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/4004d9ccc668572796770fb3401376844e1574ae diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/40640a91fda4e4e42d3063a28b9ffbba1b8c3701 b/test/core/end2end/fuzzers/api_fuzzer_corpus/40640a91fda4e4e42d3063a28b9ffbba1b8c3701 Binary files differnew file mode 100644 index 0000000000..f11821acc9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/40640a91fda4e4e42d3063a28b9ffbba1b8c3701 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/409d7e2c0173b5a00a475f79e2fbdbe596d8368a b/test/core/end2end/fuzzers/api_fuzzer_corpus/409d7e2c0173b5a00a475f79e2fbdbe596d8368a Binary files differnew file mode 100644 index 0000000000..75d8f1c0a6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/409d7e2c0173b5a00a475f79e2fbdbe596d8368a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/41bda7ff09175f821992adf4314a8ec3007ffe55 b/test/core/end2end/fuzzers/api_fuzzer_corpus/41bda7ff09175f821992adf4314a8ec3007ffe55 Binary files differnew file mode 100644 index 0000000000..a89e88e48f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/41bda7ff09175f821992adf4314a8ec3007ffe55 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/421feb3fe383541082a65a447a51b4af991ceb7e b/test/core/end2end/fuzzers/api_fuzzer_corpus/421feb3fe383541082a65a447a51b4af991ceb7e Binary files differnew file mode 100644 index 0000000000..45223cd69a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/421feb3fe383541082a65a447a51b4af991ceb7e diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/42231300ca5cf30d18f55b66020926882c64248c b/test/core/end2end/fuzzers/api_fuzzer_corpus/42231300ca5cf30d18f55b66020926882c64248c Binary files differnew file mode 100644 index 0000000000..0119532390 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/42231300ca5cf30d18f55b66020926882c64248c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/4239c3636053665277d07bafda37ee84c114b13a b/test/core/end2end/fuzzers/api_fuzzer_corpus/4239c3636053665277d07bafda37ee84c114b13a Binary files differnew file mode 100644 index 0000000000..04acde15fe --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/4239c3636053665277d07bafda37ee84c114b13a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/424b6a20be32318d920d83aa2a292a0aba013a1b b/test/core/end2end/fuzzers/api_fuzzer_corpus/424b6a20be32318d920d83aa2a292a0aba013a1b Binary files differnew file mode 100644 index 0000000000..00026e71b9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/424b6a20be32318d920d83aa2a292a0aba013a1b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/426b7f180ab26cf276a223246d4d6bd972ccf55a b/test/core/end2end/fuzzers/api_fuzzer_corpus/426b7f180ab26cf276a223246d4d6bd972ccf55a Binary files differnew file mode 100644 index 0000000000..3e0a69e059 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/426b7f180ab26cf276a223246d4d6bd972ccf55a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/428cce92c42645f4cc4060a8cb9cef3a803c0341 b/test/core/end2end/fuzzers/api_fuzzer_corpus/428cce92c42645f4cc4060a8cb9cef3a803c0341 Binary files differnew file mode 100644 index 0000000000..39faa0d693 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/428cce92c42645f4cc4060a8cb9cef3a803c0341 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/43cdc82b082bbdc4d7d23437a7f761f1ca32ca73 b/test/core/end2end/fuzzers/api_fuzzer_corpus/43cdc82b082bbdc4d7d23437a7f761f1ca32ca73 Binary files differnew file mode 100644 index 0000000000..c8250c8ccf --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/43cdc82b082bbdc4d7d23437a7f761f1ca32ca73 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/43f8e0abe3f647350ab1d8d368cca9af6ca47729 b/test/core/end2end/fuzzers/api_fuzzer_corpus/43f8e0abe3f647350ab1d8d368cca9af6ca47729 Binary files differnew file mode 100644 index 0000000000..344491e610 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/43f8e0abe3f647350ab1d8d368cca9af6ca47729 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/448fc1dc939aa7f398f1577e418630abecc0a1d7 b/test/core/end2end/fuzzers/api_fuzzer_corpus/448fc1dc939aa7f398f1577e418630abecc0a1d7 Binary files differnew file mode 100644 index 0000000000..d5f631429e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/448fc1dc939aa7f398f1577e418630abecc0a1d7 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/4523e89844538d8de502907f143c35624182f76c b/test/core/end2end/fuzzers/api_fuzzer_corpus/4523e89844538d8de502907f143c35624182f76c Binary files differnew file mode 100644 index 0000000000..9f89f26778 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/4523e89844538d8de502907f143c35624182f76c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/453861de5ab948236f13ebff66c8e82e4e789db6 b/test/core/end2end/fuzzers/api_fuzzer_corpus/453861de5ab948236f13ebff66c8e82e4e789db6 Binary files differnew file mode 100644 index 0000000000..9ebd8ae533 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/453861de5ab948236f13ebff66c8e82e4e789db6 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/46171f477d11338f4cc948915350772d54319200 b/test/core/end2end/fuzzers/api_fuzzer_corpus/46171f477d11338f4cc948915350772d54319200 Binary files differnew file mode 100644 index 0000000000..df032667c6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/46171f477d11338f4cc948915350772d54319200 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/46e1492e19d0cffdadc1050cc22d505b4e057759 b/test/core/end2end/fuzzers/api_fuzzer_corpus/46e1492e19d0cffdadc1050cc22d505b4e057759 Binary files differnew file mode 100644 index 0000000000..34bdf1fc73 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/46e1492e19d0cffdadc1050cc22d505b4e057759 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/4725b858491e1517af1032efba6bb198f39fd62d b/test/core/end2end/fuzzers/api_fuzzer_corpus/4725b858491e1517af1032efba6bb198f39fd62d Binary files differnew file mode 100644 index 0000000000..860a36c6dc --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/4725b858491e1517af1032efba6bb198f39fd62d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/48062d4824e8ba697cdd16a46b85d82ff445e649 b/test/core/end2end/fuzzers/api_fuzzer_corpus/48062d4824e8ba697cdd16a46b85d82ff445e649 Binary files differnew file mode 100644 index 0000000000..f472b3ba56 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/48062d4824e8ba697cdd16a46b85d82ff445e649 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/4857011f92ceaed4fee4d7612e1c46930903c95b b/test/core/end2end/fuzzers/api_fuzzer_corpus/4857011f92ceaed4fee4d7612e1c46930903c95b Binary files differnew file mode 100644 index 0000000000..e94c7cb43c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/4857011f92ceaed4fee4d7612e1c46930903c95b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/48c1691a919f1055f748e43cd799770f00c1c38a b/test/core/end2end/fuzzers/api_fuzzer_corpus/48c1691a919f1055f748e43cd799770f00c1c38a Binary files differnew file mode 100644 index 0000000000..3f0b5edf14 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/48c1691a919f1055f748e43cd799770f00c1c38a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/49254390bbc7e7b9eb58ddb1ac54a1e7eacee168 b/test/core/end2end/fuzzers/api_fuzzer_corpus/49254390bbc7e7b9eb58ddb1ac54a1e7eacee168 Binary files differnew file mode 100644 index 0000000000..b5418cf46d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/49254390bbc7e7b9eb58ddb1ac54a1e7eacee168 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/49d0085058d7fa81247f51b802c0f4206854b4dc b/test/core/end2end/fuzzers/api_fuzzer_corpus/49d0085058d7fa81247f51b802c0f4206854b4dc Binary files differnew file mode 100644 index 0000000000..052fa854ee --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/49d0085058d7fa81247f51b802c0f4206854b4dc diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/49f564289c79de9e0342f8b0821a167bc8c5ec00 b/test/core/end2end/fuzzers/api_fuzzer_corpus/49f564289c79de9e0342f8b0821a167bc8c5ec00 Binary files differnew file mode 100644 index 0000000000..c846377f0a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/49f564289c79de9e0342f8b0821a167bc8c5ec00 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/4a5a1abe7b402338c625013caa9bc8464a3d0bf2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/4a5a1abe7b402338c625013caa9bc8464a3d0bf2 Binary files differnew file mode 100644 index 0000000000..7ad87be818 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/4a5a1abe7b402338c625013caa9bc8464a3d0bf2 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/4ad1a61051d0db46638b774c61392b9d1c360410 b/test/core/end2end/fuzzers/api_fuzzer_corpus/4ad1a61051d0db46638b774c61392b9d1c360410 Binary files differnew file mode 100644 index 0000000000..08cdf0e22e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/4ad1a61051d0db46638b774c61392b9d1c360410 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/4aecde7ffaea881f42e693858b25c334df711b27 b/test/core/end2end/fuzzers/api_fuzzer_corpus/4aecde7ffaea881f42e693858b25c334df711b27 Binary files differnew file mode 100644 index 0000000000..651d85f44b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/4aecde7ffaea881f42e693858b25c334df711b27 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/4b0e9a84edc3eb0e6c377e860f5ecfca1bf64baa b/test/core/end2end/fuzzers/api_fuzzer_corpus/4b0e9a84edc3eb0e6c377e860f5ecfca1bf64baa Binary files differnew file mode 100644 index 0000000000..23a36273dc --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/4b0e9a84edc3eb0e6c377e860f5ecfca1bf64baa diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/4b303d7f245a569f507013af0b3afb2f033b6741 b/test/core/end2end/fuzzers/api_fuzzer_corpus/4b303d7f245a569f507013af0b3afb2f033b6741 Binary files differnew file mode 100644 index 0000000000..47d9819eec --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/4b303d7f245a569f507013af0b3afb2f033b6741 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5035db01a56a34061837c4d0214f6e5112d81ff3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/5035db01a56a34061837c4d0214f6e5112d81ff3 Binary files differnew file mode 100644 index 0000000000..a2e1b259bf --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5035db01a56a34061837c4d0214f6e5112d81ff3 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/503649137cea18ced8a57e7c644162bee8885ed1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/503649137cea18ced8a57e7c644162bee8885ed1 Binary files differnew file mode 100644 index 0000000000..58fba3d841 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/503649137cea18ced8a57e7c644162bee8885ed1 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/507865c4a5ce880b80400d93fa85def2682581cb b/test/core/end2end/fuzzers/api_fuzzer_corpus/507865c4a5ce880b80400d93fa85def2682581cb Binary files differnew file mode 100644 index 0000000000..c4473eacbb --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/507865c4a5ce880b80400d93fa85def2682581cb diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/51716d5683d5c762298fdfa6b57ecf17d6892fe6 b/test/core/end2end/fuzzers/api_fuzzer_corpus/51716d5683d5c762298fdfa6b57ecf17d6892fe6 Binary files differnew file mode 100644 index 0000000000..a8d3674c7e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/51716d5683d5c762298fdfa6b57ecf17d6892fe6 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/51adadd4662ab165a203afdbdbc470b62ac24d36 b/test/core/end2end/fuzzers/api_fuzzer_corpus/51adadd4662ab165a203afdbdbc470b62ac24d36 Binary files differnew file mode 100644 index 0000000000..c27014a928 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/51adadd4662ab165a203afdbdbc470b62ac24d36 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/51ea84d5a790d3d2495be453f5341c41b6153644 b/test/core/end2end/fuzzers/api_fuzzer_corpus/51ea84d5a790d3d2495be453f5341c41b6153644 Binary files differnew file mode 100644 index 0000000000..df8ee081bf --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/51ea84d5a790d3d2495be453f5341c41b6153644 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/52ac4e5a6c433b7e135e817b797f9bc85d4c619a b/test/core/end2end/fuzzers/api_fuzzer_corpus/52ac4e5a6c433b7e135e817b797f9bc85d4c619a Binary files differnew file mode 100644 index 0000000000..44746e47bd --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/52ac4e5a6c433b7e135e817b797f9bc85d4c619a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/536b5c0bf942c03bf9d4a4cc27c97c1230128ede b/test/core/end2end/fuzzers/api_fuzzer_corpus/536b5c0bf942c03bf9d4a4cc27c97c1230128ede Binary files differnew file mode 100644 index 0000000000..f6d08b9b92 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/536b5c0bf942c03bf9d4a4cc27c97c1230128ede diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/53e7030d5de06dcf80e1a60aa467e6e31bec6515 b/test/core/end2end/fuzzers/api_fuzzer_corpus/53e7030d5de06dcf80e1a60aa467e6e31bec6515 Binary files differnew file mode 100644 index 0000000000..dd161f0425 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/53e7030d5de06dcf80e1a60aa467e6e31bec6515 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/54168e5030c8a7cdd58162dee7c2583bb4caaf64 b/test/core/end2end/fuzzers/api_fuzzer_corpus/54168e5030c8a7cdd58162dee7c2583bb4caaf64 Binary files differnew file mode 100644 index 0000000000..459a76b114 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/54168e5030c8a7cdd58162dee7c2583bb4caaf64 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5547a3544fc5c634024d546366704547dd72cc2b b/test/core/end2end/fuzzers/api_fuzzer_corpus/5547a3544fc5c634024d546366704547dd72cc2b Binary files differnew file mode 100644 index 0000000000..9e6f5b687d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5547a3544fc5c634024d546366704547dd72cc2b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5559428fa9a1f1701e81eec11a3571be403bf627 b/test/core/end2end/fuzzers/api_fuzzer_corpus/5559428fa9a1f1701e81eec11a3571be403bf627 Binary files differnew file mode 100644 index 0000000000..180929895c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5559428fa9a1f1701e81eec11a3571be403bf627 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/559d537675dd3fc5e0c6d40e94133e9016014f6c b/test/core/end2end/fuzzers/api_fuzzer_corpus/559d537675dd3fc5e0c6d40e94133e9016014f6c Binary files differnew file mode 100644 index 0000000000..25327f398f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/559d537675dd3fc5e0c6d40e94133e9016014f6c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/55a71f74f233ea8ce88967c5660aaa532fbc985c b/test/core/end2end/fuzzers/api_fuzzer_corpus/55a71f74f233ea8ce88967c5660aaa532fbc985c Binary files differnew file mode 100644 index 0000000000..d02a29d612 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/55a71f74f233ea8ce88967c5660aaa532fbc985c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/55da9fe903905e9852dedf6b664a4a589efeeec5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/55da9fe903905e9852dedf6b664a4a589efeeec5 Binary files differnew file mode 100644 index 0000000000..8118bbbbb5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/55da9fe903905e9852dedf6b664a4a589efeeec5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/567026bafbad3be6a7bd430577e7d39ec3d56af6 b/test/core/end2end/fuzzers/api_fuzzer_corpus/567026bafbad3be6a7bd430577e7d39ec3d56af6 Binary files differnew file mode 100644 index 0000000000..1d6e37a6e4 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/567026bafbad3be6a7bd430577e7d39ec3d56af6 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/56f240463ef197b49c7e271e74412f62909974dc b/test/core/end2end/fuzzers/api_fuzzer_corpus/56f240463ef197b49c7e271e74412f62909974dc Binary files differnew file mode 100644 index 0000000000..4f77004c7f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/56f240463ef197b49c7e271e74412f62909974dc diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/57b087d753a6af79c0b58ca2c9aa5c92bc18a6a5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/57b087d753a6af79c0b58ca2c9aa5c92bc18a6a5 Binary files differnew file mode 100644 index 0000000000..af1031c03f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/57b087d753a6af79c0b58ca2c9aa5c92bc18a6a5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/59b547627a6b1aef96f6c5e3b7dc08c3e1244368 b/test/core/end2end/fuzzers/api_fuzzer_corpus/59b547627a6b1aef96f6c5e3b7dc08c3e1244368 Binary files differnew file mode 100644 index 0000000000..efc8af908d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/59b547627a6b1aef96f6c5e3b7dc08c3e1244368 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5ac0e42338f7b064f5c23697f1174a10b42e7ed8 b/test/core/end2end/fuzzers/api_fuzzer_corpus/5ac0e42338f7b064f5c23697f1174a10b42e7ed8 Binary files differnew file mode 100644 index 0000000000..1cce5cecff --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5ac0e42338f7b064f5c23697f1174a10b42e7ed8 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5ac8cb08604c86b9e8ca24482ca963eddac2efbe b/test/core/end2end/fuzzers/api_fuzzer_corpus/5ac8cb08604c86b9e8ca24482ca963eddac2efbe Binary files differnew file mode 100644 index 0000000000..9a2cafda5f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5ac8cb08604c86b9e8ca24482ca963eddac2efbe diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5bc4eddc2a2881d4b6b4f9532f4fb381e4cc9529 b/test/core/end2end/fuzzers/api_fuzzer_corpus/5bc4eddc2a2881d4b6b4f9532f4fb381e4cc9529 Binary files differnew file mode 100644 index 0000000000..9fa502fe69 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5bc4eddc2a2881d4b6b4f9532f4fb381e4cc9529 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5be0001be32d9e619769c7cc6cb9f541efe4996c b/test/core/end2end/fuzzers/api_fuzzer_corpus/5be0001be32d9e619769c7cc6cb9f541efe4996c Binary files differnew file mode 100644 index 0000000000..c42fa29f51 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5be0001be32d9e619769c7cc6cb9f541efe4996c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5c6debdb92eb9089773cc8d092d7f62d521ae029 b/test/core/end2end/fuzzers/api_fuzzer_corpus/5c6debdb92eb9089773cc8d092d7f62d521ae029 Binary files differnew file mode 100644 index 0000000000..ee6dfef51a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5c6debdb92eb9089773cc8d092d7f62d521ae029 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5cfdc00a568d97b09e720a72eac7e5fbbf76247b b/test/core/end2end/fuzzers/api_fuzzer_corpus/5cfdc00a568d97b09e720a72eac7e5fbbf76247b Binary files differnew file mode 100644 index 0000000000..6a74f12ef6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5cfdc00a568d97b09e720a72eac7e5fbbf76247b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5da1a1a4ee88d2a2b6e9470dd7be9e2dd9eecc4d b/test/core/end2end/fuzzers/api_fuzzer_corpus/5da1a1a4ee88d2a2b6e9470dd7be9e2dd9eecc4d Binary files differnew file mode 100644 index 0000000000..65b8542d2b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5da1a1a4ee88d2a2b6e9470dd7be9e2dd9eecc4d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5e0c4179d297f5bafe86b9e256bf75d54cfd1fb0 b/test/core/end2end/fuzzers/api_fuzzer_corpus/5e0c4179d297f5bafe86b9e256bf75d54cfd1fb0 Binary files differnew file mode 100644 index 0000000000..e8de3ad562 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5e0c4179d297f5bafe86b9e256bf75d54cfd1fb0 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5eeb786fa5735ef9b98c40e205f2eba24223acfd b/test/core/end2end/fuzzers/api_fuzzer_corpus/5eeb786fa5735ef9b98c40e205f2eba24223acfd Binary files differnew file mode 100644 index 0000000000..783110dd22 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5eeb786fa5735ef9b98c40e205f2eba24223acfd diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5f2fdb01d8ff632803ca2b732a7c088c6843d7d3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/5f2fdb01d8ff632803ca2b732a7c088c6843d7d3 Binary files differnew file mode 100644 index 0000000000..b91a052534 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5f2fdb01d8ff632803ca2b732a7c088c6843d7d3 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5f3a4ed52525d1db60b45d79057a6e276395e562 b/test/core/end2end/fuzzers/api_fuzzer_corpus/5f3a4ed52525d1db60b45d79057a6e276395e562 Binary files differnew file mode 100644 index 0000000000..25d6cdac55 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5f3a4ed52525d1db60b45d79057a6e276395e562 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/5fbffd9d324ad078bf6f5fdd39e5e4a27afd5965 b/test/core/end2end/fuzzers/api_fuzzer_corpus/5fbffd9d324ad078bf6f5fdd39e5e4a27afd5965 Binary files differnew file mode 100644 index 0000000000..2f4a3d9f34 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/5fbffd9d324ad078bf6f5fdd39e5e4a27afd5965 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6042b1bbaf3ceac51c11a472ea07a75e822b7bc5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/6042b1bbaf3ceac51c11a472ea07a75e822b7bc5 Binary files differnew file mode 100644 index 0000000000..1a4e8afff3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6042b1bbaf3ceac51c11a472ea07a75e822b7bc5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/60b4c79213b97204d1e4f6819ad1ed5f6e191789 b/test/core/end2end/fuzzers/api_fuzzer_corpus/60b4c79213b97204d1e4f6819ad1ed5f6e191789 Binary files differnew file mode 100644 index 0000000000..2c44e5da5c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/60b4c79213b97204d1e4f6819ad1ed5f6e191789 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/60eec02f3b3aa23b12261ed00163d122b24ab5af b/test/core/end2end/fuzzers/api_fuzzer_corpus/60eec02f3b3aa23b12261ed00163d122b24ab5af Binary files differnew file mode 100644 index 0000000000..5db740469d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/60eec02f3b3aa23b12261ed00163d122b24ab5af diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6108ac96de85e973db42982eff9d2f877a36699d b/test/core/end2end/fuzzers/api_fuzzer_corpus/6108ac96de85e973db42982eff9d2f877a36699d Binary files differnew file mode 100644 index 0000000000..8959111a05 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6108ac96de85e973db42982eff9d2f877a36699d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/614dbc86b17270ef1d5ab705ecbe88c742815ce7 b/test/core/end2end/fuzzers/api_fuzzer_corpus/614dbc86b17270ef1d5ab705ecbe88c742815ce7 Binary files differnew file mode 100644 index 0000000000..8fdff18222 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/614dbc86b17270ef1d5ab705ecbe88c742815ce7 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/61de97a9d6c4b082602c02277d8d763921f5f95b b/test/core/end2end/fuzzers/api_fuzzer_corpus/61de97a9d6c4b082602c02277d8d763921f5f95b Binary files differnew file mode 100644 index 0000000000..a24008b1d4 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/61de97a9d6c4b082602c02277d8d763921f5f95b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/62515c0e559e40838126e5be6ede5440875a3f70 b/test/core/end2end/fuzzers/api_fuzzer_corpus/62515c0e559e40838126e5be6ede5440875a3f70 Binary files differnew file mode 100644 index 0000000000..3dc4c18fd4 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/62515c0e559e40838126e5be6ede5440875a3f70 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/62b039b8a318cc08471f13629da08c68c414d8e7 b/test/core/end2end/fuzzers/api_fuzzer_corpus/62b039b8a318cc08471f13629da08c68c414d8e7 Binary files differnew file mode 100644 index 0000000000..e5e218acc3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/62b039b8a318cc08471f13629da08c68c414d8e7 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/63f1e7c7eb4d0ee635c3794993d2e2132cba72d4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/63f1e7c7eb4d0ee635c3794993d2e2132cba72d4 Binary files differnew file mode 100644 index 0000000000..722c8a67d3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/63f1e7c7eb4d0ee635c3794993d2e2132cba72d4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/641739453f7d4d3b55a1c7b79bed7da6dfd62ae0 b/test/core/end2end/fuzzers/api_fuzzer_corpus/641739453f7d4d3b55a1c7b79bed7da6dfd62ae0 Binary files differnew file mode 100644 index 0000000000..9dcc5c578c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/641739453f7d4d3b55a1c7b79bed7da6dfd62ae0 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/64656ddf81738f914ead8003c19d0148c54f34d6 b/test/core/end2end/fuzzers/api_fuzzer_corpus/64656ddf81738f914ead8003c19d0148c54f34d6 Binary files differnew file mode 100644 index 0000000000..daf5bc14b1 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/64656ddf81738f914ead8003c19d0148c54f34d6 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/64d1666dc1b1126bb99e3792040dff64b336ae36 b/test/core/end2end/fuzzers/api_fuzzer_corpus/64d1666dc1b1126bb99e3792040dff64b336ae36 Binary files differnew file mode 100644 index 0000000000..f5a526ce37 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/64d1666dc1b1126bb99e3792040dff64b336ae36 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/64d410e245db26eb7996c20bee1e3dfd77c43ebc b/test/core/end2end/fuzzers/api_fuzzer_corpus/64d410e245db26eb7996c20bee1e3dfd77c43ebc Binary files differnew file mode 100644 index 0000000000..dd97b425ed --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/64d410e245db26eb7996c20bee1e3dfd77c43ebc diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6589505362ffb5164a3c7cb1b9feadcddfba44e9 b/test/core/end2end/fuzzers/api_fuzzer_corpus/6589505362ffb5164a3c7cb1b9feadcddfba44e9 Binary files differnew file mode 100644 index 0000000000..10625da2ff --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6589505362ffb5164a3c7cb1b9feadcddfba44e9 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/671d63b9968444308d4908eb6a26bccdf32e5e29 b/test/core/end2end/fuzzers/api_fuzzer_corpus/671d63b9968444308d4908eb6a26bccdf32e5e29 Binary files differnew file mode 100644 index 0000000000..38c69c7893 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/671d63b9968444308d4908eb6a26bccdf32e5e29 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6757865ccfef9bf8f1ba4302be9767758390fa92 b/test/core/end2end/fuzzers/api_fuzzer_corpus/6757865ccfef9bf8f1ba4302be9767758390fa92 Binary files differnew file mode 100644 index 0000000000..4c2914d3ac --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6757865ccfef9bf8f1ba4302be9767758390fa92 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/681b758cad3bbce4bde2d1a78a2ec4600c59b05c b/test/core/end2end/fuzzers/api_fuzzer_corpus/681b758cad3bbce4bde2d1a78a2ec4600c59b05c Binary files differnew file mode 100644 index 0000000000..d54a2af33d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/681b758cad3bbce4bde2d1a78a2ec4600c59b05c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/68359027351be494040cc9ae6d4ccfc248fe6fcd b/test/core/end2end/fuzzers/api_fuzzer_corpus/68359027351be494040cc9ae6d4ccfc248fe6fcd Binary files differnew file mode 100644 index 0000000000..554a83bf46 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/68359027351be494040cc9ae6d4ccfc248fe6fcd diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6951632faa6eee58b6480b7cae00ee8ea1223658 b/test/core/end2end/fuzzers/api_fuzzer_corpus/6951632faa6eee58b6480b7cae00ee8ea1223658 Binary files differnew file mode 100644 index 0000000000..76d8c7dacd --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6951632faa6eee58b6480b7cae00ee8ea1223658 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/69c6c28a67fe1b5ea32cab0f06564c59ec3fcbab b/test/core/end2end/fuzzers/api_fuzzer_corpus/69c6c28a67fe1b5ea32cab0f06564c59ec3fcbab Binary files differnew file mode 100644 index 0000000000..1d17649497 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/69c6c28a67fe1b5ea32cab0f06564c59ec3fcbab diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6a2b1a1222017169ff83695bb42bf760c8126a2d b/test/core/end2end/fuzzers/api_fuzzer_corpus/6a2b1a1222017169ff83695bb42bf760c8126a2d Binary files differnew file mode 100644 index 0000000000..f25505780b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6a2b1a1222017169ff83695bb42bf760c8126a2d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6a3dee1cefadc15954dafe424c73b78a3b5c1b22 b/test/core/end2end/fuzzers/api_fuzzer_corpus/6a3dee1cefadc15954dafe424c73b78a3b5c1b22 Binary files differnew file mode 100644 index 0000000000..3dee8d06ce --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6a3dee1cefadc15954dafe424c73b78a3b5c1b22 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6ad3a1170ef884a884a6f340101549df624bf5a4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/6ad3a1170ef884a884a6f340101549df624bf5a4 Binary files differnew file mode 100644 index 0000000000..27cea9ee0c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6ad3a1170ef884a884a6f340101549df624bf5a4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6ae25d59c9f771291edddc6c71d01c855883b99b b/test/core/end2end/fuzzers/api_fuzzer_corpus/6ae25d59c9f771291edddc6c71d01c855883b99b Binary files differnew file mode 100644 index 0000000000..dede6d1ece --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6ae25d59c9f771291edddc6c71d01c855883b99b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6cb17148d52be437332b6fd6f2fc8328bfb63fb0 b/test/core/end2end/fuzzers/api_fuzzer_corpus/6cb17148d52be437332b6fd6f2fc8328bfb63fb0 Binary files differnew file mode 100644 index 0000000000..36d98fea76 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6cb17148d52be437332b6fd6f2fc8328bfb63fb0 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6ea192b1d4c4577ca7511f8ce5027b31b2e0d75d b/test/core/end2end/fuzzers/api_fuzzer_corpus/6ea192b1d4c4577ca7511f8ce5027b31b2e0d75d Binary files differnew file mode 100644 index 0000000000..a31fcf596c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6ea192b1d4c4577ca7511f8ce5027b31b2e0d75d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6ed943877a76ab6b17443e5b194012d9008612ad b/test/core/end2end/fuzzers/api_fuzzer_corpus/6ed943877a76ab6b17443e5b194012d9008612ad Binary files differnew file mode 100644 index 0000000000..35078764b7 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6ed943877a76ab6b17443e5b194012d9008612ad diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/6eef551288136e9fb2d9de210b14148746203472 b/test/core/end2end/fuzzers/api_fuzzer_corpus/6eef551288136e9fb2d9de210b14148746203472 Binary files differnew file mode 100644 index 0000000000..8f838a4410 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/6eef551288136e9fb2d9de210b14148746203472 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/70cf4c8bdd833f8c62d8c89ef50d50008457f5ac b/test/core/end2end/fuzzers/api_fuzzer_corpus/70cf4c8bdd833f8c62d8c89ef50d50008457f5ac Binary files differnew file mode 100644 index 0000000000..f40f24f06a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/70cf4c8bdd833f8c62d8c89ef50d50008457f5ac diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/71403746b8e54a5f9b6fa1882a7ff5322180dd01 b/test/core/end2end/fuzzers/api_fuzzer_corpus/71403746b8e54a5f9b6fa1882a7ff5322180dd01 Binary files differnew file mode 100644 index 0000000000..ce9f217b99 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/71403746b8e54a5f9b6fa1882a7ff5322180dd01 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/71961e53698b07bfd57e9ea37067e0dd52298a3d b/test/core/end2end/fuzzers/api_fuzzer_corpus/71961e53698b07bfd57e9ea37067e0dd52298a3d Binary files differnew file mode 100644 index 0000000000..21a263f870 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/71961e53698b07bfd57e9ea37067e0dd52298a3d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/71a0dd688553c753919c58d00c8e8db130726b3b b/test/core/end2end/fuzzers/api_fuzzer_corpus/71a0dd688553c753919c58d00c8e8db130726b3b Binary files differnew file mode 100644 index 0000000000..940e57971f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/71a0dd688553c753919c58d00c8e8db130726b3b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/71cbd5e4e98344dd16df8b21546439cdb0879e0f b/test/core/end2end/fuzzers/api_fuzzer_corpus/71cbd5e4e98344dd16df8b21546439cdb0879e0f Binary files differnew file mode 100644 index 0000000000..3ca83e18fd --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/71cbd5e4e98344dd16df8b21546439cdb0879e0f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/72031f24261c32d2e3bb2c7909a9315227172730 b/test/core/end2end/fuzzers/api_fuzzer_corpus/72031f24261c32d2e3bb2c7909a9315227172730 Binary files differnew file mode 100644 index 0000000000..b02f72e6be --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/72031f24261c32d2e3bb2c7909a9315227172730 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/724f5400f19e5a0be97022341c39eeaaaffeb390 b/test/core/end2end/fuzzers/api_fuzzer_corpus/724f5400f19e5a0be97022341c39eeaaaffeb390 Binary files differnew file mode 100644 index 0000000000..1dbc538192 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/724f5400f19e5a0be97022341c39eeaaaffeb390 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7254b9ff59ab3fcf345effdabbc25ebd2e907b23 b/test/core/end2end/fuzzers/api_fuzzer_corpus/7254b9ff59ab3fcf345effdabbc25ebd2e907b23 Binary files differnew file mode 100644 index 0000000000..92371e031f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/7254b9ff59ab3fcf345effdabbc25ebd2e907b23 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/746477e7e8f093f87cb6924ab6476cda9689607d b/test/core/end2end/fuzzers/api_fuzzer_corpus/746477e7e8f093f87cb6924ab6476cda9689607d Binary files differnew file mode 100644 index 0000000000..e348c19028 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/746477e7e8f093f87cb6924ab6476cda9689607d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/750668bd25d3c4d5c8ff863185749d31978b88e5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/750668bd25d3c4d5c8ff863185749d31978b88e5 Binary files differnew file mode 100644 index 0000000000..7d4f440256 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/750668bd25d3c4d5c8ff863185749d31978b88e5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/755e5b679c1bb2720590e166d5047588a0e2f8b0 b/test/core/end2end/fuzzers/api_fuzzer_corpus/755e5b679c1bb2720590e166d5047588a0e2f8b0 Binary files differnew file mode 100644 index 0000000000..35af128410 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/755e5b679c1bb2720590e166d5047588a0e2f8b0 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/75af1ed0b83b24a1d5201038a4b382d0ace6222f b/test/core/end2end/fuzzers/api_fuzzer_corpus/75af1ed0b83b24a1d5201038a4b382d0ace6222f Binary files differnew file mode 100644 index 0000000000..7040b2fc20 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/75af1ed0b83b24a1d5201038a4b382d0ace6222f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/75cd5b751f530f494c224304b4024d490032e65a b/test/core/end2end/fuzzers/api_fuzzer_corpus/75cd5b751f530f494c224304b4024d490032e65a Binary files differnew file mode 100644 index 0000000000..34240388e5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/75cd5b751f530f494c224304b4024d490032e65a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/75f9b79cacbfef018bb131af2e2ba0735b2640ec b/test/core/end2end/fuzzers/api_fuzzer_corpus/75f9b79cacbfef018bb131af2e2ba0735b2640ec Binary files differnew file mode 100644 index 0000000000..0bbc39c9c6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/75f9b79cacbfef018bb131af2e2ba0735b2640ec diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/76116b26156d91b16a70f28a126ed5f05ce55548 b/test/core/end2end/fuzzers/api_fuzzer_corpus/76116b26156d91b16a70f28a126ed5f05ce55548 Binary files differnew file mode 100644 index 0000000000..97890454d6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/76116b26156d91b16a70f28a126ed5f05ce55548 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/766995b9faa25c3b2c825413e5e9a702721de7fa b/test/core/end2end/fuzzers/api_fuzzer_corpus/766995b9faa25c3b2c825413e5e9a702721de7fa Binary files differnew file mode 100644 index 0000000000..4c281a8555 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/766995b9faa25c3b2c825413e5e9a702721de7fa diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7752153d87017b85112a49ea95aa25ca78d24431 b/test/core/end2end/fuzzers/api_fuzzer_corpus/7752153d87017b85112a49ea95aa25ca78d24431 Binary files differnew file mode 100644 index 0000000000..8e9b21a777 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/7752153d87017b85112a49ea95aa25ca78d24431 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/77f4f436f910c45f216fe4d3f9b631612ed09cf6 b/test/core/end2end/fuzzers/api_fuzzer_corpus/77f4f436f910c45f216fe4d3f9b631612ed09cf6 Binary files differnew file mode 100644 index 0000000000..8e31ee64e0 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/77f4f436f910c45f216fe4d3f9b631612ed09cf6 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/780fc96dea7f78bb9d1a074efbd966b03d78d653 b/test/core/end2end/fuzzers/api_fuzzer_corpus/780fc96dea7f78bb9d1a074efbd966b03d78d653 Binary files differnew file mode 100644 index 0000000000..56d52f326d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/780fc96dea7f78bb9d1a074efbd966b03d78d653 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/783484ad9e15085e9039c7504aac71af1ad549a2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/783484ad9e15085e9039c7504aac71af1ad549a2 Binary files differnew file mode 100644 index 0000000000..cdee9cfeb9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/783484ad9e15085e9039c7504aac71af1ad549a2 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/784ca396c157df8ba93bbe1e12c6d32609ef05a1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/784ca396c157df8ba93bbe1e12c6d32609ef05a1 Binary files differnew file mode 100644 index 0000000000..d601edf985 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/784ca396c157df8ba93bbe1e12c6d32609ef05a1 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/784d6f5c093ab5360670173ce001e1a446f95822 b/test/core/end2end/fuzzers/api_fuzzer_corpus/784d6f5c093ab5360670173ce001e1a446f95822 Binary files differnew file mode 100644 index 0000000000..79885b7f2a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/784d6f5c093ab5360670173ce001e1a446f95822 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/78e43d163fc8226d72b979c0fe6e1593ef3cb542 b/test/core/end2end/fuzzers/api_fuzzer_corpus/78e43d163fc8226d72b979c0fe6e1593ef3cb542 Binary files differnew file mode 100644 index 0000000000..e3470adec6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/78e43d163fc8226d72b979c0fe6e1593ef3cb542 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/79163c87e1c3340d05799cf27f1e898a932d1001 b/test/core/end2end/fuzzers/api_fuzzer_corpus/79163c87e1c3340d05799cf27f1e898a932d1001 Binary files differnew file mode 100644 index 0000000000..705aef2998 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/79163c87e1c3340d05799cf27f1e898a932d1001 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/79328fdc89d0af0e38da089dab062fd3ea5aae59 b/test/core/end2end/fuzzers/api_fuzzer_corpus/79328fdc89d0af0e38da089dab062fd3ea5aae59 Binary files differnew file mode 100644 index 0000000000..4a5cbfd654 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/79328fdc89d0af0e38da089dab062fd3ea5aae59 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/795912f4ca380c73a3a3c956b1cba1e9051d92bf b/test/core/end2end/fuzzers/api_fuzzer_corpus/795912f4ca380c73a3a3c956b1cba1e9051d92bf Binary files differnew file mode 100644 index 0000000000..2972f6c0c5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/795912f4ca380c73a3a3c956b1cba1e9051d92bf diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7a2569f4daf4480ad142cb4ee7c675bed82db74c b/test/core/end2end/fuzzers/api_fuzzer_corpus/7a2569f4daf4480ad142cb4ee7c675bed82db74c Binary files differnew file mode 100644 index 0000000000..75b55e7e10 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/7a2569f4daf4480ad142cb4ee7c675bed82db74c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7b3a99b69df9931fe12dfce5d8c5153f43bf4fd9 b/test/core/end2end/fuzzers/api_fuzzer_corpus/7b3a99b69df9931fe12dfce5d8c5153f43bf4fd9 Binary files differnew file mode 100644 index 0000000000..561c5f7e2c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/7b3a99b69df9931fe12dfce5d8c5153f43bf4fd9 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7b5a71e770bf9eed928f5e552a7659f8ad8a8b84 b/test/core/end2end/fuzzers/api_fuzzer_corpus/7b5a71e770bf9eed928f5e552a7659f8ad8a8b84 Binary files differnew file mode 100644 index 0000000000..3b5933e3c9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/7b5a71e770bf9eed928f5e552a7659f8ad8a8b84 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7cae7e5c67636a72a00785e04cc55af57b9e1318 b/test/core/end2end/fuzzers/api_fuzzer_corpus/7cae7e5c67636a72a00785e04cc55af57b9e1318 Binary files differnew file mode 100644 index 0000000000..be188e6cbc --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/7cae7e5c67636a72a00785e04cc55af57b9e1318 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7e75ea44aa7347c2f827beecb27e3bf5b1907b8a b/test/core/end2end/fuzzers/api_fuzzer_corpus/7e75ea44aa7347c2f827beecb27e3bf5b1907b8a Binary files differnew file mode 100644 index 0000000000..c5963737d3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/7e75ea44aa7347c2f827beecb27e3bf5b1907b8a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7fb64b5785ebe699ca50327c88c1d8b99432fa23 b/test/core/end2end/fuzzers/api_fuzzer_corpus/7fb64b5785ebe699ca50327c88c1d8b99432fa23 Binary files differnew file mode 100644 index 0000000000..21802ec5ee --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/7fb64b5785ebe699ca50327c88c1d8b99432fa23 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/7ff449b555102deaeea7245b5a370dd0820d2691 b/test/core/end2end/fuzzers/api_fuzzer_corpus/7ff449b555102deaeea7245b5a370dd0820d2691 Binary files differnew file mode 100644 index 0000000000..d0e0587e49 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/7ff449b555102deaeea7245b5a370dd0820d2691 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8005d0a23f43613949321e9fc761180cdcd569c8 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8005d0a23f43613949321e9fc761180cdcd569c8 Binary files differnew file mode 100644 index 0000000000..1a2385c7ed --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8005d0a23f43613949321e9fc761180cdcd569c8 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/807a48bd33ce375438dbc158c1531891c5b54a51 b/test/core/end2end/fuzzers/api_fuzzer_corpus/807a48bd33ce375438dbc158c1531891c5b54a51 Binary files differnew file mode 100644 index 0000000000..4fd3b4cdc0 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/807a48bd33ce375438dbc158c1531891c5b54a51 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/80d4266aee0b8b7dca74696dde949ebfaa052535 b/test/core/end2end/fuzzers/api_fuzzer_corpus/80d4266aee0b8b7dca74696dde949ebfaa052535 Binary files differnew file mode 100644 index 0000000000..26585324a8 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/80d4266aee0b8b7dca74696dde949ebfaa052535 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/817570ac3bbeab63961d78aa2fef496e87c7e056 b/test/core/end2end/fuzzers/api_fuzzer_corpus/817570ac3bbeab63961d78aa2fef496e87c7e056 Binary files differnew file mode 100644 index 0000000000..36adfeb2a2 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/817570ac3bbeab63961d78aa2fef496e87c7e056 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/823ef8523d3d3d90578d32e09e6822eb9ed42ecf b/test/core/end2end/fuzzers/api_fuzzer_corpus/823ef8523d3d3d90578d32e09e6822eb9ed42ecf Binary files differnew file mode 100644 index 0000000000..530dd554b7 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/823ef8523d3d3d90578d32e09e6822eb9ed42ecf diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/826c36b53a0f249c139de4aec6fb113a70af3b6a b/test/core/end2end/fuzzers/api_fuzzer_corpus/826c36b53a0f249c139de4aec6fb113a70af3b6a Binary files differnew file mode 100644 index 0000000000..108f7150b0 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/826c36b53a0f249c139de4aec6fb113a70af3b6a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/82731abc38788755495b1bac7b58bc0f12e4bdd1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/82731abc38788755495b1bac7b58bc0f12e4bdd1 Binary files differnew file mode 100644 index 0000000000..20c7c70f83 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/82731abc38788755495b1bac7b58bc0f12e4bdd1 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/835062d78983dae5747ab4e207d227869ce90733 b/test/core/end2end/fuzzers/api_fuzzer_corpus/835062d78983dae5747ab4e207d227869ce90733 Binary files differnew file mode 100644 index 0000000000..1422c0640f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/835062d78983dae5747ab4e207d227869ce90733 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/83776278a4997b0d178602c8419f3e6481dec01d b/test/core/end2end/fuzzers/api_fuzzer_corpus/83776278a4997b0d178602c8419f3e6481dec01d Binary files differnew file mode 100644 index 0000000000..2570ea8bc6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/83776278a4997b0d178602c8419f3e6481dec01d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/837db5272d730107ae362fcd3cb2c21e5f1ea53e b/test/core/end2end/fuzzers/api_fuzzer_corpus/837db5272d730107ae362fcd3cb2c21e5f1ea53e Binary files differnew file mode 100644 index 0000000000..53d45b5aa5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/837db5272d730107ae362fcd3cb2c21e5f1ea53e diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/83a2a19743bb77278aba8cce1d04529d2cb0a744 b/test/core/end2end/fuzzers/api_fuzzer_corpus/83a2a19743bb77278aba8cce1d04529d2cb0a744 Binary files differnew file mode 100644 index 0000000000..3bf333b82b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/83a2a19743bb77278aba8cce1d04529d2cb0a744 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/853a546c5435e9eb9f2d13898755abeaf93d51b1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/853a546c5435e9eb9f2d13898755abeaf93d51b1 Binary files differnew file mode 100644 index 0000000000..6464ace91f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/853a546c5435e9eb9f2d13898755abeaf93d51b1 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8644486ad9579f43b8c6f34b423c2c1159b20a9a b/test/core/end2end/fuzzers/api_fuzzer_corpus/8644486ad9579f43b8c6f34b423c2c1159b20a9a Binary files differnew file mode 100644 index 0000000000..2bc1290ab6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8644486ad9579f43b8c6f34b423c2c1159b20a9a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/86906b52f5fdad0955f5a93dd26ff420e4a58078 b/test/core/end2end/fuzzers/api_fuzzer_corpus/86906b52f5fdad0955f5a93dd26ff420e4a58078 Binary files differnew file mode 100644 index 0000000000..17b1b02f69 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/86906b52f5fdad0955f5a93dd26ff420e4a58078 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/87a300cd25d2e57745bd00499d4d2352a10a2fa1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/87a300cd25d2e57745bd00499d4d2352a10a2fa1 Binary files differnew file mode 100644 index 0000000000..c8f79862bc --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/87a300cd25d2e57745bd00499d4d2352a10a2fa1 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/87a34188d51bc8b43bd7d9097958097e70154960 b/test/core/end2end/fuzzers/api_fuzzer_corpus/87a34188d51bc8b43bd7d9097958097e70154960 Binary files differnew file mode 100644 index 0000000000..a90fb52338 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/87a34188d51bc8b43bd7d9097958097e70154960 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/87a4605e106399e71e689468a23ba11e7f17de2b b/test/core/end2end/fuzzers/api_fuzzer_corpus/87a4605e106399e71e689468a23ba11e7f17de2b Binary files differnew file mode 100644 index 0000000000..c9a66bd9f6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/87a4605e106399e71e689468a23ba11e7f17de2b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/89cdf2f9a9682277284c24819a0cd336bbb04d60 b/test/core/end2end/fuzzers/api_fuzzer_corpus/89cdf2f9a9682277284c24819a0cd336bbb04d60 Binary files differnew file mode 100644 index 0000000000..9501a65404 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/89cdf2f9a9682277284c24819a0cd336bbb04d60 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8a1c629910280f8beebb88687696de98da988ecc b/test/core/end2end/fuzzers/api_fuzzer_corpus/8a1c629910280f8beebb88687696de98da988ecc Binary files differnew file mode 100644 index 0000000000..ce3377fdc1 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8a1c629910280f8beebb88687696de98da988ecc diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8adec341bcbd14fb0bee52926141a4a5b3a885e2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8adec341bcbd14fb0bee52926141a4a5b3a885e2 Binary files differnew file mode 100644 index 0000000000..270c4babd8 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8adec341bcbd14fb0bee52926141a4a5b3a885e2 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8b43d6ab6c1034fba9757ce801e237da089f1898 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8b43d6ab6c1034fba9757ce801e237da089f1898 Binary files differnew file mode 100644 index 0000000000..782654efba --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8b43d6ab6c1034fba9757ce801e237da089f1898 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8c00268431d8fb83ee306f0a49bee4af8728c0b0 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8c00268431d8fb83ee306f0a49bee4af8728c0b0 Binary files differnew file mode 100644 index 0000000000..95211f0f25 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8c00268431d8fb83ee306f0a49bee4af8728c0b0 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8c5d9191880e9753a747e7ccd7824483bcd7568a b/test/core/end2end/fuzzers/api_fuzzer_corpus/8c5d9191880e9753a747e7ccd7824483bcd7568a Binary files differnew file mode 100644 index 0000000000..de4f90e72f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8c5d9191880e9753a747e7ccd7824483bcd7568a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8cbb67da0e40816cf4bedf4fa6ce176563fc0487 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8cbb67da0e40816cf4bedf4fa6ce176563fc0487 Binary files differnew file mode 100644 index 0000000000..aaded62452 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8cbb67da0e40816cf4bedf4fa6ce176563fc0487 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8d54be1edc097b319d26ee1a08b1da06bafd0bbc b/test/core/end2end/fuzzers/api_fuzzer_corpus/8d54be1edc097b319d26ee1a08b1da06bafd0bbc Binary files differnew file mode 100644 index 0000000000..020792a956 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8d54be1edc097b319d26ee1a08b1da06bafd0bbc diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8dfdb04ef558fba84dcbfa65a6aa318b10988fa9 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8dfdb04ef558fba84dcbfa65a6aa318b10988fa9 Binary files differnew file mode 100644 index 0000000000..7e71dc66d4 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8dfdb04ef558fba84dcbfa65a6aa318b10988fa9 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8e49b880f6e9514963c8f82bc6c7131ab104200f b/test/core/end2end/fuzzers/api_fuzzer_corpus/8e49b880f6e9514963c8f82bc6c7131ab104200f Binary files differnew file mode 100644 index 0000000000..944d3e76a7 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8e49b880f6e9514963c8f82bc6c7131ab104200f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8e6332b7d5234f6a1a153f91131ea33f0a5535d8 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8e6332b7d5234f6a1a153f91131ea33f0a5535d8 Binary files differnew file mode 100644 index 0000000000..c790e8c799 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8e6332b7d5234f6a1a153f91131ea33f0a5535d8 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8ea9969bced02fd855c7de7edb12f074226f6dab b/test/core/end2end/fuzzers/api_fuzzer_corpus/8ea9969bced02fd855c7de7edb12f074226f6dab Binary files differnew file mode 100644 index 0000000000..531ba64f2e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8ea9969bced02fd855c7de7edb12f074226f6dab diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8efa9ad7c934a3c3cc01470ee1c21d7063f7b209 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8efa9ad7c934a3c3cc01470ee1c21d7063f7b209 Binary files differnew file mode 100644 index 0000000000..c2dcd010c0 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8efa9ad7c934a3c3cc01470ee1c21d7063f7b209 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8f332e450d6a489fed2627f387cf0d0db7bacd37 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8f332e450d6a489fed2627f387cf0d0db7bacd37 Binary files differnew file mode 100644 index 0000000000..740dd57a72 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8f332e450d6a489fed2627f387cf0d0db7bacd37 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8f71f51eba1aba1d839b19801c594eab968a892e b/test/core/end2end/fuzzers/api_fuzzer_corpus/8f71f51eba1aba1d839b19801c594eab968a892e Binary files differnew file mode 100644 index 0000000000..ef4b4e1a15 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8f71f51eba1aba1d839b19801c594eab968a892e diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8f840f0a04cce56098d395939b446589ee67da0c b/test/core/end2end/fuzzers/api_fuzzer_corpus/8f840f0a04cce56098d395939b446589ee67da0c Binary files differnew file mode 100644 index 0000000000..d72b78c939 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8f840f0a04cce56098d395939b446589ee67da0c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8fba35a2ec8e2eb182eeacd23592c92932c64200 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8fba35a2ec8e2eb182eeacd23592c92932c64200 Binary files differnew file mode 100644 index 0000000000..351f16a946 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8fba35a2ec8e2eb182eeacd23592c92932c64200 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/8ff7b1568d2da2e4196c2e28617e1911d62021e6 b/test/core/end2end/fuzzers/api_fuzzer_corpus/8ff7b1568d2da2e4196c2e28617e1911d62021e6 Binary files differnew file mode 100644 index 0000000000..321520b870 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/8ff7b1568d2da2e4196c2e28617e1911d62021e6 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/902ad49db6c0518017e8438d1ee61e0841fda6e7 b/test/core/end2end/fuzzers/api_fuzzer_corpus/902ad49db6c0518017e8438d1ee61e0841fda6e7 Binary files differnew file mode 100644 index 0000000000..586cd39a23 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/902ad49db6c0518017e8438d1ee61e0841fda6e7 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/91236da3b95886937ab487700d8c72b40e6b9477 b/test/core/end2end/fuzzers/api_fuzzer_corpus/91236da3b95886937ab487700d8c72b40e6b9477 Binary files differnew file mode 100644 index 0000000000..da27462e8a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/91236da3b95886937ab487700d8c72b40e6b9477 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/91491f410776eb726c8a5face925c703737ed916 b/test/core/end2end/fuzzers/api_fuzzer_corpus/91491f410776eb726c8a5face925c703737ed916 Binary files differnew file mode 100644 index 0000000000..5adc9504b0 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/91491f410776eb726c8a5face925c703737ed916 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/91980bd25cd4827c2e0c9ebb028d03ef226d0e73 b/test/core/end2end/fuzzers/api_fuzzer_corpus/91980bd25cd4827c2e0c9ebb028d03ef226d0e73 Binary files differnew file mode 100644 index 0000000000..8510caabe2 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/91980bd25cd4827c2e0c9ebb028d03ef226d0e73 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/92c816d98f9f8669f43b46b22d5da21464d9ef41 b/test/core/end2end/fuzzers/api_fuzzer_corpus/92c816d98f9f8669f43b46b22d5da21464d9ef41 Binary files differnew file mode 100644 index 0000000000..c000647a86 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/92c816d98f9f8669f43b46b22d5da21464d9ef41 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/939a61533db8868591c514fc41c7dfb4232e3e4f b/test/core/end2end/fuzzers/api_fuzzer_corpus/939a61533db8868591c514fc41c7dfb4232e3e4f Binary files differnew file mode 100644 index 0000000000..c21081b541 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/939a61533db8868591c514fc41c7dfb4232e3e4f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/943924f902d02a4358ba2ae693087033d30e862b b/test/core/end2end/fuzzers/api_fuzzer_corpus/943924f902d02a4358ba2ae693087033d30e862b Binary files differnew file mode 100644 index 0000000000..c879d782a4 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/943924f902d02a4358ba2ae693087033d30e862b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/946f3ee9686789790301935574f412b9cf5cdeec b/test/core/end2end/fuzzers/api_fuzzer_corpus/946f3ee9686789790301935574f412b9cf5cdeec Binary files differnew file mode 100644 index 0000000000..a627547b9a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/946f3ee9686789790301935574f412b9cf5cdeec diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/958d48d95d2c2ff8b177ebd2149b9d9a89908f48 b/test/core/end2end/fuzzers/api_fuzzer_corpus/958d48d95d2c2ff8b177ebd2149b9d9a89908f48 Binary files differnew file mode 100644 index 0000000000..14d8c6a492 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/958d48d95d2c2ff8b177ebd2149b9d9a89908f48 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/95e73caecc0ab06beaa9b84125adcb2e6eee2eff b/test/core/end2end/fuzzers/api_fuzzer_corpus/95e73caecc0ab06beaa9b84125adcb2e6eee2eff Binary files differnew file mode 100644 index 0000000000..67fecc095d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/95e73caecc0ab06beaa9b84125adcb2e6eee2eff diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9625913195b7d7a5337016e8f9a29c8f3d6ad435 b/test/core/end2end/fuzzers/api_fuzzer_corpus/9625913195b7d7a5337016e8f9a29c8f3d6ad435 Binary files differnew file mode 100644 index 0000000000..26233fc403 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/9625913195b7d7a5337016e8f9a29c8f3d6ad435 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/963c2fa0d8197bb8b6c7bbfcb43a9ae1ec29f2c7 b/test/core/end2end/fuzzers/api_fuzzer_corpus/963c2fa0d8197bb8b6c7bbfcb43a9ae1ec29f2c7 Binary files differnew file mode 100644 index 0000000000..3420d46065 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/963c2fa0d8197bb8b6c7bbfcb43a9ae1ec29f2c7 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/973f74081ad8c1d91ad1b0bfc10061de72d1b1bc b/test/core/end2end/fuzzers/api_fuzzer_corpus/973f74081ad8c1d91ad1b0bfc10061de72d1b1bc Binary files differnew file mode 100644 index 0000000000..ae0e4e378f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/973f74081ad8c1d91ad1b0bfc10061de72d1b1bc diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/974be67fe5188cfa77f7db943dfdaa0a4a2c4e82 b/test/core/end2end/fuzzers/api_fuzzer_corpus/974be67fe5188cfa77f7db943dfdaa0a4a2c4e82 Binary files differnew file mode 100644 index 0000000000..c6f1c5a8d7 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/974be67fe5188cfa77f7db943dfdaa0a4a2c4e82 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/976ed70e538943fc60d5b339528c70a69161d6a1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/976ed70e538943fc60d5b339528c70a69161d6a1 Binary files differnew file mode 100644 index 0000000000..21c265de57 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/976ed70e538943fc60d5b339528c70a69161d6a1 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/97b87b4a9d1846c2f2277f7291c545be955257e3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/97b87b4a9d1846c2f2277f7291c545be955257e3 Binary files differnew file mode 100644 index 0000000000..90c4026f1e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/97b87b4a9d1846c2f2277f7291c545be955257e3 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/97d261c920f2802c97343e07847c98afa3ff46a3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/97d261c920f2802c97343e07847c98afa3ff46a3 Binary files differnew file mode 100644 index 0000000000..2861755d6d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/97d261c920f2802c97343e07847c98afa3ff46a3 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/97f7a51a0bb869d09f9f1bd7a4f93c5d859c89eb b/test/core/end2end/fuzzers/api_fuzzer_corpus/97f7a51a0bb869d09f9f1bd7a4f93c5d859c89eb Binary files differnew file mode 100644 index 0000000000..1bb271fbb1 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/97f7a51a0bb869d09f9f1bd7a4f93c5d859c89eb diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/982f375b183d984958667461c7767206062eb4cb b/test/core/end2end/fuzzers/api_fuzzer_corpus/982f375b183d984958667461c7767206062eb4cb Binary files differnew file mode 100644 index 0000000000..01d07d6408 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/982f375b183d984958667461c7767206062eb4cb diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/98739af631223fa05ad88f1e63a52052a9bb4b1c b/test/core/end2end/fuzzers/api_fuzzer_corpus/98739af631223fa05ad88f1e63a52052a9bb4b1c Binary files differnew file mode 100644 index 0000000000..a4adb7aee6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/98739af631223fa05ad88f1e63a52052a9bb4b1c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/98a661d328f1ad6277c802604126d91965d6fda8 b/test/core/end2end/fuzzers/api_fuzzer_corpus/98a661d328f1ad6277c802604126d91965d6fda8 Binary files differnew file mode 100644 index 0000000000..ee68d203dc --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/98a661d328f1ad6277c802604126d91965d6fda8 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9916b65305d28acf75a17495b9f44d7b839b948f b/test/core/end2end/fuzzers/api_fuzzer_corpus/9916b65305d28acf75a17495b9f44d7b839b948f Binary files differnew file mode 100644 index 0000000000..40a6dacd7d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/9916b65305d28acf75a17495b9f44d7b839b948f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/99789b6e9a0932dc95b686cf380872175603918f b/test/core/end2end/fuzzers/api_fuzzer_corpus/99789b6e9a0932dc95b686cf380872175603918f Binary files differnew file mode 100644 index 0000000000..fe02035525 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/99789b6e9a0932dc95b686cf380872175603918f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/99bb7db7244a6cb2bc0e6c275739f051f83b335a b/test/core/end2end/fuzzers/api_fuzzer_corpus/99bb7db7244a6cb2bc0e6c275739f051f83b335a Binary files differnew file mode 100644 index 0000000000..c14b6d8e45 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/99bb7db7244a6cb2bc0e6c275739f051f83b335a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9b922c2b47217bbc8c91fce66fc666d626cee86a b/test/core/end2end/fuzzers/api_fuzzer_corpus/9b922c2b47217bbc8c91fce66fc666d626cee86a Binary files differnew file mode 100644 index 0000000000..1295369cb7 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/9b922c2b47217bbc8c91fce66fc666d626cee86a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9c052499ada417d5038f8cc7da62e6acae9ba9ae b/test/core/end2end/fuzzers/api_fuzzer_corpus/9c052499ada417d5038f8cc7da62e6acae9ba9ae Binary files differnew file mode 100644 index 0000000000..ccee196ca3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/9c052499ada417d5038f8cc7da62e6acae9ba9ae diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9c78f9e53f09be45b2dac44dc8452880e7bed04b b/test/core/end2end/fuzzers/api_fuzzer_corpus/9c78f9e53f09be45b2dac44dc8452880e7bed04b Binary files differnew file mode 100644 index 0000000000..ae93ae8e84 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/9c78f9e53f09be45b2dac44dc8452880e7bed04b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9ca8f5c67662fa6726db2680978e443d80785a9f b/test/core/end2end/fuzzers/api_fuzzer_corpus/9ca8f5c67662fa6726db2680978e443d80785a9f Binary files differnew file mode 100644 index 0000000000..4954b7255c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/9ca8f5c67662fa6726db2680978e443d80785a9f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9cc4eeecbb2df8b130cca5e455a0f6b8a6e00660 b/test/core/end2end/fuzzers/api_fuzzer_corpus/9cc4eeecbb2df8b130cca5e455a0f6b8a6e00660 Binary files differnew file mode 100644 index 0000000000..86f991ed00 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/9cc4eeecbb2df8b130cca5e455a0f6b8a6e00660 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9d43466b9c4b8736cde82e337d9a9f881db82d11 b/test/core/end2end/fuzzers/api_fuzzer_corpus/9d43466b9c4b8736cde82e337d9a9f881db82d11 Binary files differnew file mode 100644 index 0000000000..065698222e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/9d43466b9c4b8736cde82e337d9a9f881db82d11 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9d5d9a28271a6d21850feb249cfe27aa0a31130c b/test/core/end2end/fuzzers/api_fuzzer_corpus/9d5d9a28271a6d21850feb249cfe27aa0a31130c Binary files differnew file mode 100644 index 0000000000..c99b47eeae --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/9d5d9a28271a6d21850feb249cfe27aa0a31130c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9e273a94bf3c60f1c7875874c81d0b9309428752 b/test/core/end2end/fuzzers/api_fuzzer_corpus/9e273a94bf3c60f1c7875874c81d0b9309428752 Binary files differnew file mode 100644 index 0000000000..8c91bb1f0d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/9e273a94bf3c60f1c7875874c81d0b9309428752 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/9f1c4ea38c9fb86a62693f202b26b1be3c7b2d37 b/test/core/end2end/fuzzers/api_fuzzer_corpus/9f1c4ea38c9fb86a62693f202b26b1be3c7b2d37 Binary files differnew file mode 100644 index 0000000000..8f11fb518f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/9f1c4ea38c9fb86a62693f202b26b1be3c7b2d37 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a1f59f79257ae56e6e6039d3fe838ca050f40385 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a1f59f79257ae56e6e6039d3fe838ca050f40385 Binary files differnew file mode 100644 index 0000000000..79bc6c9469 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a1f59f79257ae56e6e6039d3fe838ca050f40385 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a2180525f267c6d6b8f7501b100b97aef0d87f83 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a2180525f267c6d6b8f7501b100b97aef0d87f83 Binary files differnew file mode 100644 index 0000000000..4a6f0c64b5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a2180525f267c6d6b8f7501b100b97aef0d87f83 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a270e4304cc0dcd2c67b78c0495dedb10419f0af b/test/core/end2end/fuzzers/api_fuzzer_corpus/a270e4304cc0dcd2c67b78c0495dedb10419f0af Binary files differnew file mode 100644 index 0000000000..733f4cc62a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a270e4304cc0dcd2c67b78c0495dedb10419f0af diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a2d2b12575edfb559872c4f2ce63e95fdf68b774 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a2d2b12575edfb559872c4f2ce63e95fdf68b774 Binary files differnew file mode 100644 index 0000000000..b948759f44 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a2d2b12575edfb559872c4f2ce63e95fdf68b774 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a31a10de37eda6db8ecc2270b6a368985a38a44b b/test/core/end2end/fuzzers/api_fuzzer_corpus/a31a10de37eda6db8ecc2270b6a368985a38a44b Binary files differnew file mode 100644 index 0000000000..3df44fd224 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a31a10de37eda6db8ecc2270b6a368985a38a44b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a4da7f4642cfaf355445834075d3b4d04cf8b218 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a4da7f4642cfaf355445834075d3b4d04cf8b218 Binary files differnew file mode 100644 index 0000000000..5c306ad98f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a4da7f4642cfaf355445834075d3b4d04cf8b218 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a5be9b0f094ec76d5f082f4e06dafb5a01c066c1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a5be9b0f094ec76d5f082f4e06dafb5a01c066c1 Binary files differnew file mode 100644 index 0000000000..e64aae2e01 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a5be9b0f094ec76d5f082f4e06dafb5a01c066c1 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a62651154d1e5c33e154ea4b57f042be89feed9c b/test/core/end2end/fuzzers/api_fuzzer_corpus/a62651154d1e5c33e154ea4b57f042be89feed9c Binary files differnew file mode 100644 index 0000000000..56535f1ef5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a62651154d1e5c33e154ea4b57f042be89feed9c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a65bda38b60ae084a5dcc3b616660aa338feef17 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a65bda38b60ae084a5dcc3b616660aa338feef17 Binary files differnew file mode 100644 index 0000000000..cd7537592c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a65bda38b60ae084a5dcc3b616660aa338feef17 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a6a11f05565197ecb9cbf3a2ddf826564b425e74 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a6a11f05565197ecb9cbf3a2ddf826564b425e74 Binary files differnew file mode 100644 index 0000000000..2203ea0268 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a6a11f05565197ecb9cbf3a2ddf826564b425e74 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a71ab47d9ad32e10acc8b9772a331cae045fb424 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a71ab47d9ad32e10acc8b9772a331cae045fb424 Binary files differnew file mode 100644 index 0000000000..0dd072b2f5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a71ab47d9ad32e10acc8b9772a331cae045fb424 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a78bca1ef8829d720dd5dedac3a9d4d12684da34 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a78bca1ef8829d720dd5dedac3a9d4d12684da34 Binary files differnew file mode 100644 index 0000000000..322d4ae019 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a78bca1ef8829d720dd5dedac3a9d4d12684da34 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a881a2dcd16f595644c1543ccf047b7ae5bb7fa4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a881a2dcd16f595644c1543ccf047b7ae5bb7fa4 Binary files differnew file mode 100644 index 0000000000..cd6c17b10b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a881a2dcd16f595644c1543ccf047b7ae5bb7fa4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a8c0a166004ee637f22f5838960c8f4320738694 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a8c0a166004ee637f22f5838960c8f4320738694 Binary files differnew file mode 100644 index 0000000000..c654a53fcb --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a8c0a166004ee637f22f5838960c8f4320738694 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/a9e6f164e912d8964ae28f383dca6d980dcd4b94 b/test/core/end2end/fuzzers/api_fuzzer_corpus/a9e6f164e912d8964ae28f383dca6d980dcd4b94 Binary files differnew file mode 100644 index 0000000000..121daf9a6c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/a9e6f164e912d8964ae28f383dca6d980dcd4b94 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/aa05527f894960d22773d0e1c96e8ad9293e3910 b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa05527f894960d22773d0e1c96e8ad9293e3910 Binary files differnew file mode 100644 index 0000000000..6362b42992 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa05527f894960d22773d0e1c96e8ad9293e3910 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/aa103991d1d90adf0af592c050c1d39532690f73 b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa103991d1d90adf0af592c050c1d39532690f73 Binary files differnew file mode 100644 index 0000000000..abf072f382 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa103991d1d90adf0af592c050c1d39532690f73 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/aa26dbb6bb031702e07e82a70162de89e31dbb60 b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa26dbb6bb031702e07e82a70162de89e31dbb60 Binary files differnew file mode 100644 index 0000000000..e5a844355d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa26dbb6bb031702e07e82a70162de89e31dbb60 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/aa2b2a1240b9ddfba14035695084096f93a4eea5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa2b2a1240b9ddfba14035695084096f93a4eea5 Binary files differnew file mode 100644 index 0000000000..ba0fbcea36 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa2b2a1240b9ddfba14035695084096f93a4eea5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/aa58c60840b27f80a9779d2f4fc76154e12b7dc5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa58c60840b27f80a9779d2f4fc76154e12b7dc5 Binary files differnew file mode 100644 index 0000000000..6dafb63709 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa58c60840b27f80a9779d2f4fc76154e12b7dc5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/aa682b09b1e785fe0ed7edc6b14a4e8e5282e043 b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa682b09b1e785fe0ed7edc6b14a4e8e5282e043 Binary files differnew file mode 100644 index 0000000000..28028a3bbe --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa682b09b1e785fe0ed7edc6b14a4e8e5282e043 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/aa7e9b09e36bec073300d107795b7dc63eafbeb9 b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa7e9b09e36bec073300d107795b7dc63eafbeb9 Binary files differnew file mode 100644 index 0000000000..2209278cb9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/aa7e9b09e36bec073300d107795b7dc63eafbeb9 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/abd5de7b5e9218d19a57c47d2ccd6a1bc022c7fb b/test/core/end2end/fuzzers/api_fuzzer_corpus/abd5de7b5e9218d19a57c47d2ccd6a1bc022c7fb Binary files differnew file mode 100644 index 0000000000..5d8ebd3c76 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/abd5de7b5e9218d19a57c47d2ccd6a1bc022c7fb diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ac763d89466ebfad676e75be0076831c03fe2a5d b/test/core/end2end/fuzzers/api_fuzzer_corpus/ac763d89466ebfad676e75be0076831c03fe2a5d Binary files differnew file mode 100644 index 0000000000..64c9720c9b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ac763d89466ebfad676e75be0076831c03fe2a5d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/acb33ec3207ddd5f641f8f989faa888bcc70385c b/test/core/end2end/fuzzers/api_fuzzer_corpus/acb33ec3207ddd5f641f8f989faa888bcc70385c Binary files differnew file mode 100644 index 0000000000..4d14b561ff --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/acb33ec3207ddd5f641f8f989faa888bcc70385c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/adc78556e789c046d7f82b77e967a9e7fdf6cdac b/test/core/end2end/fuzzers/api_fuzzer_corpus/adc78556e789c046d7f82b77e967a9e7fdf6cdac Binary files differnew file mode 100644 index 0000000000..1934f3b981 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/adc78556e789c046d7f82b77e967a9e7fdf6cdac diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/adf88d50a752961142e1a3fc4eeba380e6089a5f b/test/core/end2end/fuzzers/api_fuzzer_corpus/adf88d50a752961142e1a3fc4eeba380e6089a5f Binary files differnew file mode 100644 index 0000000000..74f1f0c31a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/adf88d50a752961142e1a3fc4eeba380e6089a5f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/aed35edde0a0395829c43b45a34f537b9c6fc23a b/test/core/end2end/fuzzers/api_fuzzer_corpus/aed35edde0a0395829c43b45a34f537b9c6fc23a Binary files differnew file mode 100644 index 0000000000..1592e17701 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/aed35edde0a0395829c43b45a34f537b9c6fc23a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/af9d0bbc10db557c0ef9ab55a6f217b4f76a87db b/test/core/end2end/fuzzers/api_fuzzer_corpus/af9d0bbc10db557c0ef9ab55a6f217b4f76a87db Binary files differnew file mode 100644 index 0000000000..de43084835 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/af9d0bbc10db557c0ef9ab55a6f217b4f76a87db diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b09e64aa807db006a219bd1b9faf1a2e00dc6d33 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b09e64aa807db006a219bd1b9faf1a2e00dc6d33 Binary files differnew file mode 100644 index 0000000000..50548fa35d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b09e64aa807db006a219bd1b9faf1a2e00dc6d33 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b0c9bc430c79f064b61d8cad076b072c9c014804 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b0c9bc430c79f064b61d8cad076b072c9c014804 Binary files differnew file mode 100644 index 0000000000..3b751711e7 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b0c9bc430c79f064b61d8cad076b072c9c014804 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b165523f699e6ae9b2ad15873b9d56465d1af546 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b165523f699e6ae9b2ad15873b9d56465d1af546 Binary files differnew file mode 100644 index 0000000000..b0b7452924 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b165523f699e6ae9b2ad15873b9d56465d1af546 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b233e6287f4208a2ae8f89fe25caf0a33b7b4e51 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b233e6287f4208a2ae8f89fe25caf0a33b7b4e51 Binary files differnew file mode 100644 index 0000000000..6ff2926ccf --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b233e6287f4208a2ae8f89fe25caf0a33b7b4e51 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b2a5ec3ef40c68d594638218e3c943a479f82215 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b2a5ec3ef40c68d594638218e3c943a479f82215 Binary files differnew file mode 100644 index 0000000000..ac2b154407 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b2a5ec3ef40c68d594638218e3c943a479f82215 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b36c3e5841c6aed7b0d439bd3b9c6d922d56c70b b/test/core/end2end/fuzzers/api_fuzzer_corpus/b36c3e5841c6aed7b0d439bd3b9c6d922d56c70b Binary files differnew file mode 100644 index 0000000000..4c5fc29e71 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b36c3e5841c6aed7b0d439bd3b9c6d922d56c70b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b39f27387a256019038cddb91f65651c01afb825 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b39f27387a256019038cddb91f65651c01afb825 Binary files differnew file mode 100644 index 0000000000..a1e335bd01 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b39f27387a256019038cddb91f65651c01afb825 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b4b0f04d9a771ea9575d9cc484947fcadf4ef5bd b/test/core/end2end/fuzzers/api_fuzzer_corpus/b4b0f04d9a771ea9575d9cc484947fcadf4ef5bd Binary files differnew file mode 100644 index 0000000000..02e99acac8 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b4b0f04d9a771ea9575d9cc484947fcadf4ef5bd diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b501cbf4c085ce0b75e4031810bf99f91905fb06 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b501cbf4c085ce0b75e4031810bf99f91905fb06 Binary files differnew file mode 100644 index 0000000000..6c4e46a26f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b501cbf4c085ce0b75e4031810bf99f91905fb06 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b53a90f0ad5e8026e0354e149ed8b4782fda00ad b/test/core/end2end/fuzzers/api_fuzzer_corpus/b53a90f0ad5e8026e0354e149ed8b4782fda00ad Binary files differnew file mode 100644 index 0000000000..59ba6f05ab --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b53a90f0ad5e8026e0354e149ed8b4782fda00ad diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b55d66dbf3f2b795062e5a53379c2f63cab17062 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b55d66dbf3f2b795062e5a53379c2f63cab17062 Binary files differnew file mode 100644 index 0000000000..c0464c3f20 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b55d66dbf3f2b795062e5a53379c2f63cab17062 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b6f721156f8dc6a353555929e459e61bab8b394a b/test/core/end2end/fuzzers/api_fuzzer_corpus/b6f721156f8dc6a353555929e459e61bab8b394a Binary files differnew file mode 100644 index 0000000000..43986eae54 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b6f721156f8dc6a353555929e459e61bab8b394a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b8845fbdf002c64053d7fa3e60add56f0a030992 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b8845fbdf002c64053d7fa3e60add56f0a030992 Binary files differnew file mode 100644 index 0000000000..b6823a113a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b8845fbdf002c64053d7fa3e60add56f0a030992 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b88619bb22a3b2585cad3ace194fcdd8c6b63104 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b88619bb22a3b2585cad3ace194fcdd8c6b63104 Binary files differnew file mode 100644 index 0000000000..903049d9a9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b88619bb22a3b2585cad3ace194fcdd8c6b63104 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b8bc377e53ca54ae4e30f437b69e270040c35f65 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b8bc377e53ca54ae4e30f437b69e270040c35f65 Binary files differnew file mode 100644 index 0000000000..44934bbb99 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b8bc377e53ca54ae4e30f437b69e270040c35f65 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b92b1c5e0dba009a9516e7185f5df019c62c5cc9 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b92b1c5e0dba009a9516e7185f5df019c62c5cc9 Binary files differnew file mode 100644 index 0000000000..3d542f38ec --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b92b1c5e0dba009a9516e7185f5df019c62c5cc9 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b94e1db2cd1236075bb8772b72c64991d442e584 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b94e1db2cd1236075bb8772b72c64991d442e584 Binary files differnew file mode 100644 index 0000000000..154e8b8d5f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b94e1db2cd1236075bb8772b72c64991d442e584 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b9a7faa77ddf3a7e206e4d06f5d9d8de7d9c7df8 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b9a7faa77ddf3a7e206e4d06f5d9d8de7d9c7df8 Binary files differnew file mode 100644 index 0000000000..e17d915c54 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b9a7faa77ddf3a7e206e4d06f5d9d8de7d9c7df8 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/b9d799eb148e4d8a8a235e385ca8302a8acc3896 b/test/core/end2end/fuzzers/api_fuzzer_corpus/b9d799eb148e4d8a8a235e385ca8302a8acc3896 Binary files differnew file mode 100644 index 0000000000..fb5a09d134 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/b9d799eb148e4d8a8a235e385ca8302a8acc3896 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/baee7b89cd2017f450c37137628688f25979b3bb b/test/core/end2end/fuzzers/api_fuzzer_corpus/baee7b89cd2017f450c37137628688f25979b3bb Binary files differnew file mode 100644 index 0000000000..aea662cd91 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/baee7b89cd2017f450c37137628688f25979b3bb diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/baf7b33805daf027e037e406d3442b3444108ac0 b/test/core/end2end/fuzzers/api_fuzzer_corpus/baf7b33805daf027e037e406d3442b3444108ac0 Binary files differnew file mode 100644 index 0000000000..230c450902 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/baf7b33805daf027e037e406d3442b3444108ac0 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/bb426bb115461f351e57f64c0378e331f74ed5fc b/test/core/end2end/fuzzers/api_fuzzer_corpus/bb426bb115461f351e57f64c0378e331f74ed5fc Binary files differnew file mode 100644 index 0000000000..12c6be1a45 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/bb426bb115461f351e57f64c0378e331f74ed5fc diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/bbb2429766a7c4ef9cb7110d567fd48cd6507dc5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/bbb2429766a7c4ef9cb7110d567fd48cd6507dc5 Binary files differnew file mode 100644 index 0000000000..017a4775f8 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/bbb2429766a7c4ef9cb7110d567fd48cd6507dc5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/bc330aa616a792ff22a8c7428dcdb4d99accbe4b b/test/core/end2end/fuzzers/api_fuzzer_corpus/bc330aa616a792ff22a8c7428dcdb4d99accbe4b Binary files differnew file mode 100644 index 0000000000..a046eae7b3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/bc330aa616a792ff22a8c7428dcdb4d99accbe4b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/bc42e00a7d67fb68df3cb5893908c04884b6ad5e b/test/core/end2end/fuzzers/api_fuzzer_corpus/bc42e00a7d67fb68df3cb5893908c04884b6ad5e Binary files differnew file mode 100644 index 0000000000..af4a3481d8 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/bc42e00a7d67fb68df3cb5893908c04884b6ad5e diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/bcc655cbb7334db02fc7fe9d29bd49fd6ee4ee91 b/test/core/end2end/fuzzers/api_fuzzer_corpus/bcc655cbb7334db02fc7fe9d29bd49fd6ee4ee91 Binary files differnew file mode 100644 index 0000000000..7d914ef5ea --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/bcc655cbb7334db02fc7fe9d29bd49fd6ee4ee91 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/bd4f7f4d43ceaec0429ddc248cd438284813cc64 b/test/core/end2end/fuzzers/api_fuzzer_corpus/bd4f7f4d43ceaec0429ddc248cd438284813cc64 Binary files differnew file mode 100644 index 0000000000..f5098854fb --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/bd4f7f4d43ceaec0429ddc248cd438284813cc64 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/bed4e119b86e8dd0a6c60cb96cc2f9e66d0a8857 b/test/core/end2end/fuzzers/api_fuzzer_corpus/bed4e119b86e8dd0a6c60cb96cc2f9e66d0a8857 Binary files differnew file mode 100644 index 0000000000..ad1a13706c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/bed4e119b86e8dd0a6c60cb96cc2f9e66d0a8857 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/bfafd0d497ccd035d6ef1478509c93a9d2443513 b/test/core/end2end/fuzzers/api_fuzzer_corpus/bfafd0d497ccd035d6ef1478509c93a9d2443513 Binary files differnew file mode 100644 index 0000000000..579f28c1ac --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/bfafd0d497ccd035d6ef1478509c93a9d2443513 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/bfb3ae60341e80c10de105fa0f9a01f134033225 b/test/core/end2end/fuzzers/api_fuzzer_corpus/bfb3ae60341e80c10de105fa0f9a01f134033225 Binary files differnew file mode 100644 index 0000000000..c5fdc4cf40 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/bfb3ae60341e80c10de105fa0f9a01f134033225 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c1e5524945b3e3eabedfbb675be9e9ea99a36b94 b/test/core/end2end/fuzzers/api_fuzzer_corpus/c1e5524945b3e3eabedfbb675be9e9ea99a36b94 Binary files differnew file mode 100644 index 0000000000..12bb8f2d64 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c1e5524945b3e3eabedfbb675be9e9ea99a36b94 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c29f3256e632a713aeb3ef647fff014a9be01a8d b/test/core/end2end/fuzzers/api_fuzzer_corpus/c29f3256e632a713aeb3ef647fff014a9be01a8d Binary files differnew file mode 100644 index 0000000000..000e18c44b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c29f3256e632a713aeb3ef647fff014a9be01a8d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c41f43520da236f84dd0e2157644d316ca6fac37 b/test/core/end2end/fuzzers/api_fuzzer_corpus/c41f43520da236f84dd0e2157644d316ca6fac37 Binary files differnew file mode 100644 index 0000000000..17026cce93 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c41f43520da236f84dd0e2157644d316ca6fac37 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c5535d6d801d315d78792c9956a82711d0d5a803 b/test/core/end2end/fuzzers/api_fuzzer_corpus/c5535d6d801d315d78792c9956a82711d0d5a803 Binary files differnew file mode 100644 index 0000000000..1f779a6356 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c5535d6d801d315d78792c9956a82711d0d5a803 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c5cd7af16e7bc0049445d5a0b92a3d4b7e5e3533 b/test/core/end2end/fuzzers/api_fuzzer_corpus/c5cd7af16e7bc0049445d5a0b92a3d4b7e5e3533 Binary files differnew file mode 100644 index 0000000000..c8fca17ad3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c5cd7af16e7bc0049445d5a0b92a3d4b7e5e3533 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c6ec8562082eda6ea9ae1cc27f33b920b93589e4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/c6ec8562082eda6ea9ae1cc27f33b920b93589e4 Binary files differnew file mode 100644 index 0000000000..1b8ebd047b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c6ec8562082eda6ea9ae1cc27f33b920b93589e4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c6f9e7ce30494ccbf3a1f49bed7107d976e3cc4e b/test/core/end2end/fuzzers/api_fuzzer_corpus/c6f9e7ce30494ccbf3a1f49bed7107d976e3cc4e Binary files differnew file mode 100644 index 0000000000..0091fd27d3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c6f9e7ce30494ccbf3a1f49bed7107d976e3cc4e diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c71747c667c94062a03ec0f0468212e7ac222c57 b/test/core/end2end/fuzzers/api_fuzzer_corpus/c71747c667c94062a03ec0f0468212e7ac222c57 Binary files differnew file mode 100644 index 0000000000..cde0a42fa3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c71747c667c94062a03ec0f0468212e7ac222c57 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c767f1416feb8d7a2899ab276a4846e10f59531c b/test/core/end2end/fuzzers/api_fuzzer_corpus/c767f1416feb8d7a2899ab276a4846e10f59531c Binary files differnew file mode 100644 index 0000000000..7c1932f552 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c767f1416feb8d7a2899ab276a4846e10f59531c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c8b448134c9d165968599402c9633719573afd8d b/test/core/end2end/fuzzers/api_fuzzer_corpus/c8b448134c9d165968599402c9633719573afd8d Binary files differnew file mode 100644 index 0000000000..c13b0965b6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c8b448134c9d165968599402c9633719573afd8d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c955c8f169185554e8e1d45ded89db29c3164917 b/test/core/end2end/fuzzers/api_fuzzer_corpus/c955c8f169185554e8e1d45ded89db29c3164917 Binary files differnew file mode 100644 index 0000000000..0eb3d9c1f5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c955c8f169185554e8e1d45ded89db29c3164917 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/c9f81864507c264369dd22c72aeb16f1cb1742b0 b/test/core/end2end/fuzzers/api_fuzzer_corpus/c9f81864507c264369dd22c72aeb16f1cb1742b0 Binary files differnew file mode 100644 index 0000000000..0331bad1a6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/c9f81864507c264369dd22c72aeb16f1cb1742b0 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/cb4f23427bca81db8ccf5f03bdb0c60418a20a74 b/test/core/end2end/fuzzers/api_fuzzer_corpus/cb4f23427bca81db8ccf5f03bdb0c60418a20a74 Binary files differnew file mode 100644 index 0000000000..39eb594be2 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/cb4f23427bca81db8ccf5f03bdb0c60418a20a74 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/cce1a22e2c3532ddb85af19d2f17cc7a11ca1050 b/test/core/end2end/fuzzers/api_fuzzer_corpus/cce1a22e2c3532ddb85af19d2f17cc7a11ca1050 Binary files differnew file mode 100644 index 0000000000..f2685ffe9c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/cce1a22e2c3532ddb85af19d2f17cc7a11ca1050 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/cd2b1fed5910041aca30e39210ee21d4ebb80469 b/test/core/end2end/fuzzers/api_fuzzer_corpus/cd2b1fed5910041aca30e39210ee21d4ebb80469 Binary files differnew file mode 100644 index 0000000000..92e009a4dc --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/cd2b1fed5910041aca30e39210ee21d4ebb80469 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/cd4ccfa79f65f31716296e690f3a76007edde2e3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/cd4ccfa79f65f31716296e690f3a76007edde2e3 Binary files differnew file mode 100644 index 0000000000..2a19daf6c7 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/cd4ccfa79f65f31716296e690f3a76007edde2e3 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ce4a157481d32f9c2ec106f257278d3159e6bd21 b/test/core/end2end/fuzzers/api_fuzzer_corpus/ce4a157481d32f9c2ec106f257278d3159e6bd21 Binary files differnew file mode 100644 index 0000000000..dc0a837819 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ce4a157481d32f9c2ec106f257278d3159e6bd21 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ceb98039ba87c5c326c904f275490b25c7d90f1c b/test/core/end2end/fuzzers/api_fuzzer_corpus/ceb98039ba87c5c326c904f275490b25c7d90f1c Binary files differnew file mode 100644 index 0000000000..e6ac3a837a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ceb98039ba87c5c326c904f275490b25c7d90f1c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/cee29e303670fdd259d375da8345d6e49ba971b4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/cee29e303670fdd259d375da8345d6e49ba971b4 Binary files differnew file mode 100644 index 0000000000..246dec486a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/cee29e303670fdd259d375da8345d6e49ba971b4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-177af631195e806f4056847cea4d09b5eb28cf8a b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-177af631195e806f4056847cea4d09b5eb28cf8a Binary files differnew file mode 100644 index 0000000000..344825c571 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-177af631195e806f4056847cea4d09b5eb28cf8a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-373224be81ff98db60e9f81536f16a9ef92792d5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-373224be81ff98db60e9f81536f16a9ef92792d5 Binary files differnew file mode 100644 index 0000000000..bebaf9c8ba --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-373224be81ff98db60e9f81536f16a9ef92792d5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-59b587d15c0bcdb985417cd7a133cecfcc232698 b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-59b587d15c0bcdb985417cd7a133cecfcc232698 Binary files differnew file mode 100644 index 0000000000..3fa801139e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-59b587d15c0bcdb985417cd7a133cecfcc232698 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-5d73de981fb75553a7b2606e111716ee9f2af844 b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-5d73de981fb75553a7b2606e111716ee9f2af844 Binary files differnew file mode 100644 index 0000000000..6c25c18eae --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-5d73de981fb75553a7b2606e111716ee9f2af844 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-5fc15c2ee9c70fd834588cbd256cfb52cdcbcb8d b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-5fc15c2ee9c70fd834588cbd256cfb52cdcbcb8d Binary files differnew file mode 100644 index 0000000000..ce2ffbb6d5 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-5fc15c2ee9c70fd834588cbd256cfb52cdcbcb8d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-60a3f7ed4abddaa6a7c837ace86d048fa15e288b b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-60a3f7ed4abddaa6a7c837ace86d048fa15e288b Binary files differnew file mode 100644 index 0000000000..3e441c97c7 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-60a3f7ed4abddaa6a7c837ace86d048fa15e288b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-b208a1eb5ef9f229f309492329323f485768fa74 b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-b208a1eb5ef9f229f309492329323f485768fa74 Binary files differnew file mode 100644 index 0000000000..e7a6aedd9f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-b208a1eb5ef9f229f309492329323f485768fa74 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-b5ae6881c767a7769bb957ac379f22aafe4ef05e b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-b5ae6881c767a7769bb957ac379f22aafe4ef05e Binary files differnew file mode 100644 index 0000000000..3518dffafc --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/crash-b5ae6881c767a7769bb957ac379f22aafe4ef05e 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/d0a8deab4d26bc005d022184c311c1ce4d5327bb b/test/core/end2end/fuzzers/api_fuzzer_corpus/d0a8deab4d26bc005d022184c311c1ce4d5327bb Binary files differnew file mode 100644 index 0000000000..e6490ffa1f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d0a8deab4d26bc005d022184c311c1ce4d5327bb diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d0d622fa3916e800e959a3fc2c90e213d518e5f4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/d0d622fa3916e800e959a3fc2c90e213d518e5f4 Binary files differnew file mode 100644 index 0000000000..0de93e6a0d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d0d622fa3916e800e959a3fc2c90e213d518e5f4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d123c89b3cafd995bf401032699fc7dba60f8de4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/d123c89b3cafd995bf401032699fc7dba60f8de4 Binary files differnew file mode 100644 index 0000000000..0c90e71f90 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d123c89b3cafd995bf401032699fc7dba60f8de4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d263d6004c2cc33cd9d157dd31ff604870c4d6fb b/test/core/end2end/fuzzers/api_fuzzer_corpus/d263d6004c2cc33cd9d157dd31ff604870c4d6fb Binary files differnew file mode 100644 index 0000000000..ca1f987170 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d263d6004c2cc33cd9d157dd31ff604870c4d6fb diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d29859445bfeff04ca22b20408f9aa0e2e161abc b/test/core/end2end/fuzzers/api_fuzzer_corpus/d29859445bfeff04ca22b20408f9aa0e2e161abc Binary files differnew file mode 100644 index 0000000000..9177f89f7a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d29859445bfeff04ca22b20408f9aa0e2e161abc diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d2ba1c23045223aa6f4c107f91d57786befae604 b/test/core/end2end/fuzzers/api_fuzzer_corpus/d2ba1c23045223aa6f4c107f91d57786befae604 Binary files differnew file mode 100644 index 0000000000..94600a7167 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d2ba1c23045223aa6f4c107f91d57786befae604 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d2e66d1fdf0110212c632268aec5b06130db3e21 b/test/core/end2end/fuzzers/api_fuzzer_corpus/d2e66d1fdf0110212c632268aec5b06130db3e21 Binary files differnew file mode 100644 index 0000000000..e4fec6c9d4 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d2e66d1fdf0110212c632268aec5b06130db3e21 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d2f7c85e3c87ad5b71ad423aa4a9d97a8191d867 b/test/core/end2end/fuzzers/api_fuzzer_corpus/d2f7c85e3c87ad5b71ad423aa4a9d97a8191d867 Binary files differnew file mode 100644 index 0000000000..4b5d54318f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d2f7c85e3c87ad5b71ad423aa4a9d97a8191d867 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d4bd740db31b0e9925ce331c9c7d2fae5c1d15f2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/d4bd740db31b0e9925ce331c9c7d2fae5c1d15f2 Binary files differnew file mode 100644 index 0000000000..91e28514f0 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d4bd740db31b0e9925ce331c9c7d2fae5c1d15f2 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d5dad7a599e22cff371d595a5014475301670892 b/test/core/end2end/fuzzers/api_fuzzer_corpus/d5dad7a599e22cff371d595a5014475301670892 Binary files differnew file mode 100644 index 0000000000..20b04ddb83 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d5dad7a599e22cff371d595a5014475301670892 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d6b689f1b878d6914ced5d24f21c599c203594d4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/d6b689f1b878d6914ced5d24f21c599c203594d4 Binary files differnew file mode 100644 index 0000000000..b26a7a7b76 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d6b689f1b878d6914ced5d24f21c599c203594d4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/d716fb79cd7dd78d2ff66dc8a0e2acef9a93f98a b/test/core/end2end/fuzzers/api_fuzzer_corpus/d716fb79cd7dd78d2ff66dc8a0e2acef9a93f98a Binary files differnew file mode 100644 index 0000000000..1006f60613 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/d716fb79cd7dd78d2ff66dc8a0e2acef9a93f98a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/da57f06258c4f0de07611263dfba8be669dd780c b/test/core/end2end/fuzzers/api_fuzzer_corpus/da57f06258c4f0de07611263dfba8be669dd780c Binary files differnew file mode 100644 index 0000000000..c6435f7f95 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/da57f06258c4f0de07611263dfba8be669dd780c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/da97ec2d11daf27fe924513c463810c867b88983 b/test/core/end2end/fuzzers/api_fuzzer_corpus/da97ec2d11daf27fe924513c463810c867b88983 Binary files differnew file mode 100644 index 0000000000..b293ff0565 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/da97ec2d11daf27fe924513c463810c867b88983 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/daed40229642eab256927f3bfb0288e036eab89f b/test/core/end2end/fuzzers/api_fuzzer_corpus/daed40229642eab256927f3bfb0288e036eab89f Binary files differnew file mode 100644 index 0000000000..a9903db045 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/daed40229642eab256927f3bfb0288e036eab89f diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/db25df0fa146d02874114b8605000e0135ff12dd b/test/core/end2end/fuzzers/api_fuzzer_corpus/db25df0fa146d02874114b8605000e0135ff12dd Binary files differnew file mode 100644 index 0000000000..841f40f342 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/db25df0fa146d02874114b8605000e0135ff12dd diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/dcaa24f054af09a755c794ac4c3485ee682437a9 b/test/core/end2end/fuzzers/api_fuzzer_corpus/dcaa24f054af09a755c794ac4c3485ee682437a9 Binary files differnew file mode 100644 index 0000000000..975d9460e6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/dcaa24f054af09a755c794ac4c3485ee682437a9 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/dcc039d81106cd60cd611ff540d4669ebd10fe68 b/test/core/end2end/fuzzers/api_fuzzer_corpus/dcc039d81106cd60cd611ff540d4669ebd10fe68 Binary files differnew file mode 100644 index 0000000000..8c1536af0d --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/dcc039d81106cd60cd611ff540d4669ebd10fe68 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/dd229da166c3bec675e882d17092238cf7d245f3 b/test/core/end2end/fuzzers/api_fuzzer_corpus/dd229da166c3bec675e882d17092238cf7d245f3 Binary files differnew file mode 100644 index 0000000000..2a994d9dda --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/dd229da166c3bec675e882d17092238cf7d245f3 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/dda7f9e8860f0e132312f57e3640402f33df308a b/test/core/end2end/fuzzers/api_fuzzer_corpus/dda7f9e8860f0e132312f57e3640402f33df308a Binary files differnew file mode 100644 index 0000000000..f530f36b97 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/dda7f9e8860f0e132312f57e3640402f33df308a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ddd34e967b1460902af2d01818605e208c5c7524 b/test/core/end2end/fuzzers/api_fuzzer_corpus/ddd34e967b1460902af2d01818605e208c5c7524 Binary files differnew file mode 100644 index 0000000000..c3d7d78386 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ddd34e967b1460902af2d01818605e208c5c7524 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/de45c55043f63ec680e990b1edf1f0cc60ebbf4e b/test/core/end2end/fuzzers/api_fuzzer_corpus/de45c55043f63ec680e990b1edf1f0cc60ebbf4e Binary files differnew file mode 100644 index 0000000000..fab7ebbb2f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/de45c55043f63ec680e990b1edf1f0cc60ebbf4e diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/df29cf0d3cd5cfd27a98b506fffee64476398bba b/test/core/end2end/fuzzers/api_fuzzer_corpus/df29cf0d3cd5cfd27a98b506fffee64476398bba Binary files differnew file mode 100644 index 0000000000..d40b23c032 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/df29cf0d3cd5cfd27a98b506fffee64476398bba diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e13344aeec0694c50eed41ae1b78e6d2ac4a4c6c b/test/core/end2end/fuzzers/api_fuzzer_corpus/e13344aeec0694c50eed41ae1b78e6d2ac4a4c6c Binary files differnew file mode 100644 index 0000000000..3be56d333e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e13344aeec0694c50eed41ae1b78e6d2ac4a4c6c diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e28ffd8c2816f12f6395805199c792d1718191df b/test/core/end2end/fuzzers/api_fuzzer_corpus/e28ffd8c2816f12f6395805199c792d1718191df Binary files differnew file mode 100644 index 0000000000..a867a8b0be --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e28ffd8c2816f12f6395805199c792d1718191df diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e37b4c7b64414d4705d934f8a723a50dcbf42571 b/test/core/end2end/fuzzers/api_fuzzer_corpus/e37b4c7b64414d4705d934f8a723a50dcbf42571 Binary files differnew file mode 100644 index 0000000000..bc13609991 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e37b4c7b64414d4705d934f8a723a50dcbf42571 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e4068f14a046ce3ee7f1920cbd210b6e876c07ec b/test/core/end2end/fuzzers/api_fuzzer_corpus/e4068f14a046ce3ee7f1920cbd210b6e876c07ec Binary files differnew file mode 100644 index 0000000000..6ddb7d618c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e4068f14a046ce3ee7f1920cbd210b6e876c07ec diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e452ab01690d7e326f5ef52f4a312d066c087a24 b/test/core/end2end/fuzzers/api_fuzzer_corpus/e452ab01690d7e326f5ef52f4a312d066c087a24 Binary files differnew file mode 100644 index 0000000000..ff74e958c6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e452ab01690d7e326f5ef52f4a312d066c087a24 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e52ac2e3cad2e544488a01822115cb37d10a76ce b/test/core/end2end/fuzzers/api_fuzzer_corpus/e52ac2e3cad2e544488a01822115cb37d10a76ce Binary files differnew file mode 100644 index 0000000000..b3bb2405d8 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e52ac2e3cad2e544488a01822115cb37d10a76ce diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e609da99f76fa36e4b9060650cbc3597af458b01 b/test/core/end2end/fuzzers/api_fuzzer_corpus/e609da99f76fa36e4b9060650cbc3597af458b01 Binary files differnew file mode 100644 index 0000000000..9dac9955f6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e609da99f76fa36e4b9060650cbc3597af458b01 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e6b74f64e8bdfdf98177aee58b8729ff2aa7ffb2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/e6b74f64e8bdfdf98177aee58b8729ff2aa7ffb2 Binary files differnew file mode 100644 index 0000000000..cc011513d3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e6b74f64e8bdfdf98177aee58b8729ff2aa7ffb2 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e709e8861c09e29cdae73e337587a63fb0ccf76d b/test/core/end2end/fuzzers/api_fuzzer_corpus/e709e8861c09e29cdae73e337587a63fb0ccf76d Binary files differnew file mode 100644 index 0000000000..a481542791 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e709e8861c09e29cdae73e337587a63fb0ccf76d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e839090caa1b1bfa8898eea683f5d5c9f1ed6dd1 b/test/core/end2end/fuzzers/api_fuzzer_corpus/e839090caa1b1bfa8898eea683f5d5c9f1ed6dd1 Binary files differnew file mode 100644 index 0000000000..af332baf9a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e839090caa1b1bfa8898eea683f5d5c9f1ed6dd1 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e97beccbdbb6e29eb476efec4ea2c96c310e6615 b/test/core/end2end/fuzzers/api_fuzzer_corpus/e97beccbdbb6e29eb476efec4ea2c96c310e6615 Binary files differnew file mode 100644 index 0000000000..1c33e4fd5a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e97beccbdbb6e29eb476efec4ea2c96c310e6615 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e9932127668f9de0743fc639dca31acedbfc68fd b/test/core/end2end/fuzzers/api_fuzzer_corpus/e9932127668f9de0743fc639dca31acedbfc68fd Binary files differnew file mode 100644 index 0000000000..62fe8fd03e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e9932127668f9de0743fc639dca31acedbfc68fd diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/e9d470cdf421f6c6c9eefd7f84bd09df6a8994b2 b/test/core/end2end/fuzzers/api_fuzzer_corpus/e9d470cdf421f6c6c9eefd7f84bd09df6a8994b2 Binary files differnew file mode 100644 index 0000000000..3d19da0697 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/e9d470cdf421f6c6c9eefd7f84bd09df6a8994b2 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/eacf4905e489566a3e5fcaaeac9fe91cbf916e06 b/test/core/end2end/fuzzers/api_fuzzer_corpus/eacf4905e489566a3e5fcaaeac9fe91cbf916e06 Binary files differnew file mode 100644 index 0000000000..44f3e00f98 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/eacf4905e489566a3e5fcaaeac9fe91cbf916e06 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/eaddce3919388311104c50b9089461ff59c8ac14 b/test/core/end2end/fuzzers/api_fuzzer_corpus/eaddce3919388311104c50b9089461ff59c8ac14 Binary files differnew file mode 100644 index 0000000000..d81c34e934 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/eaddce3919388311104c50b9089461ff59c8ac14 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ec55cbebe6db506acf7af9e5d26386630319623d b/test/core/end2end/fuzzers/api_fuzzer_corpus/ec55cbebe6db506acf7af9e5d26386630319623d Binary files differnew file mode 100644 index 0000000000..14ebab0cf3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ec55cbebe6db506acf7af9e5d26386630319623d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ec823f4018389e64a99f6580277fba28df6bd136 b/test/core/end2end/fuzzers/api_fuzzer_corpus/ec823f4018389e64a99f6580277fba28df6bd136 Binary files differnew file mode 100644 index 0000000000..2e6d409d39 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ec823f4018389e64a99f6580277fba28df6bd136 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ed47f70f76dadbb6744ede3eb7016f585c9fe59a b/test/core/end2end/fuzzers/api_fuzzer_corpus/ed47f70f76dadbb6744ede3eb7016f585c9fe59a Binary files differnew file mode 100644 index 0000000000..be50868c61 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ed47f70f76dadbb6744ede3eb7016f585c9fe59a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ed7d0b055e59602ec752162db7afc2b36ac7800a b/test/core/end2end/fuzzers/api_fuzzer_corpus/ed7d0b055e59602ec752162db7afc2b36ac7800a Binary files differnew file mode 100644 index 0000000000..73c5db3098 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ed7d0b055e59602ec752162db7afc2b36ac7800a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/edecc59c5809796f266abd8df4d5ecf6aae304ca b/test/core/end2end/fuzzers/api_fuzzer_corpus/edecc59c5809796f266abd8df4d5ecf6aae304ca Binary files differnew file mode 100644 index 0000000000..805106a4fc --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/edecc59c5809796f266abd8df4d5ecf6aae304ca diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ee2c1ac1e668f22836cf25a59495e778b0e2c7a8 b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee2c1ac1e668f22836cf25a59495e778b0e2c7a8 Binary files differnew file mode 100644 index 0000000000..f1990ac231 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee2c1ac1e668f22836cf25a59495e778b0e2c7a8 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ee42f876c500996016a9f4a989147e5c2b5019fa b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee42f876c500996016a9f4a989147e5c2b5019fa Binary files differnew file mode 100644 index 0000000000..79770813f9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee42f876c500996016a9f4a989147e5c2b5019fa diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ee6855178435d2046d8763ecae46e1e0a71a95f4 b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee6855178435d2046d8763ecae46e1e0a71a95f4 Binary files differnew file mode 100644 index 0000000000..6badaf36dc --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee6855178435d2046d8763ecae46e1e0a71a95f4 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ee90aa84710c6a218a84b49ca6bc5d0e7a324220 b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee90aa84710c6a218a84b49ca6bc5d0e7a324220 Binary files differnew file mode 100644 index 0000000000..095b25464a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ee90aa84710c6a218a84b49ca6bc5d0e7a324220 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/eeb310d91038cb02862e187e68c5d6578233485b b/test/core/end2end/fuzzers/api_fuzzer_corpus/eeb310d91038cb02862e187e68c5d6578233485b Binary files differnew file mode 100644 index 0000000000..1b05cfb036 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/eeb310d91038cb02862e187e68c5d6578233485b diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ef20d859b09ca00a80782df7097881ec4299cd25 b/test/core/end2end/fuzzers/api_fuzzer_corpus/ef20d859b09ca00a80782df7097881ec4299cd25 Binary files differnew file mode 100644 index 0000000000..f4077be7de --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ef20d859b09ca00a80782df7097881ec4299cd25 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/ef24beeeff80ec8ad728919794e9de4a06cf7daa b/test/core/end2end/fuzzers/api_fuzzer_corpus/ef24beeeff80ec8ad728919794e9de4a06cf7daa Binary files differnew file mode 100644 index 0000000000..39b8ac4cc3 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/ef24beeeff80ec8ad728919794e9de4a06cf7daa diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/efa40f9e7f8a5ba4649dbad1a66ff9cc6bc699b8 b/test/core/end2end/fuzzers/api_fuzzer_corpus/efa40f9e7f8a5ba4649dbad1a66ff9cc6bc699b8 Binary files differnew file mode 100644 index 0000000000..8927909b7c --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/efa40f9e7f8a5ba4649dbad1a66ff9cc6bc699b8 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f07bc2907c95f2aeb79ca60e2ad826e13b848f45 b/test/core/end2end/fuzzers/api_fuzzer_corpus/f07bc2907c95f2aeb79ca60e2ad826e13b848f45 Binary files differnew file mode 100644 index 0000000000..313d456262 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f07bc2907c95f2aeb79ca60e2ad826e13b848f45 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f09c5cabe569b5c22a16d7d584074d54d9343edc b/test/core/end2end/fuzzers/api_fuzzer_corpus/f09c5cabe569b5c22a16d7d584074d54d9343edc Binary files differnew file mode 100644 index 0000000000..58644e12ae --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f09c5cabe569b5c22a16d7d584074d54d9343edc diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f1b2889ae7091d6a14332343fe7a2bffd81039a7 b/test/core/end2end/fuzzers/api_fuzzer_corpus/f1b2889ae7091d6a14332343fe7a2bffd81039a7 Binary files differnew file mode 100644 index 0000000000..e7f28070f6 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f1b2889ae7091d6a14332343fe7a2bffd81039a7 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f2b838edb5715e9f0f73897ed74eddaede87a43a b/test/core/end2end/fuzzers/api_fuzzer_corpus/f2b838edb5715e9f0f73897ed74eddaede87a43a Binary files differnew file mode 100644 index 0000000000..bcffbae085 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f2b838edb5715e9f0f73897ed74eddaede87a43a diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f3b3769d79f1d9586c575c27dff353f343ceacaf b/test/core/end2end/fuzzers/api_fuzzer_corpus/f3b3769d79f1d9586c575c27dff353f343ceacaf Binary files differnew file mode 100644 index 0000000000..034f1983a9 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f3b3769d79f1d9586c575c27dff353f343ceacaf diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f3cad6a2ea4ebfd40568d4992d68784e82de2b20 b/test/core/end2end/fuzzers/api_fuzzer_corpus/f3cad6a2ea4ebfd40568d4992d68784e82de2b20 Binary files differnew file mode 100644 index 0000000000..7a5e86bda7 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f3cad6a2ea4ebfd40568d4992d68784e82de2b20 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f503f8d526eaec9bab6cae97d09207deefa85d8d b/test/core/end2end/fuzzers/api_fuzzer_corpus/f503f8d526eaec9bab6cae97d09207deefa85d8d Binary files differnew file mode 100644 index 0000000000..6bdb2b0436 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f503f8d526eaec9bab6cae97d09207deefa85d8d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f575224a90d142bcd971b4f1634f4dc4988f8b15 b/test/core/end2end/fuzzers/api_fuzzer_corpus/f575224a90d142bcd971b4f1634f4dc4988f8b15 Binary files differnew file mode 100644 index 0000000000..b4e7db949f --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f575224a90d142bcd971b4f1634f4dc4988f8b15 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f7623c34b3b5fb243fe589d881e4e8489f578f21 b/test/core/end2end/fuzzers/api_fuzzer_corpus/f7623c34b3b5fb243fe589d881e4e8489f578f21 Binary files differnew file mode 100644 index 0000000000..46076b5f94 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f7623c34b3b5fb243fe589d881e4e8489f578f21 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f875ad5830cb0b5d387a267e0200eb3027d025d5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/f875ad5830cb0b5d387a267e0200eb3027d025d5 Binary files differnew file mode 100644 index 0000000000..dccc89ba77 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f875ad5830cb0b5d387a267e0200eb3027d025d5 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f9048c4c18e729b6f49e929876ec30866deb16a9 b/test/core/end2end/fuzzers/api_fuzzer_corpus/f9048c4c18e729b6f49e929876ec30866deb16a9 Binary files differnew file mode 100644 index 0000000000..7c90edad4e --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f9048c4c18e729b6f49e929876ec30866deb16a9 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/f92897ee60bd24634aa1582f162c1c8f4b249148 b/test/core/end2end/fuzzers/api_fuzzer_corpus/f92897ee60bd24634aa1582f162c1c8f4b249148 Binary files differnew file mode 100644 index 0000000000..758adafd3b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/f92897ee60bd24634aa1582f162c1c8f4b249148 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/fb17c3fec47ab446ee737ab4c7fa8cb85688d5be b/test/core/end2end/fuzzers/api_fuzzer_corpus/fb17c3fec47ab446ee737ab4c7fa8cb85688d5be Binary files differnew file mode 100644 index 0000000000..2deefec71b --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/fb17c3fec47ab446ee737ab4c7fa8cb85688d5be diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/fb655905396b768cf3ff015afdb0b564dae2cdfd b/test/core/end2end/fuzzers/api_fuzzer_corpus/fb655905396b768cf3ff015afdb0b564dae2cdfd Binary files differnew file mode 100644 index 0000000000..b02dabe03a --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/fb655905396b768cf3ff015afdb0b564dae2cdfd diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/fc824337cead8b9e5229119c85c284fdd8e2d391 b/test/core/end2end/fuzzers/api_fuzzer_corpus/fc824337cead8b9e5229119c85c284fdd8e2d391 Binary files differnew file mode 100644 index 0000000000..20ca7b5262 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/fc824337cead8b9e5229119c85c284fdd8e2d391 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/fd05ad1a9d183c2a25d820aca9940caacbaa0660 b/test/core/end2end/fuzzers/api_fuzzer_corpus/fd05ad1a9d183c2a25d820aca9940caacbaa0660 Binary files differnew file mode 100644 index 0000000000..3261a7bfda --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/fd05ad1a9d183c2a25d820aca9940caacbaa0660 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/fd4f7d5d3d21c75ccb5cde9491bf952bae753390 b/test/core/end2end/fuzzers/api_fuzzer_corpus/fd4f7d5d3d21c75ccb5cde9491bf952bae753390 Binary files differnew file mode 100644 index 0000000000..fc7226b8e7 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/fd4f7d5d3d21c75ccb5cde9491bf952bae753390 diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/fdb038087233cd176746558875932029f779221d b/test/core/end2end/fuzzers/api_fuzzer_corpus/fdb038087233cd176746558875932029f779221d Binary files differnew file mode 100644 index 0000000000..017fdbf661 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/fdb038087233cd176746558875932029f779221d diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/fe786c056e1e068e9cb9a94d7e10cee1593436bc b/test/core/end2end/fuzzers/api_fuzzer_corpus/fe786c056e1e068e9cb9a94d7e10cee1593436bc Binary files differnew file mode 100644 index 0000000000..28b1302d47 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/fe786c056e1e068e9cb9a94d7e10cee1593436bc diff --git a/test/core/end2end/fuzzers/client_fuzzer.c b/test/core/end2end/fuzzers/client_fuzzer.c index c5260cd287..e7e7dbefd0 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.c +++ b/test/core/end2end/fuzzers/client_fuzzer.c @@ -37,6 +37,7 @@ #include <grpc/support/alloc.h> #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/channel.h" #include "test/core/util/memory_counters.h" #include "test/core/util/mock_endpoint.h" @@ -51,7 +52,7 @@ static void *tag(int n) { return (void *)(uintptr_t)n; } static void dont_log(gpr_log_func_args *args) {} int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - grpc_test_only_set_metadata_hash_seed(0); + grpc_test_only_set_slice_hash_seed(0); struct grpc_memory_counters counters; if (squelch) gpr_set_log_function(dont_log); if (leak_check) grpc_memory_counters_init(); @@ -62,7 +63,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 = @@ -71,9 +72,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_channel *channel = grpc_channel_create( &exec_ctx, "test-target", NULL, GRPC_CLIENT_DIRECT_CHANNEL, transport); - grpc_call *call = - grpc_channel_create_call(channel, NULL, 0, cq, "/foo", "localhost", - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + grpc_slice host = grpc_slice_from_static_string("localhost"); + grpc_call *call = grpc_channel_create_call( + channel, NULL, 0, cq, grpc_slice_from_static_string("/foo"), &host, + gpr_inf_future(GPR_CLOCK_REALTIME), NULL); grpc_metadata_array initial_metadata_recv; grpc_metadata_array_init(&initial_metadata_recv); @@ -81,8 +83,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_metadata_array trailing_metadata_recv; grpc_metadata_array_init(&trailing_metadata_recv); grpc_status_code status; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details = grpc_empty_slice(); grpc_op ops[6]; memset(ops, 0, sizeof(ops)); @@ -97,12 +98,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -110,7 +111,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 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++; @@ -155,7 +155,7 @@ done: grpc_completion_queue_destroy(cq); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); - gpr_free(details); + grpc_slice_unref(details); grpc_channel_destroy(channel); if (response_payload_recv != NULL) { grpc_byte_buffer_destroy(response_payload_recv); diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/175f16901997fdee41ac9ec88f7e018d46d774e7 b/test/core/end2end/fuzzers/client_fuzzer_corpus/175f16901997fdee41ac9ec88f7e018d46d774e7 Binary files differnew file mode 100644 index 0000000000..1cf81515f3 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/175f16901997fdee41ac9ec88f7e018d46d774e7 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/26f250ae38865f030176a8801ce992536351a326 b/test/core/end2end/fuzzers/client_fuzzer_corpus/26f250ae38865f030176a8801ce992536351a326 Binary files differnew file mode 100644 index 0000000000..6c970a4a05 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/26f250ae38865f030176a8801ce992536351a326 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/3233f2ab3b6c9431289ef7dc4f40676d0128bcad b/test/core/end2end/fuzzers/client_fuzzer_corpus/3233f2ab3b6c9431289ef7dc4f40676d0128bcad Binary files differnew file mode 100644 index 0000000000..64eef0085c --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/3233f2ab3b6c9431289ef7dc4f40676d0128bcad diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/3656614c7b0dc11d4dd7e1826f77fa96a88c420f b/test/core/end2end/fuzzers/client_fuzzer_corpus/3656614c7b0dc11d4dd7e1826f77fa96a88c420f Binary files differnew file mode 100644 index 0000000000..fb9667c5a2 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/3656614c7b0dc11d4dd7e1826f77fa96a88c420f diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/3dec1981e8677ec6ad2517feba29869d53f8d884 b/test/core/end2end/fuzzers/client_fuzzer_corpus/3dec1981e8677ec6ad2517feba29869d53f8d884 Binary files differnew file mode 100644 index 0000000000..92ff8bcb26 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/3dec1981e8677ec6ad2517feba29869d53f8d884 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/4bed84590a55b06d7eb30d8faa4b00a881ba9b2c b/test/core/end2end/fuzzers/client_fuzzer_corpus/4bed84590a55b06d7eb30d8faa4b00a881ba9b2c Binary files differnew file mode 100644 index 0000000000..3e3365e861 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/4bed84590a55b06d7eb30d8faa4b00a881ba9b2c diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/591d46b83d2e6babc0ce3c753c4606a10c46d7ce b/test/core/end2end/fuzzers/client_fuzzer_corpus/591d46b83d2e6babc0ce3c753c4606a10c46d7ce Binary files differnew file mode 100644 index 0000000000..addaccb045 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/591d46b83d2e6babc0ce3c753c4606a10c46d7ce diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/5a52d683c9342dd301b0e699db36175aad715e1d b/test/core/end2end/fuzzers/client_fuzzer_corpus/5a52d683c9342dd301b0e699db36175aad715e1d Binary files differnew file mode 100644 index 0000000000..e9e09a1b0d --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/5a52d683c9342dd301b0e699db36175aad715e1d diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/5b7ff7c113c2bcf125271d22c937f758a0cd2ee4 b/test/core/end2end/fuzzers/client_fuzzer_corpus/5b7ff7c113c2bcf125271d22c937f758a0cd2ee4 Binary files differnew file mode 100644 index 0000000000..2ccc02dcc6 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/5b7ff7c113c2bcf125271d22c937f758a0cd2ee4 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/616e55354ba3517ce6762d6cd56600f97915e646 b/test/core/end2end/fuzzers/client_fuzzer_corpus/616e55354ba3517ce6762d6cd56600f97915e646 Binary files differnew file mode 100644 index 0000000000..ccaeedbac6 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/616e55354ba3517ce6762d6cd56600f97915e646 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/7a9a12b15c798b88f1a599779f52d14edf9f4ef5 b/test/core/end2end/fuzzers/client_fuzzer_corpus/7a9a12b15c798b88f1a599779f52d14edf9f4ef5 Binary files differnew file mode 100644 index 0000000000..05e8c3952c --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/7a9a12b15c798b88f1a599779f52d14edf9f4ef5 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/8f05b8da748cc04e64b688c4b435fe64699bd481 b/test/core/end2end/fuzzers/client_fuzzer_corpus/8f05b8da748cc04e64b688c4b435fe64699bd481 Binary files differnew file mode 100644 index 0000000000..53a44036f4 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/8f05b8da748cc04e64b688c4b435fe64699bd481 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/8fd758e2603f1e3772cfcd295ff0f951988d7648 b/test/core/end2end/fuzzers/client_fuzzer_corpus/8fd758e2603f1e3772cfcd295ff0f951988d7648 Binary files differnew file mode 100644 index 0000000000..33a7bd8b82 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/8fd758e2603f1e3772cfcd295ff0f951988d7648 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/9018925b5e791ae4b3ae9c84b8a4d47d86671c2d b/test/core/end2end/fuzzers/client_fuzzer_corpus/9018925b5e791ae4b3ae9c84b8a4d47d86671c2d Binary files differnew file mode 100644 index 0000000000..fccac2a4ae --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/9018925b5e791ae4b3ae9c84b8a4d47d86671c2d diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/9912de197918ac0e305f0c0107f863823e8ae818 b/test/core/end2end/fuzzers/client_fuzzer_corpus/9912de197918ac0e305f0c0107f863823e8ae818 Binary files differnew file mode 100644 index 0000000000..5304b1e5b6 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/9912de197918ac0e305f0c0107f863823e8ae818 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/ab90bebd4c017827a6d5de61511445df81169eb6 b/test/core/end2end/fuzzers/client_fuzzer_corpus/ab90bebd4c017827a6d5de61511445df81169eb6 Binary files differnew file mode 100644 index 0000000000..3cdcdf9e6f --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/ab90bebd4c017827a6d5de61511445df81169eb6 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/b26a3a83d0b319ce13a9ae164e90fa6da1b05a57 b/test/core/end2end/fuzzers/client_fuzzer_corpus/b26a3a83d0b319ce13a9ae164e90fa6da1b05a57 Binary files differnew file mode 100644 index 0000000000..908355a681 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/b26a3a83d0b319ce13a9ae164e90fa6da1b05a57 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/ba25be123c630bd3e4aeb9bda6304dd1a7e51365 b/test/core/end2end/fuzzers/client_fuzzer_corpus/ba25be123c630bd3e4aeb9bda6304dd1a7e51365 Binary files differnew file mode 100644 index 0000000000..1f1b88ac8d --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/ba25be123c630bd3e4aeb9bda6304dd1a7e51365 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/c77ee0b6cb21ab7b7cf222c7f6563b3b1b1b6eed b/test/core/end2end/fuzzers/client_fuzzer_corpus/c77ee0b6cb21ab7b7cf222c7f6563b3b1b1b6eed Binary files differnew file mode 100644 index 0000000000..3f14a28a44 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/c77ee0b6cb21ab7b7cf222c7f6563b3b1b1b6eed diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/c7b17d6ae5f3b155532a5a9bf0239c098c35eec1 b/test/core/end2end/fuzzers/client_fuzzer_corpus/c7b17d6ae5f3b155532a5a9bf0239c098c35eec1 Binary files differnew file mode 100644 index 0000000000..e0d5825270 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/c7b17d6ae5f3b155532a5a9bf0239c098c35eec1 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/ccc36ee2c6a0daad65a4d929599fda5cd38b8fd1 b/test/core/end2end/fuzzers/client_fuzzer_corpus/ccc36ee2c6a0daad65a4d929599fda5cd38b8fd1 Binary files differnew file mode 100644 index 0000000000..e612b05fb5 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/ccc36ee2c6a0daad65a4d929599fda5cd38b8fd1 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/crash-133500314833c9037b34a4c34ad779dd78a0fa8d b/test/core/end2end/fuzzers/client_fuzzer_corpus/crash-133500314833c9037b34a4c34ad779dd78a0fa8d Binary files differnew file mode 100644 index 0000000000..e475765eef --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/crash-133500314833c9037b34a4c34ad779dd78a0fa8d diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/d3141a71cdaa7a0915c8c55abf2c940b0fd00172 b/test/core/end2end/fuzzers/client_fuzzer_corpus/d3141a71cdaa7a0915c8c55abf2c940b0fd00172 Binary files differnew file mode 100644 index 0000000000..e2881dae02 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/d3141a71cdaa7a0915c8c55abf2c940b0fd00172 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/de9b9a35e1e7040e842b597b8d2fe4cd602e67f1 b/test/core/end2end/fuzzers/client_fuzzer_corpus/de9b9a35e1e7040e842b597b8d2fe4cd602e67f1 Binary files differnew file mode 100644 index 0000000000..7b8d43ea27 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/de9b9a35e1e7040e842b597b8d2fe4cd602e67f1 diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/e5319a8570a762bbdd67135b49579097324e369a b/test/core/end2end/fuzzers/client_fuzzer_corpus/e5319a8570a762bbdd67135b49579097324e369a Binary files differnew file mode 100644 index 0000000000..128aef0fd5 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/e5319a8570a762bbdd67135b49579097324e369a diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/e5e276acd665ccb47f868fe3bc36e647bbb840bd b/test/core/end2end/fuzzers/client_fuzzer_corpus/e5e276acd665ccb47f868fe3bc36e647bbb840bd Binary files differnew file mode 100644 index 0000000000..05b14a7035 --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/e5e276acd665ccb47f868fe3bc36e647bbb840bd diff --git a/test/core/end2end/fuzzers/client_fuzzer_corpus/f69aa5666fd60c1b6814198f12d049abb0e9f148 b/test/core/end2end/fuzzers/client_fuzzer_corpus/f69aa5666fd60c1b6814198f12d049abb0e9f148 Binary files differnew file mode 100644 index 0000000000..380bac227a --- /dev/null +++ b/test/core/end2end/fuzzers/client_fuzzer_corpus/f69aa5666fd60c1b6814198f12d049abb0e9f148 diff --git a/test/core/end2end/fuzzers/hpack.dictionary b/test/core/end2end/fuzzers/hpack.dictionary index 12db0ff024..81a2419d12 100644 --- a/test/core/end2end/fuzzers/hpack.dictionary +++ b/test/core/end2end/fuzzers/hpack.dictionary @@ -1,24 +1,62 @@ # hpack fuzzing dictionary +"\x05:path" +"\x07:method" +"\x07:status" +"\x0A:authority" +"\x07:scheme" +"\x02te" +"\x0Cgrpc-message" +"\x0Bgrpc-status" +"\x10grpc-payload-bin" +"\x0Dgrpc-encoding" +"\x14grpc-accept-encoding" +"\x0Ccontent-type" +"\x1Egrpc-internal-encoding-request" +"\x0Auser-agent" +"\x04host" +"\x08lb-token" +"\x0Blb-cost-bin" +"\x0Cgrpc-timeout" +"\x10grpc-tracing-bin" +"\x0Egrpc-stats-bin" +"\x00" +"\x13grpc.wait_for_ready" +"\x0Cgrpc.timeout" +"\x1Egrpc.max_request_message_bytes" +"\x1Fgrpc.max_response_message_bytes" +"$/grpc.lb.v1.LoadBalancer/BalanceLoad" "\x010" "\x011" "\x012" +"\x08identity" +"\x04gzip" +"\x07deflate" +"\x08trailers" +"\x10application/grpc" +"\x04POST" "\x03200" +"\x03404" +"\x04http" +"\x05https" +"\x04grpc" +"\x03GET" +"\x03PUT" +"\x01/" +"\x0B/index.html" "\x03204" "\x03206" "\x03304" "\x03400" -"\x03404" "\x03500" -"\x06accept" "\x0Eaccept-charset" "\x0Faccept-encoding" +"\x0Dgzip, deflate" "\x0Faccept-language" "\x0Daccept-ranges" +"\x06accept" "\x1Baccess-control-allow-origin" "\x03age" "\x05allow" -"\x10application/grpc" -"\x0A:authority" "\x0Dauthorization" "\x0Dcache-control" "\x13content-disposition" @@ -27,81 +65,71 @@ "\x0Econtent-length" "\x10content-location" "\x0Dcontent-range" -"\x0Ccontent-type" "\x06cookie" "\x04date" -"\x07deflate" -"\x0Cdeflate,gzip" -"\x00" "\x04etag" "\x06expect" "\x07expires" "\x04from" -"\x03GET" -"\x04grpc" -"\x14grpc-accept-encoding" -"\x0Dgrpc-encoding" -"\x1Egrpc-internal-encoding-request" -"\x0Cgrpc-message" -"\x10grpc-payload-bin" -"\x0Egrpc-stats-bin" -"\x0Bgrpc-status" -"\x0Cgrpc-timeout" -"\x10grpc-tracing-bin" -"\x04gzip" -"\x0Dgzip, deflate" -"\x04host" -"\x04http" -"\x05https" -"\x08identity" -"\x10identity,deflate" -"\x15identity,deflate,gzip" -"\x0Didentity,gzip" "\x08if-match" "\x11if-modified-since" "\x0Dif-none-match" "\x08if-range" "\x13if-unmodified-since" "\x0Dlast-modified" -"\x0Blb-cost-bin" -"\x08lb-token" "\x04link" "\x08location" "\x0Cmax-forwards" -"\x07:method" -"\x05:path" -"\x04POST" "\x12proxy-authenticate" "\x13proxy-authorization" -"\x03PUT" "\x05range" "\x07referer" "\x07refresh" "\x0Bretry-after" -"\x07:scheme" "\x06server" "\x0Aset-cookie" -"\x01/" -"\x0B/index.html" -"\x07:status" "\x19strict-transport-security" -"\x02te" -"\x08trailers" "\x11transfer-encoding" -"\x0Auser-agent" "\x04vary" "\x03via" "\x10www-authenticate" +"\x10identity,deflate" +"\x0Didentity,gzip" +"\x0Cdeflate,gzip" +"\x15identity,deflate,gzip" +"\x00\x0Bgrpc-status\x010" +"\x00\x0Bgrpc-status\x011" +"\x00\x0Bgrpc-status\x012" +"\x00\x0Dgrpc-encoding\x08identity" +"\x00\x0Dgrpc-encoding\x04gzip" +"\x00\x0Dgrpc-encoding\x07deflate" +"\x00\x02te\x08trailers" +"\x00\x0Ccontent-type\x10application/grpc" +"\x00\x07:method\x04POST" +"\x00\x07:status\x03200" +"\x00\x07:status\x03404" +"\x00\x07:scheme\x04http" +"\x00\x07:scheme\x05https" +"\x00\x07:scheme\x04grpc" +"\x00\x0A:authority\x00" +"\x00\x07:method\x03GET" +"\x00\x07:method\x03PUT" +"\x00\x05:path\x01/" +"\x00\x05:path\x0B/index.html" +"\x00\x07:status\x03204" +"\x00\x07:status\x03206" +"\x00\x07:status\x03304" +"\x00\x07:status\x03400" +"\x00\x07:status\x03500" "\x00\x0Eaccept-charset\x00" -"\x00\x06accept\x00" "\x00\x0Faccept-encoding\x00" "\x00\x0Faccept-encoding\x0Dgzip, deflate" "\x00\x0Faccept-language\x00" "\x00\x0Daccept-ranges\x00" +"\x00\x06accept\x00" "\x00\x1Baccess-control-allow-origin\x00" "\x00\x03age\x00" "\x00\x05allow\x00" -"\x00\x0A:authority\x00" "\x00\x0Dauthorization\x00" "\x00\x0Dcache-control\x00" "\x00\x13content-disposition\x00" @@ -110,7 +138,6 @@ "\x00\x0Econtent-length\x00" "\x00\x10content-location\x00" "\x00\x0Dcontent-range\x00" -"\x00\x0Ccontent-type\x10application/grpc" "\x00\x0Ccontent-type\x00" "\x00\x06cookie\x00" "\x00\x04date\x00" @@ -118,19 +145,6 @@ "\x00\x06expect\x00" "\x00\x07expires\x00" "\x00\x04from\x00" -"\x00\x14grpc-accept-encoding\x07deflate" -"\x00\x14grpc-accept-encoding\x0Cdeflate,gzip" -"\x00\x14grpc-accept-encoding\x04gzip" -"\x00\x14grpc-accept-encoding\x08identity" -"\x00\x14grpc-accept-encoding\x10identity,deflate" -"\x00\x14grpc-accept-encoding\x15identity,deflate,gzip" -"\x00\x14grpc-accept-encoding\x0Didentity,gzip" -"\x00\x0Dgrpc-encoding\x07deflate" -"\x00\x0Dgrpc-encoding\x04gzip" -"\x00\x0Dgrpc-encoding\x08identity" -"\x00\x0Bgrpc-status\x010" -"\x00\x0Bgrpc-status\x011" -"\x00\x0Bgrpc-status\x012" "\x00\x04host\x00" "\x00\x08if-match\x00" "\x00\x11if-modified-since\x00" @@ -138,38 +152,29 @@ "\x00\x08if-range\x00" "\x00\x13if-unmodified-since\x00" "\x00\x0Dlast-modified\x00" -"\x00\x0Blb-cost-bin\x00" "\x00\x08lb-token\x00" +"\x00\x0Blb-cost-bin\x00" "\x00\x04link\x00" "\x00\x08location\x00" "\x00\x0Cmax-forwards\x00" -"\x00\x07:method\x03GET" -"\x00\x07:method\x04POST" -"\x00\x07:method\x03PUT" -"\x00\x05:path\x01/" -"\x00\x05:path\x0B/index.html" "\x00\x12proxy-authenticate\x00" "\x00\x13proxy-authorization\x00" "\x00\x05range\x00" "\x00\x07referer\x00" "\x00\x07refresh\x00" "\x00\x0Bretry-after\x00" -"\x00\x07:scheme\x04grpc" -"\x00\x07:scheme\x04http" -"\x00\x07:scheme\x05https" "\x00\x06server\x00" "\x00\x0Aset-cookie\x00" -"\x00\x07:status\x03200" -"\x00\x07:status\x03204" -"\x00\x07:status\x03206" -"\x00\x07:status\x03304" -"\x00\x07:status\x03400" -"\x00\x07:status\x03404" -"\x00\x07:status\x03500" "\x00\x19strict-transport-security\x00" -"\x00\x02te\x08trailers" "\x00\x11transfer-encoding\x00" "\x00\x0Auser-agent\x00" "\x00\x04vary\x00" "\x00\x03via\x00" "\x00\x10www-authenticate\x00" +"\x00\x14grpc-accept-encoding\x08identity" +"\x00\x14grpc-accept-encoding\x07deflate" +"\x00\x14grpc-accept-encoding\x10identity,deflate" +"\x00\x14grpc-accept-encoding\x04gzip" +"\x00\x14grpc-accept-encoding\x0Didentity,gzip" +"\x00\x14grpc-accept-encoding\x0Cdeflate,gzip" +"\x00\x14grpc-accept-encoding\x15identity,deflate,gzip" diff --git a/test/core/end2end/fuzzers/server_fuzzer.c b/test/core/end2end/fuzzers/server_fuzzer.c index 164022ec79..186542d4b2 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.c +++ b/test/core/end2end/fuzzers/server_fuzzer.c @@ -34,6 +34,7 @@ #include <grpc/grpc.h> #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/server.h" #include "test/core/util/memory_counters.h" #include "test/core/util/mock_endpoint.h" @@ -49,7 +50,7 @@ static int detag(void *p) { return (int)(uintptr_t)p; } static void dont_log(gpr_log_func_args *args) {} int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - grpc_test_only_set_metadata_hash_seed(0); + grpc_test_only_set_slice_hash_seed(0); struct grpc_memory_counters counters; if (squelch) gpr_set_log_function(dont_log); if (leak_check) grpc_memory_counters_init(); @@ -60,7 +61,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/fuzzers/server_fuzzer_corpus/084e9e02b8f2ed41ff9c22fef80e522e491227c5 b/test/core/end2end/fuzzers/server_fuzzer_corpus/084e9e02b8f2ed41ff9c22fef80e522e491227c5 Binary files differnew file mode 100644 index 0000000000..dceac8308d --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/084e9e02b8f2ed41ff9c22fef80e522e491227c5 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/0c129f78eacfb0d0d3c89dd4e578724096a3cea0 b/test/core/end2end/fuzzers/server_fuzzer_corpus/0c129f78eacfb0d0d3c89dd4e578724096a3cea0 Binary files differnew file mode 100644 index 0000000000..98fcc6d4f0 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/0c129f78eacfb0d0d3c89dd4e578724096a3cea0 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/129382aa11fa2922053fa47ba691dddb98901260 b/test/core/end2end/fuzzers/server_fuzzer_corpus/129382aa11fa2922053fa47ba691dddb98901260 Binary files differnew file mode 100644 index 0000000000..aaab7408d6 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/129382aa11fa2922053fa47ba691dddb98901260 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/1353e447b7b10fb3eabb02863a1fc5bc9bb50460 b/test/core/end2end/fuzzers/server_fuzzer_corpus/1353e447b7b10fb3eabb02863a1fc5bc9bb50460 Binary files differnew file mode 100644 index 0000000000..80c050952b --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/1353e447b7b10fb3eabb02863a1fc5bc9bb50460 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/3b55d09b98e3982d6f80913a792463c3974766db b/test/core/end2end/fuzzers/server_fuzzer_corpus/3b55d09b98e3982d6f80913a792463c3974766db Binary files differnew file mode 100644 index 0000000000..ef3d868d27 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/3b55d09b98e3982d6f80913a792463c3974766db diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/416160124b3b64fc9355f24dd789b3d1fd097b8b b/test/core/end2end/fuzzers/server_fuzzer_corpus/416160124b3b64fc9355f24dd789b3d1fd097b8b Binary files differnew file mode 100644 index 0000000000..896d760dc4 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/416160124b3b64fc9355f24dd789b3d1fd097b8b diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/47563391b73b6ef4bf987014c3e631fe2555a377 b/test/core/end2end/fuzzers/server_fuzzer_corpus/47563391b73b6ef4bf987014c3e631fe2555a377 Binary files differnew file mode 100644 index 0000000000..ed9f1c8645 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/47563391b73b6ef4bf987014c3e631fe2555a377 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/6c0ec181e81b915071766762f5d78e9b1ccc9128 b/test/core/end2end/fuzzers/server_fuzzer_corpus/6c0ec181e81b915071766762f5d78e9b1ccc9128 Binary files differnew file mode 100644 index 0000000000..e373c1e20b --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/6c0ec181e81b915071766762f5d78e9b1ccc9128 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/6c66271b74a11f4e7065a6acbc86e4611e7e0dcc b/test/core/end2end/fuzzers/server_fuzzer_corpus/6c66271b74a11f4e7065a6acbc86e4611e7e0dcc Binary files differnew file mode 100644 index 0000000000..c4a5dd5e7a --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/6c66271b74a11f4e7065a6acbc86e4611e7e0dcc diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/72db978194609ac138bca393650740a3eae8f448 b/test/core/end2end/fuzzers/server_fuzzer_corpus/72db978194609ac138bca393650740a3eae8f448 Binary files differnew file mode 100644 index 0000000000..8d3023a33c --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/72db978194609ac138bca393650740a3eae8f448 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/7df75412d12894fc501bd2d8493fe9e5a753ad88 b/test/core/end2end/fuzzers/server_fuzzer_corpus/7df75412d12894fc501bd2d8493fe9e5a753ad88 Binary files differnew file mode 100644 index 0000000000..d2200a2378 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/7df75412d12894fc501bd2d8493fe9e5a753ad88 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/92f1df2266f34a097e96dd22188d8633832d37b1 b/test/core/end2end/fuzzers/server_fuzzer_corpus/92f1df2266f34a097e96dd22188d8633832d37b1 Binary files differnew file mode 100644 index 0000000000..16a928deee --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/92f1df2266f34a097e96dd22188d8633832d37b1 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/947f53c0978672e59be452395670fa949a33cb4f b/test/core/end2end/fuzzers/server_fuzzer_corpus/947f53c0978672e59be452395670fa949a33cb4f Binary files differnew file mode 100644 index 0000000000..1c1f163af3 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/947f53c0978672e59be452395670fa949a33cb4f diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/a40c3ba87b4206142b134f67485859b7c9b7c75c b/test/core/end2end/fuzzers/server_fuzzer_corpus/a40c3ba87b4206142b134f67485859b7c9b7c75c Binary files differnew file mode 100644 index 0000000000..6cc09b4dc2 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/a40c3ba87b4206142b134f67485859b7c9b7c75c diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/a8305e9bb4a544eaef27e8bd21b4faabf524a84e b/test/core/end2end/fuzzers/server_fuzzer_corpus/a8305e9bb4a544eaef27e8bd21b4faabf524a84e Binary files differnew file mode 100644 index 0000000000..9476948e84 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/a8305e9bb4a544eaef27e8bd21b4faabf524a84e diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/ac4e19c9fe290afc54bbb1e5f6cfe84a9c1f3c29 b/test/core/end2end/fuzzers/server_fuzzer_corpus/ac4e19c9fe290afc54bbb1e5f6cfe84a9c1f3c29 Binary files differnew file mode 100644 index 0000000000..6fb218b891 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/ac4e19c9fe290afc54bbb1e5f6cfe84a9c1f3c29 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/ae297426638eb5a0611324f403c3189515274f1b b/test/core/end2end/fuzzers/server_fuzzer_corpus/ae297426638eb5a0611324f403c3189515274f1b Binary files differnew file mode 100644 index 0000000000..9540cb54e3 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/ae297426638eb5a0611324f403c3189515274f1b diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/b74dcd9c2780f145e09a27d2e03119576889a301 b/test/core/end2end/fuzzers/server_fuzzer_corpus/b74dcd9c2780f145e09a27d2e03119576889a301 Binary files differnew file mode 100644 index 0000000000..ffe5b3b6b6 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/b74dcd9c2780f145e09a27d2e03119576889a301 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/c39c0192d0d4f2b24f05c25a9e669cc091bff9e9 b/test/core/end2end/fuzzers/server_fuzzer_corpus/c39c0192d0d4f2b24f05c25a9e669cc091bff9e9 Binary files differnew file mode 100644 index 0000000000..0da037829f --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/c39c0192d0d4f2b24f05c25a9e669cc091bff9e9 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-73923add5066617ae08f187b79d2639b4fd96138 b/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-73923add5066617ae08f187b79d2639b4fd96138 Binary files differnew file mode 100644 index 0000000000..a06f3ce0d1 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-73923add5066617ae08f187b79d2639b4fd96138 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-901723090ff2042ecc5a008ccd7ae0845c1681cb b/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-901723090ff2042ecc5a008ccd7ae0845c1681cb Binary files differnew file mode 100644 index 0000000000..9f909839dc --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/crash-901723090ff2042ecc5a008ccd7ae0845c1681cb diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/d297b3f84e3dee9f74bf1162718aff66a11a7f5c b/test/core/end2end/fuzzers/server_fuzzer_corpus/d297b3f84e3dee9f74bf1162718aff66a11a7f5c Binary files differnew file mode 100644 index 0000000000..e619ae5434 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/d297b3f84e3dee9f74bf1162718aff66a11a7f5c diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/e021c5b9815f02ee9d1e5a003cbf3500e19db13c b/test/core/end2end/fuzzers/server_fuzzer_corpus/e021c5b9815f02ee9d1e5a003cbf3500e19db13c Binary files differnew file mode 100644 index 0000000000..a3ae8221c9 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/e021c5b9815f02ee9d1e5a003cbf3500e19db13c diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/fc162db40f87facb73cff20751e23af2e1f5296e b/test/core/end2end/fuzzers/server_fuzzer_corpus/fc162db40f87facb73cff20751e23af2e1f5296e Binary files differnew file mode 100644 index 0000000000..d63d69c2c3 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/fc162db40f87facb73cff20751e23af2e1f5296e diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/fcb1dea251d1ce74e30351f13a3f71e3debec3d2 b/test/core/end2end/fuzzers/server_fuzzer_corpus/fcb1dea251d1ce74e30351f13a3f71e3debec3d2 Binary files differnew file mode 100644 index 0000000000..84d6c210b7 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/fcb1dea251d1ce74e30351f13a3f71e3debec3d2 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/fe740f8c4ffd07f79456c8cee24ef556ee348f55 b/test/core/end2end/fuzzers/server_fuzzer_corpus/fe740f8c4ffd07f79456c8cee24ef556ee348f55 Binary files differnew file mode 100644 index 0000000000..3391a8399e --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/fe740f8c4ffd07f79456c8cee24ef556ee348f55 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-03c6f209b2f144734c83d81ed452839d9e244fe9 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-03c6f209b2f144734c83d81ed452839d9e244fe9 Binary files differnew file mode 100644 index 0000000000..f9ce44a3c2 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-03c6f209b2f144734c83d81ed452839d9e244fe9 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-129ecb5e7b80616f36791e3580844e520f2ba7d3 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-129ecb5e7b80616f36791e3580844e520f2ba7d3 Binary files differnew file mode 100644 index 0000000000..b11defdbe2 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-129ecb5e7b80616f36791e3580844e520f2ba7d3 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-30408c9d13f29804168fc62a0818cc894c6375ae b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-30408c9d13f29804168fc62a0818cc894c6375ae Binary files differnew file mode 100644 index 0000000000..0eff0f19f7 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-30408c9d13f29804168fc62a0818cc894c6375ae diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-33d8bf197de7131be78244e10fbb0da5055cf266 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-33d8bf197de7131be78244e10fbb0da5055cf266 Binary files differnew file mode 100644 index 0000000000..170119f265 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-33d8bf197de7131be78244e10fbb0da5055cf266 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-51cdbfa3e97a46ceefde405e6ab087a109c26907 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-51cdbfa3e97a46ceefde405e6ab087a109c26907 Binary files differnew file mode 100644 index 0000000000..aeecff3c4d --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-51cdbfa3e97a46ceefde405e6ab087a109c26907 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-523cb1bca5ad56690c618b4ceac7fceca1113b9d b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-523cb1bca5ad56690c618b4ceac7fceca1113b9d Binary files differnew file mode 100644 index 0000000000..b725ec18f0 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-523cb1bca5ad56690c618b4ceac7fceca1113b9d diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-a877fe99fd0e92721d162bc252bf72a4f67ba1ea b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-a877fe99fd0e92721d162bc252bf72a4f67ba1ea Binary files differnew file mode 100644 index 0000000000..718794aa0e --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-a877fe99fd0e92721d162bc252bf72a4f67ba1ea diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-bd9d24f5c7c915174b6ca9d1a3573e16e0edee12 b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-bd9d24f5c7c915174b6ca9d1a3573e16e0edee12 Binary files differnew file mode 100644 index 0000000000..fa1e6fab82 --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-bd9d24f5c7c915174b6ca9d1a3573e16e0edee12 diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-f3c688876395bf7a529f29f7b91532726cf5cbce b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-f3c688876395bf7a529f29f7b91532726cf5cbce Binary files differnew file mode 100644 index 0000000000..b66722c90c --- /dev/null +++ b/test/core/end2end/fuzzers/server_fuzzer_corpus/slow-unit-f3c688876395bf7a529f29f7b91532726cf5cbce 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 cd68b390bb..c67c1f145a 100644 --- a/test/core/end2end/goaway_server_test.c +++ b/test/core/end2end/goaway_server_test.c @@ -101,8 +101,7 @@ int main(int argc, char **argv) { grpc_metadata_array request_metadata1; grpc_call_details request_details1; grpc_status_code status1; - char *details1 = NULL; - size_t details_capacity1 = 0; + grpc_slice details1; grpc_metadata_array_init(&trailing_metadata_recv1); grpc_metadata_array_init(&request_metadata1); grpc_call_details_init(&request_details1); @@ -111,8 +110,7 @@ int main(int argc, char **argv) { grpc_metadata_array request_metadata2; grpc_call_details request_details2; grpc_status_code status2; - char *details2 = NULL; - size_t details_capacity2 = 0; + grpc_slice details2; grpc_metadata_array_init(&trailing_metadata_recv2); grpc_metadata_array_init(&request_metadata2); grpc_call_details_init(&request_details2); @@ -137,9 +135,11 @@ int main(int argc, char **argv) { /* create a channel that picks first amongst the servers */ 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", - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20), NULL); + grpc_slice host = grpc_slice_from_static_string("127.0.0.1"); + grpc_call *call1 = + grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, + grpc_slice_from_static_string("/foo"), &host, + grpc_timeout_seconds_to_deadline(20), NULL); /* send initial metadata to probe connectivity */ memset(ops, 0, sizeof(ops)); op = ops; @@ -158,7 +158,6 @@ int main(int argc, char **argv) { op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv1; op->data.recv_status_on_client.status = &status1; op->data.recv_status_on_client.status_details = &details1; - op->data.recv_status_on_client.status_details_capacity = &details_capacity1; op->flags = 0; op->reserved = NULL; op++; @@ -213,9 +212,10 @@ int main(int argc, char **argv) { cq_verify_empty(cqv); /* and a new call: should go through to server2 when we start it */ - grpc_call *call2 = grpc_channel_create_call( - chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo", "127.0.0.1", - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20), NULL); + grpc_call *call2 = + grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, + grpc_slice_from_static_string("/foo"), &host, + grpc_timeout_seconds_to_deadline(20), NULL); /* send initial metadata to probe connectivity */ memset(ops, 0, sizeof(ops)); op = ops; @@ -234,7 +234,6 @@ int main(int argc, char **argv) { op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv2; op->data.recv_status_on_client.status = &status2; op->data.recv_status_on_client.status_details = &details2; - op->data.recv_status_on_client.status_details_capacity = &details_capacity2; op->flags = 0; op->reserved = NULL; op++; @@ -300,11 +299,11 @@ int main(int argc, char **argv) { grpc_metadata_array_destroy(&trailing_metadata_recv1); grpc_metadata_array_destroy(&request_metadata1); grpc_call_details_destroy(&request_details1); - gpr_free(details1); + grpc_slice_unref(details1); grpc_metadata_array_destroy(&trailing_metadata_recv2); grpc_metadata_array_destroy(&request_metadata2); grpc_call_details_destroy(&request_details2); - gpr_free(details2); + grpc_slice_unref(details2); cq_verifier_destroy(cqv); grpc_completion_queue_destroy(cq); diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index d974d2c8ff..2a9072570d 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -56,8 +56,7 @@ struct test_state { grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_status_code status; - char *details; - size_t details_capacity; + grpc_slice details; grpc_call *server_call; grpc_server *server; grpc_metadata_array server_initial_metadata_recv; @@ -73,20 +72,20 @@ static void prepare_test(int is_client) { g_state.is_client = is_client; grpc_metadata_array_init(&g_state.initial_metadata_recv); grpc_metadata_array_init(&g_state.trailing_metadata_recv); - g_state.deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2); + g_state.deadline = grpc_timeout_seconds_to_deadline(2); g_state.cq = grpc_completion_queue_create(NULL); g_state.cqv = cq_verifier_create(g_state.cq); - g_state.details = NULL; - g_state.details_capacity = 0; + g_state.details = grpc_empty_slice(); memset(g_state.ops, 0, sizeof(g_state.ops)); if (is_client) { /* create a call, channel to a non existant server */ g_state.chan = grpc_insecure_channel_create("nonexistant:54321", NULL, NULL); + grpc_slice host = grpc_slice_from_static_string("nonexistant"); g_state.call = grpc_channel_create_call( - g_state.chan, NULL, GRPC_PROPAGATE_DEFAULTS, g_state.cq, "/Foo", - "nonexistant", g_state.deadline, NULL); + g_state.chan, NULL, GRPC_PROPAGATE_DEFAULTS, g_state.cq, + grpc_slice_from_static_string("/Foo"), &host, g_state.deadline, NULL); } else { g_state.server = grpc_server_create(NULL, NULL); grpc_server_register_completion_queue(g_state.server, g_state.cq, NULL); @@ -97,9 +96,10 @@ static void prepare_test(int is_client) { gpr_join_host_port(&server_hostport, "localhost", port); g_state.chan = grpc_insecure_channel_create(server_hostport, NULL, NULL); gpr_free(server_hostport); + grpc_slice host = grpc_slice_from_static_string("bar"); g_state.call = grpc_channel_create_call( - g_state.chan, NULL, GRPC_PROPAGATE_DEFAULTS, g_state.cq, "/Foo", "bar", - g_state.deadline, NULL); + g_state.chan, NULL, GRPC_PROPAGATE_DEFAULTS, g_state.cq, + grpc_slice_from_static_string("/Foo"), &host, g_state.deadline, NULL); grpc_metadata_array_init(&g_state.server_initial_metadata_recv); grpc_call_details_init(&g_state.call_details); op = g_state.ops; @@ -126,7 +126,7 @@ static void cleanup_test() { grpc_call_destroy(g_state.call); cq_verifier_destroy(g_state.cqv); grpc_channel_destroy(g_state.chan); - gpr_free(g_state.details); + grpc_slice_unref(g_state.details); grpc_metadata_array_destroy(&g_state.initial_metadata_recv); grpc_metadata_array_destroy(&g_state.trailing_metadata_recv); @@ -134,7 +134,7 @@ static void cleanup_test() { grpc_call_destroy(g_state.server_call); grpc_server_shutdown_and_notify(g_state.server, g_state.cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(g_state.cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), + grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(g_state.server); @@ -237,7 +237,7 @@ static void test_send_null_message() { op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = NULL; + op->data.send_message.send_message = NULL; op->flags = 0; op->reserved = NULL; op++; @@ -263,12 +263,12 @@ static void test_send_messages_at_the_same_time() { op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = tag(2); + op->data.send_message.send_message = tag(2); op->flags = 0; op->reserved = NULL; op++; @@ -289,7 +289,8 @@ static void test_send_server_status_from_client() { 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -306,7 +307,8 @@ static void test_receive_initial_metadata_twice_at_client() { prepare_test(1); op = g_state.ops; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &g_state.initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = + &g_state.initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -317,7 +319,8 @@ static void test_receive_initial_metadata_twice_at_client() { cq_verify(g_state.cqv); op = g_state.ops; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &g_state.initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = + &g_state.initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -335,7 +338,7 @@ static void test_receive_message_with_invalid_flags() { prepare_test(1); op = g_state.ops; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &payload; + op->data.recv_message.recv_message = &payload; op->flags = 1; op->reserved = NULL; op++; @@ -353,12 +356,12 @@ static void test_receive_two_messages_at_the_same_time() { prepare_test(1); op = g_state.ops; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &payload; + op->data.recv_message.recv_message = &payload; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &payload; + op->data.recv_message.recv_message = &payload; op->flags = 0; op->reserved = NULL; op++; @@ -398,8 +401,6 @@ static void test_recv_status_on_client_twice() { &g_state.trailing_metadata_recv; op->data.recv_status_on_client.status = &g_state.status; op->data.recv_status_on_client.status_details = &g_state.details; - op->data.recv_status_on_client.status_details_capacity = - &g_state.details_capacity; op->flags = 0; op->reserved = NULL; op++; @@ -414,7 +415,6 @@ static void test_recv_status_on_client_twice() { op->data.recv_status_on_client.trailing_metadata = NULL; op->data.recv_status_on_client.status = NULL; op->data.recv_status_on_client.status_details = NULL; - op->data.recv_status_on_client.status_details_capacity = NULL; op->flags = 0; op->reserved = NULL; op++; @@ -453,8 +453,6 @@ static void test_recv_status_on_client_from_server() { &g_state.trailing_metadata_recv; op->data.recv_status_on_client.status = &g_state.status; op->data.recv_status_on_client.status_details = &g_state.details; - op->data.recv_status_on_client.status_details_capacity = - &g_state.details_capacity; op->flags = 0; op->reserved = NULL; op++; @@ -474,7 +472,8 @@ static void test_send_status_from_server_with_invalid_flags() { 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 1; op->reserved = NULL; op++; @@ -495,7 +494,8 @@ static void test_too_many_trailing_metadata() { op->data.send_status_from_server.trailing_metadata_count = (size_t)INT_MAX + 1; op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -515,14 +515,15 @@ static void test_send_server_status_twice() { 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -577,9 +578,8 @@ 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; + metadata.key = grpc_slice_from_static_string(":start_with_colon"); + metadata.value = grpc_slice_from_static_string("value"); grpc_op *op; prepare_test(1); @@ -599,6 +599,7 @@ static void test_invalid_initial_metadata_reserved_key() { int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); + test_invalid_initial_metadata_reserved_key(); test_non_null_reserved_on_start_batch(); test_non_null_reserved_on_op(); test_send_initial_metadata_more_than_once(); @@ -618,7 +619,6 @@ 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/no_server_test.c b/test/core/end2end/no_server_test.c index 03ff70a188..26d26d8f7a 100644 --- a/test/core/end2end/no_server_test.c +++ b/test/core/end2end/no_server_test.c @@ -45,15 +45,14 @@ static void *tag(intptr_t i) { return (void *)i; } int main(int argc, char **argv) { grpc_channel *chan; grpc_call *call; - gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2); + gpr_timespec deadline = grpc_timeout_seconds_to_deadline(2); grpc_completion_queue *cq; cq_verifier *cqv; grpc_op ops[6]; grpc_op *op; grpc_metadata_array trailing_metadata_recv; grpc_status_code status; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; grpc_test_init(argc, argv); grpc_init(); @@ -65,8 +64,10 @@ int main(int argc, char **argv) { /* create a call, channel to a non existant server */ chan = grpc_insecure_channel_create("nonexistant:54321", NULL, NULL); + grpc_slice host = grpc_slice_from_static_string("nonexistant"); call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, - "/Foo", "nonexistant", deadline, NULL); + grpc_slice_from_static_string("/Foo"), &host, + deadline, NULL); memset(ops, 0, sizeof(ops)); op = ops; @@ -79,7 +80,6 @@ int main(int argc, char **argv) { 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++; @@ -101,7 +101,7 @@ int main(int argc, char **argv) { grpc_channel_destroy(chan); cq_verifier_destroy(cqv); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_shutdown(); diff --git a/test/core/end2end/tests/authority_not_supported.c b/test/core/end2end/tests/authority_not_supported.c index 705970f6ca..7db2fd6b27 100644 --- a/test/core/end2end/tests/authority_not_supported.c +++ b/test/core/end2end/tests/authority_not_supported.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -103,9 +103,14 @@ static void test_with_authority_header(grpc_end2end_test_config config) { grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); - grpc_metadata meta_c[2] = { - {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"), + grpc_slice_from_static_string("val1"), + 0, + {{NULL, NULL, NULL, NULL}}}, + {grpc_slice_from_static_string("key2"), + grpc_slice_from_static_string("val2"), + 0, + {{NULL, NULL, NULL, NULL}}}}; grpc_end2end_test_fixture f = begin_test(config, "test_with_authority_header", NULL, NULL); cq_verifier *cqv = cq_verifier_create(f.cq); @@ -116,11 +121,12 @@ static void test_with_authority_header(grpc_end2end_test_config config) { grpc_byte_buffer *response_payload_recv = NULL; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; + grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr"); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + grpc_slice_from_static_string("/foo"), &host, + deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -135,7 +141,7 @@ static void test_with_authority_header(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -144,12 +150,12 @@ static void test_with_authority_header(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -157,7 +163,6 @@ static void test_with_authority_header(grpc_end2end_test_config config) { 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++; @@ -169,7 +174,7 @@ static void test_with_authority_header(grpc_end2end_test_config config) { GPR_ASSERT(status == GRPC_STATUS_CANCELLED); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c index e0c7ac7c02..f50a5805a2 100644 --- a/test/core/end2end/tests/bad_hostname.c +++ b/test/core/end2end/tests/bad_hostname.c @@ -52,7 +52,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); config.init_client(&f, client_args); config.init_server(&f, server_args); @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +76,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -109,11 +109,12 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; + grpc_slice host = grpc_slice_from_static_string("slartibartfast.local"); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "slartibartfast.local", deadline, NULL); + grpc_slice_from_static_string("/foo"), &host, + deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -133,7 +134,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -141,7 +142,6 @@ static void simple_request_body(grpc_end2end_test_fixture f) { 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++; @@ -153,7 +153,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { GPR_ASSERT(status == GRPC_STATUS_INTERNAL); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index dd7a8a9ad3..7fb60f4495 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -110,25 +110,25 @@ static void test_request_response_with_metadata_and_payload( grpc_raw_byte_buffer_create(&response_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); grpc_metadata meta_c[2] = { - {"key1-bin", - "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", - 13, + {grpc_slice_from_static_string("key1-bin"), + grpc_slice_from_static_string( + "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc"), 0, {{NULL, NULL, NULL, NULL}}}, - {"key2-bin", - "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", - 14, + {grpc_slice_from_static_string("key2-bin"), + grpc_slice_from_static_string( + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d"), 0, {{NULL, NULL, NULL, NULL}}}}; grpc_metadata meta_s[2] = { - {"key3-bin", - "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee", - 15, + {grpc_slice_from_static_string("key3-bin"), + grpc_slice_from_static_string( + "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee"), 0, {{NULL, NULL, NULL, NULL}}}, - {"key4-bin", - "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", - 16, + {grpc_slice_from_static_string("key4-bin"), + grpc_slice_from_static_string( + "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"), 0, {{NULL, NULL, NULL, NULL}}}}; grpc_end2end_test_fixture f = begin_test( @@ -144,13 +144,13 @@ static void test_request_response_with_metadata_and_payload( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -168,7 +168,7 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -177,12 +177,12 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -190,7 +190,6 @@ static void test_request_response_with_metadata_and_payload( 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++; @@ -213,7 +212,7 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -231,14 +230,14 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; 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 = + grpc_slice status_string = grpc_slice_from_static_string( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12" "\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24" "\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36" @@ -253,7 +252,8 @@ static void test_request_response_with_metadata_and_payload( "\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8" "\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea" "\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc" - "\xfd\xfe\xff"; + "\xfd\xfe\xff"); + op->data.send_status_from_server.status_details = &status_string; op->flags = 0; op->reserved = NULL; op++; @@ -267,24 +267,25 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT( 0 == - strcmp(details, - "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10" - "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20" - "\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30" - "\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40" - "\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50" - "\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60" - "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70" - "\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80" - "\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90" - "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0" - "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0" - "\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0" - "\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0" - "\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0" - "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0" - "\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + grpc_slice_str_cmp( + details, + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10" + "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20" + "\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30" + "\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40" + "\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50" + "\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60" + "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70" + "\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80" + "\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90" + "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0" + "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0" + "\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0" + "\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0" + "\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0" + "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0" + "\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); @@ -303,7 +304,7 @@ static void test_request_response_with_metadata_and_payload( &initial_metadata_recv, "key4-bin", "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 606938fff6..38cba50e12 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -59,7 +59,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, int fail_server_auth_check) { grpc_end2end_test_fixture f; - gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(NULL, NULL); config.init_client(&f, NULL); if (fail_server_auth_check) { @@ -76,7 +76,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -92,7 +92,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -156,8 +156,7 @@ static void request_response_with_payload_and_call_creds( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; grpc_call_credentials *creds = NULL; grpc_auth_context *s_auth_context = NULL; @@ -167,8 +166,9 @@ static void request_response_with_payload_and_call_creds( cqv = cq_verifier_create(f.cq); 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL); @@ -203,7 +203,7 @@ static void request_response_with_payload_and_call_creds( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -212,12 +212,12 @@ static void request_response_with_payload_and_call_creds( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -225,7 +225,6 @@ static void request_response_with_payload_and_call_creds( 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++; @@ -259,7 +258,7 @@ static void request_response_with_payload_and_call_creds( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -277,14 +276,15 @@ static void request_response_with_payload_and_call_creds( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; 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"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -296,8 +296,8 @@ static void request_response_with_payload_and_call_creds( cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); @@ -337,7 +337,7 @@ static void request_response_with_payload_and_call_creds( break; } - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -391,8 +391,7 @@ static void test_request_with_server_rejecting_client_creds( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; grpc_byte_buffer *response_payload_recv = NULL; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); @@ -404,8 +403,9 @@ static void test_request_with_server_rejecting_client_creds( cqv = cq_verifier_create(f.cq); 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -425,7 +425,6 @@ static void test_request_with_server_rejecting_client_creds( 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++; @@ -435,7 +434,7 @@ static void test_request_with_server_rejecting_client_creds( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -444,12 +443,12 @@ static void test_request_with_server_rejecting_client_creds( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -468,7 +467,7 @@ static void test_request_with_server_rejecting_client_creds( grpc_byte_buffer_destroy(request_payload); grpc_byte_buffer_destroy(response_payload_recv); - gpr_free(details); + grpc_slice_unref(details); grpc_call_destroy(c); diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index e582c59f2d..1a92aa4837 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -43,6 +43,7 @@ #include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" @@ -56,7 +57,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -64,7 +65,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -80,7 +81,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -118,8 +119,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; grpc_byte_buffer *request_payload_recv = NULL; grpc_byte_buffer *response_payload_recv = NULL; grpc_slice request_payload_slice = @@ -154,8 +154,9 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, cq_verifier *cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call( - f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/service/method", - get_host_override_string("foo.test.google.fr:1234", config), deadline, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/service/method"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -170,7 +171,6 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, 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++; @@ -180,17 +180,17 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -206,7 +206,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -216,7 +216,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; op->flags = 0; op->reserved = NULL; op++; @@ -246,12 +246,16 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, grpc_byte_buffer_destroy(response_payload); grpc_byte_buffer_destroy(request_payload_recv); grpc_byte_buffer_destroy(response_payload_recv); - gpr_free(details); + grpc_slice_unref(details); 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/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index 7742f9d179..0afeecb037 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -51,7 +51,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -59,7 +59,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -75,7 +75,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -113,8 +113,7 @@ static void test_cancel_after_accept_and_writes_closed( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; grpc_byte_buffer *request_payload_recv = NULL; grpc_byte_buffer *response_payload_recv = NULL; grpc_slice request_payload_slice = @@ -128,8 +127,9 @@ static void test_cancel_after_accept_and_writes_closed( 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -144,7 +144,6 @@ static void test_cancel_after_accept_and_writes_closed( 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++; @@ -154,7 +153,7 @@ static void test_cancel_after_accept_and_writes_closed( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -163,12 +162,12 @@ static void test_cancel_after_accept_and_writes_closed( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -184,7 +183,7 @@ static void test_cancel_after_accept_and_writes_closed( memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -199,7 +198,7 @@ static void test_cancel_after_accept_and_writes_closed( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; op->flags = 0; op->reserved = NULL; op++; @@ -224,7 +223,7 @@ static void test_cancel_after_accept_and_writes_closed( grpc_byte_buffer_destroy(response_payload); grpc_byte_buffer_destroy(request_payload_recv); grpc_byte_buffer_destroy(response_payload_recv); - gpr_free(details); + grpc_slice_unref(details); grpc_call_destroy(c); grpc_call_destroy(s); diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index c3c5418f20..8a96ef2f89 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -52,7 +52,8 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log(GPR_INFO, "%s/%s/%s", test_name, config.name, mode.name); + gpr_log(GPR_INFO, "Running test: %s/%s/%s", test_name, config.name, + mode.name); f = config.create_fixture(client_args, server_args); config.init_server(&f, server_args); config.init_client(&f, client_args); @@ -60,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +77,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -113,8 +114,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; grpc_byte_buffer *response_payload_recv = NULL; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); @@ -122,8 +122,9 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, grpc_raw_byte_buffer_create(&request_payload_slice, 1); 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -138,7 +139,6 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, 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++; @@ -148,7 +148,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -157,12 +157,12 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -183,7 +183,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, grpc_byte_buffer_destroy(request_payload); grpc_byte_buffer_destroy(response_payload_recv); - gpr_free(details); + grpc_slice_unref(details); grpc_call_destroy(c); diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index d4842829c0..586aa7ead3 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -111,8 +111,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; grpc_byte_buffer *response_payload_recv = NULL; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); @@ -120,8 +119,9 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, grpc_raw_byte_buffer_create(&request_payload_slice, 1); 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -138,7 +138,6 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, 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++; @@ -148,7 +147,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -157,12 +156,12 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -181,7 +180,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, grpc_byte_buffer_destroy(request_payload); grpc_byte_buffer_destroy(response_payload_recv); - gpr_free(details); + grpc_slice_unref(details); grpc_call_destroy(c); diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index 5be850b6ea..bc462ddcf5 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -51,7 +51,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -59,7 +59,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -75,7 +75,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -106,8 +106,9 @@ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config, cq_verifier *v_client = cq_verifier_create(f.cq); 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index 3aecaf7159..7d03fe5580 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -52,7 +52,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +76,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -108,14 +108,14 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_metadata_array trailing_metadata_recv; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -128,12 +128,11 @@ static void simple_request_body(grpc_end2end_test_config config, 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++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -156,9 +155,9 @@ static void simple_request_body(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 81fc7091f8..7dd8c112d1 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -48,6 +48,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/call_test_only.h" +#include "src/core/lib/transport/static_metadata.h" #include "test/core/end2end/cq_verifier.h" static void *tag(intptr_t t) { return (void *)t; } @@ -57,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -65,7 +66,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -81,7 +82,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -125,8 +126,7 @@ static void request_for_disabled_algorithm( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; cq_verifier *cqv; char str[1024]; @@ -140,15 +140,20 @@ 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); 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -170,7 +175,7 @@ static void request_for_disabled_algorithm( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = send_flags_bitmask; op->reserved = NULL; op++; @@ -179,7 +184,7 @@ static void request_for_disabled_algorithm( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -187,7 +192,6 @@ static void request_for_disabled_algorithm( 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++; @@ -208,7 +212,7 @@ static void request_for_disabled_algorithm( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -241,13 +245,13 @@ static void request_for_disabled_algorithm( gpr_asprintf(&expected_details, "Compression algorithm '%s' is disabled.", algo_name); /* and we expect a specific reason for it */ - GPR_ASSERT(0 == strcmp(details, expected_details)); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, expected_details)); gpr_free(expected_details); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -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); @@ -297,8 +305,7 @@ static void request_with_payload_template( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; cq_verifier *cqv; char request_str[1024]; @@ -323,8 +330,9 @@ static void request_with_payload_template( cqv = cq_verifier_create(f.cq); 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -346,7 +354,7 @@ static void request_with_payload_template( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -354,7 +362,6 @@ static void request_with_payload_template( 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++; @@ -404,12 +411,12 @@ static void request_with_payload_template( memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = client_send_flags_bitmask; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -419,7 +426,7 @@ static void request_with_payload_template( memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -436,7 +443,7 @@ static void request_with_payload_template( memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; op->flags = 0; op->reserved = NULL; op++; @@ -481,7 +488,8 @@ static void request_with_payload_template( 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"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -495,13 +503,13 @@ static void request_with_payload_template( cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -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); @@ -557,17 +569,14 @@ static void test_invoke_request_with_compressed_payload_md_override( grpc_metadata gzip_compression_override; grpc_metadata identity_compression_override; - gzip_compression_override.key = GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY; - gzip_compression_override.value = "gzip"; - gzip_compression_override.value_length = - strlen(gzip_compression_override.value); + gzip_compression_override.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST; + gzip_compression_override.value = grpc_slice_from_static_string("gzip"); memset(&gzip_compression_override.internal_data, 0, sizeof(gzip_compression_override.internal_data)); - identity_compression_override.key = GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY; - identity_compression_override.value = "identity"; - identity_compression_override.value_length = - strlen(identity_compression_override.value); + identity_compression_override.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST; + identity_compression_override.value = + grpc_slice_from_static_string("identity"); memset(&identity_compression_override.internal_data, 0, sizeof(identity_compression_override.internal_data)); diff --git a/test/core/end2end/tests/connectivity.c b/test/core/end2end/tests/connectivity.c index 42475c7331..979419a100 100644 --- a/test/core/end2end/tests/connectivity.c +++ b/test/core/end2end/tests/connectivity.c @@ -89,7 +89,7 @@ static void test_connectivity(grpc_end2end_test_config config) { /* channels should start life in IDLE, and stay there */ GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 0) == GRPC_CHANNEL_IDLE); - gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100)); + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100)); GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 0) == GRPC_CHANNEL_IDLE); @@ -106,7 +106,7 @@ static void test_connectivity(grpc_end2end_test_config config) { GRPC_CHANNEL_IDLE); /* start watching for a change */ grpc_channel_watch_connectivity_state(f.client, GRPC_CHANNEL_IDLE, - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), + grpc_timeout_seconds_to_deadline(3), f.cq, tag(2)); /* and now the watch should trigger */ @@ -118,7 +118,7 @@ static void test_connectivity(grpc_end2end_test_config config) { /* quickly followed by a transition to TRANSIENT_FAILURE */ grpc_channel_watch_connectivity_state(f.client, GRPC_CHANNEL_CONNECTING, - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), + grpc_timeout_seconds_to_deadline(3), f.cq, tag(3)); CQ_EXPECT_COMPLETION(cqv, tag(3), 1); cq_verify(cqv); @@ -137,7 +137,7 @@ static void test_connectivity(grpc_end2end_test_config config) { READY is reached */ while (state != GRPC_CHANNEL_READY) { grpc_channel_watch_connectivity_state( - f.client, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(4)); + f.client, state, grpc_timeout_seconds_to_deadline(3), f.cq, tag(4)); CQ_EXPECT_COMPLETION(cqv, tag(4), 1); cq_verify(cqv); state = grpc_channel_check_connectivity_state(f.client, 0); @@ -151,7 +151,7 @@ static void test_connectivity(grpc_end2end_test_config config) { gpr_log(GPR_DEBUG, "*** SHUTTING DOWN SERVER ***"); grpc_channel_watch_connectivity_state(f.client, GRPC_CHANNEL_READY, - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), + grpc_timeout_seconds_to_deadline(3), f.cq, tag(5)); grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead)); diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c index 208e31697e..bc1829b24b 100644 --- a/test/core/end2end/tests/default_host.c +++ b/test/core/end2end/tests/default_host.c @@ -52,7 +52,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); config.init_client(&f, client_args); config.init_server(&f, server_args); @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +76,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -110,13 +110,13 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; char *peer; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", NULL, deadline, NULL); + grpc_slice_from_static_string("/foo"), NULL, + deadline, NULL); GPR_ASSERT(c); peer = grpc_call_get_peer(c); @@ -141,7 +141,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -149,7 +149,6 @@ static void simple_request_body(grpc_end2end_test_fixture f) { 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++; @@ -182,7 +181,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) { 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -199,12 +199,12 @@ static void simple_request_body(grpc_end2end_test_fixture f) { cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strncmp(call_details.host, "localhost", 9)); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); + GPR_ASSERT(grpc_slice_buf_start_eq(call_details.host, "localhost", 9)); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index 8ebf7e643e..05440a6f56 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -46,7 +46,7 @@ static void *tag(intptr_t t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -93,13 +93,13 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -120,7 +120,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -128,7 +128,6 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config, 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++; @@ -156,7 +155,8 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -174,13 +174,13 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -194,7 +194,8 @@ static void disappearing_server_test(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL); cq_verifier *cqv = cq_verifier_create(f.cq); - gpr_log(GPR_INFO, "%s/%s", "disappearing_server_test", config.name); + gpr_log(GPR_INFO, "Running test: %s/%s", "disappearing_server_test", + config.name); config.init_client(&f, NULL); config.init_server(&f, NULL); diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index dc8e52a60f..50bb6b849e 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -52,7 +52,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +76,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -106,8 +106,9 @@ static void empty_batch_body(grpc_end2end_test_config config, grpc_op *op = NULL; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.c index 6d9351ed8c..7e189164b2 100644 --- a/test/core/end2end/tests/filter_call_init_fails.c +++ b/test/core/end2end/tests/filter_call_init_fails.c @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -66,7 +66,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -82,7 +82,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -125,12 +125,12 @@ static void test_request(grpc_end2end_test_config config) { grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -148,7 +148,7 @@ static void test_request(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -157,7 +157,7 @@ static void test_request(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -165,7 +165,6 @@ static void test_request(grpc_end2end_test_config config) { 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++; @@ -181,9 +180,9 @@ static void test_request(grpc_end2end_test_config config) { cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_PERMISSION_DENIED); - GPR_ASSERT(0 == strcmp(details, "access denied")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "access denied")); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -243,7 +242,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 21905b98fa..308b4de71b 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -55,7 +55,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -63,7 +63,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -79,7 +79,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -121,12 +121,12 @@ static void test_request(grpc_end2end_test_config config) { grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -144,7 +144,7 @@ static void test_request(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -153,7 +153,7 @@ static void test_request(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -161,7 +161,6 @@ static void test_request(grpc_end2end_test_config config) { 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++; @@ -177,9 +176,10 @@ static void test_request(grpc_end2end_test_config config) { cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_PERMISSION_DENIED); - GPR_ASSERT(0 == strcmp(details, "Failure that's not preventable.")); + GPR_ASSERT(0 == + grpc_slice_str_cmp(details, "Failure that's not preventable.")); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -208,18 +208,12 @@ static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { grpc_call_element *elem = arg; call_data *calld = elem->call_data; - if (error == GRPC_ERROR_NONE) { - // close the stream with an error. - 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_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_set_int(GRPC_ERROR_CREATE_REFERENCING( + "Failure that's not preventable.", &error, 1), + GRPC_ERROR_INT_GRPC_STATUS, + GRPC_STATUS_PERMISSION_DENIED)); } static void start_transport_stream_op(grpc_exec_ctx *exec_ctx, @@ -228,7 +222,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); } @@ -270,7 +265,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 e10204863b..13d2ae012c 100644 --- a/test/core/end2end/tests/filter_latency.c +++ b/test/core/end2end/tests/filter_latency.c @@ -62,7 +62,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -70,7 +70,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -86,7 +86,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -128,8 +128,7 @@ static void test_request(grpc_end2end_test_config config) { grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; gpr_mu_lock(&g_mu); @@ -138,8 +137,10 @@ static void test_request(grpc_end2end_test_config config) { gpr_mu_unlock(&g_mu); const gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -156,7 +157,7 @@ static void test_request(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -165,7 +166,7 @@ static void test_request(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -173,7 +174,6 @@ static void test_request(grpc_end2end_test_config config) { 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++; @@ -198,7 +198,8 @@ static void test_request(grpc_end2end_test_config config) { 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_string = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_string; op->flags = 0; op->reserved = NULL; op++; @@ -215,9 +216,9 @@ static void test_request(grpc_end2end_test_config config) { cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -322,7 +323,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/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index 5fecadbe44..a3ad260cc2 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -107,13 +107,13 @@ static void test_early_server_shutdown_finishes_inflight_calls( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -135,7 +135,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -143,7 +143,6 @@ static void test_early_server_shutdown_finishes_inflight_calls( 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++; @@ -171,7 +170,8 @@ static void test_early_server_shutdown_finishes_inflight_calls( 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -191,12 +191,12 @@ static void test_early_server_shutdown_finishes_inflight_calls( grpc_call_destroy(s); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 01a4909ccd..cca8532b0e 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -54,7 +54,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -62,7 +62,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -78,7 +78,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -113,13 +113,13 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -140,7 +140,7 @@ static void simple_request_body(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -148,7 +148,6 @@ static void simple_request_body(grpc_end2end_test_config config, 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++; @@ -172,7 +171,8 @@ static void simple_request_body(grpc_end2end_test_config config, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -189,13 +189,13 @@ static void simple_request_body(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -233,7 +233,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config, f = begin_test(config, name, &client_args, NULL); for (i = 0; i < 10; i++) { simple_request_body(config, f); - gpr_log(GPR_INFO, "Passed simple request %d", i); + gpr_log(GPR_INFO, "Running test: Passed simple request %d", i); } end_test(&f); config.tear_down_data(&f); diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index cec8b2faae..7601722dee 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -194,7 +194,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -202,7 +202,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -218,7 +218,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -254,24 +254,24 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_status_code status; grpc_call_error error; grpc_metadata extra_metadata[3]; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; memset(extra_metadata, 0, sizeof(extra_metadata)); - extra_metadata[0].key = "hobbit-first-name"; - extra_metadata[0].value = hobbits[index % GPR_ARRAY_SIZE(hobbits)][0]; - extra_metadata[0].value_length = strlen(extra_metadata[0].value); - extra_metadata[1].key = "hobbit-second-name"; - extra_metadata[1].value = hobbits[index % GPR_ARRAY_SIZE(hobbits)][1]; - extra_metadata[1].value_length = strlen(extra_metadata[1].value); - extra_metadata[2].key = "dragon"; - extra_metadata[2].value = dragons[index % GPR_ARRAY_SIZE(dragons)]; - extra_metadata[2].value_length = strlen(extra_metadata[2].value); + extra_metadata[0].key = grpc_slice_from_static_string("hobbit-first-name"); + extra_metadata[0].value = grpc_slice_from_static_string( + hobbits[index % GPR_ARRAY_SIZE(hobbits)][0]); + extra_metadata[1].key = grpc_slice_from_static_string("hobbit-second-name"); + extra_metadata[1].value = grpc_slice_from_static_string( + hobbits[index % GPR_ARRAY_SIZE(hobbits)][1]); + extra_metadata[2].key = grpc_slice_from_static_string("dragon"); + extra_metadata[2].value = + grpc_slice_from_static_string(dragons[index % GPR_ARRAY_SIZE(dragons)]); 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -293,7 +293,7 @@ static void simple_request_body(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -301,7 +301,6 @@ static void simple_request_body(grpc_end2end_test_config config, 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++; @@ -325,7 +324,8 @@ static void simple_request_body(grpc_end2end_test_config config, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -342,13 +342,13 @@ static void simple_request_body(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index 4f6d3bb808..cef2e100be 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -52,7 +52,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +76,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -111,14 +111,14 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; char *peer; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -144,7 +144,7 @@ static void simple_request_body(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -152,7 +152,6 @@ static void simple_request_body(grpc_end2end_test_config config, 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++; @@ -185,7 +184,8 @@ static void simple_request_body(grpc_end2end_test_config config, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -202,14 +202,14 @@ static void simple_request_body(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST == call_details.flags); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 24abfa2ea0..d799bd8ccf 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -51,7 +51,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -59,7 +59,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static void drain_cq(grpc_completion_queue *cq) { @@ -73,7 +73,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -140,13 +140,13 @@ static void test_invoke_large_request(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -163,7 +163,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -172,12 +172,12 @@ static void test_invoke_large_request(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -185,7 +185,6 @@ static void test_invoke_large_request(grpc_end2end_test_config config, 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++; @@ -207,7 +206,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -225,14 +224,15 @@ static void test_invoke_large_request(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -244,13 +244,13 @@ static void test_invoke_large_request(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index 69b4b24b06..ac4c0e7f3b 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -122,21 +122,19 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); - meta.key = "key"; - meta.value = gpr_malloc(large_size + 1); - memset((char *)meta.value, 'a', large_size); - ((char *)meta.value)[large_size] = 0; - meta.value_length = large_size; + meta.key = grpc_slice_from_static_string("key"); + meta.value = grpc_slice_malloc(large_size); + memset(GRPC_SLICE_START_PTR(meta.value), 'a', large_size); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -153,7 +151,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -162,7 +160,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -170,7 +168,6 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { 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++; @@ -194,7 +191,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -216,7 +213,8 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { 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"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -228,15 +226,17 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(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_recv, "hello world")); - GPR_ASSERT(contains_metadata(&request_metadata_recv, "key", meta.value)); + GPR_ASSERT(contains_metadata_slices(&request_metadata_recv, + grpc_slice_from_static_string("key"), + meta.value)); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -250,7 +250,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { grpc_byte_buffer_destroy(request_payload); grpc_byte_buffer_destroy(request_payload_recv); - gpr_free((char *)meta.value); + grpc_slice_unref(meta.value); end_test(&f); config.tear_down_data(&f); diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index 5b75f26bd2..085a563fb8 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -74,7 +74,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); config.init_server(&f, server_args); @@ -84,7 +84,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -100,7 +100,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -146,13 +146,13 @@ static void request_response_with_payload( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; c = grpc_channel_create_call( - f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, method_name, - get_host_override_string("foo.test.google.fr:1234", config), deadline, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string(method_name), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -171,7 +171,7 @@ static void request_response_with_payload( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -180,12 +180,12 @@ static void request_response_with_payload( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -193,7 +193,6 @@ static void request_response_with_payload( 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++; @@ -215,7 +214,7 @@ static void request_response_with_payload( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -233,7 +232,7 @@ static void request_response_with_payload( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; op->flags = 0; op->reserved = NULL; op++; @@ -242,7 +241,8 @@ static void request_response_with_payload( op->data.send_status_from_server.trailing_metadata_count = 1; op->data.send_status_from_server.trailing_metadata = trailing_lr_metadata; op->data.send_status_from_server.status = GRPC_STATUS_OK; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -255,7 +255,7 @@ static void request_response_with_payload( GPR_ASSERT(status == GRPC_STATUS_OK); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -295,15 +295,13 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) { grpc_metadata initial_lr_metadata; grpc_metadata trailing_lr_metadata; - initial_lr_metadata.key = GRPC_LB_TOKEN_MD_KEY; - initial_lr_metadata.value = "client-token"; - initial_lr_metadata.value_length = strlen(initial_lr_metadata.value); + initial_lr_metadata.key = GRPC_MDSTR_LB_TOKEN; + initial_lr_metadata.value = grpc_slice_from_static_string("client-token"); memset(&initial_lr_metadata.internal_data, 0, sizeof(initial_lr_metadata.internal_data)); - trailing_lr_metadata.key = GRPC_LB_COST_MD_KEY; - trailing_lr_metadata.value = "server-token"; - trailing_lr_metadata.value_length = strlen(trailing_lr_metadata.value); + trailing_lr_metadata.key = GRPC_MDSTR_LB_COST_BIN; + trailing_lr_metadata.value = grpc_slice_from_static_string("server-token"); memset(&trailing_lr_metadata.internal_data, 0, sizeof(trailing_lr_metadata.internal_data)); @@ -311,7 +309,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_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 9338bc5f0d..e81a628944 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -109,13 +109,13 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -136,7 +136,7 @@ static void simple_request_body(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -144,7 +144,6 @@ static void simple_request_body(grpc_end2end_test_config config, 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++; @@ -168,7 +167,8 @@ static void simple_request_body(grpc_end2end_test_config config, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -185,13 +185,13 @@ static void simple_request_body(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -223,11 +223,9 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { grpc_metadata_array trailing_metadata_recv2; grpc_status_code status1; grpc_call_error error; - char *details1 = NULL; - size_t details_capacity1 = 0; + grpc_slice details1; grpc_status_code status2; - char *details2 = NULL; - size_t details_capacity2 = 0; + grpc_slice details2; grpc_op ops[6]; grpc_op *op; int was_cancelled; @@ -261,13 +259,15 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { the first completes */ deadline = n_seconds_time(1000); c1 = grpc_channel_create_call( - f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/alpha", - get_host_override_string("foo.test.google.fr:1234", config), deadline, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/alpha"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c1); c2 = grpc_channel_create_call( - f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/beta", - get_host_override_string("foo.test.google.fr:1234", config), deadline, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/beta"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c2); @@ -295,12 +295,12 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv1; op->data.recv_status_on_client.status = &status1; op->data.recv_status_on_client.status_details = &details1; - op->data.recv_status_on_client.status_details_capacity = &details_capacity1; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv1; + op->data.recv_initial_metadata.recv_initial_metadata = + &initial_metadata_recv1; op->flags = 0; op->reserved = NULL; op++; @@ -327,12 +327,12 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv2; op->data.recv_status_on_client.status = &status2; op->data.recv_status_on_client.status_details = &details2; - op->data.recv_status_on_client.status_details_capacity = &details_capacity2; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv1; + op->data.recv_initial_metadata.recv_initial_metadata = + &initial_metadata_recv1; op->flags = 0; op->reserved = NULL; op++; @@ -343,7 +343,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { got_server_start = 0; live_call = -1; while (!got_client_start || !got_server_start) { - ev = grpc_completion_queue_next(f.cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), + ev = grpc_completion_queue_next(f.cq, grpc_timeout_seconds_to_deadline(3), NULL); GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); GPR_ASSERT(ev.success); @@ -378,7 +378,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -392,6 +393,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { CQ_EXPECT_COMPLETION(cqv, tag(live_call + 1), 1); cq_verify(cqv); + grpc_call_details_destroy(&call_details); + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( f.server, &s2, &call_details, &request_metadata_recv, f.cq, f.cq, tag(201))); @@ -413,7 +416,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -431,8 +434,394 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { grpc_call_destroy(c2); grpc_call_destroy(s2); - gpr_free(details1); - gpr_free(details2); + grpc_slice_unref(details1); + grpc_slice_unref(details2); + grpc_metadata_array_destroy(&initial_metadata_recv1); + grpc_metadata_array_destroy(&trailing_metadata_recv1); + grpc_metadata_array_destroy(&initial_metadata_recv2); + grpc_metadata_array_destroy(&trailing_metadata_recv2); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + + end_test(&f); + config.tear_down_data(&f); +} + +static void test_max_concurrent_streams_with_timeout_on_first( + grpc_end2end_test_config config) { + grpc_end2end_test_fixture f; + grpc_arg server_arg; + grpc_channel_args server_args; + grpc_call *c1; + grpc_call *c2; + grpc_call *s1; + grpc_call *s2; + cq_verifier *cqv; + grpc_call_details call_details; + grpc_metadata_array request_metadata_recv; + grpc_metadata_array initial_metadata_recv1; + grpc_metadata_array trailing_metadata_recv1; + grpc_metadata_array initial_metadata_recv2; + grpc_metadata_array trailing_metadata_recv2; + grpc_status_code status1; + grpc_call_error error; + grpc_slice details1 = grpc_empty_slice(); + grpc_status_code status2; + grpc_slice details2 = grpc_empty_slice(); + grpc_op ops[6]; + grpc_op *op; + int was_cancelled; + + server_arg.key = GRPC_ARG_MAX_CONCURRENT_STREAMS; + server_arg.type = GRPC_ARG_INTEGER; + server_arg.value.integer = 1; + + server_args.num_args = 1; + server_args.args = &server_arg; + + f = begin_test(config, "test_max_concurrent_streams_with_timeout_on_first", + NULL, &server_args); + cqv = cq_verifier_create(f.cq); + + grpc_metadata_array_init(&request_metadata_recv); + grpc_metadata_array_init(&initial_metadata_recv1); + grpc_metadata_array_init(&trailing_metadata_recv1); + grpc_metadata_array_init(&initial_metadata_recv2); + grpc_metadata_array_init(&trailing_metadata_recv2); + grpc_call_details_init(&call_details); + + /* perform a ping-pong to ensure that settings have had a chance to round + trip */ + simple_request_body(config, f); + /* perform another one to make sure that the one stream case still works */ + simple_request_body(config, f); + + /* start two requests - ensuring that the second is not accepted until + the first completes */ + c1 = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/alpha"), + get_host_override_slice("foo.test.google.fr:1234", config), + n_seconds_time(3), NULL); + GPR_ASSERT(c1); + c2 = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/beta"), + get_host_override_slice("foo.test.google.fr:1234", config), + n_seconds_time(1000), NULL); + GPR_ASSERT(c2); + + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( + f.server, &s1, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101))); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + 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_recv1; + op->data.recv_status_on_client.status = &status1; + op->data.recv_status_on_client.status_details = &details1; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata.recv_initial_metadata = + &initial_metadata_recv1; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + CQ_EXPECT_COMPLETION(cqv, tag(101), 1); + CQ_EXPECT_COMPLETION(cqv, tag(301), 1); + cq_verify(cqv); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + 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_recv2; + op->data.recv_status_on_client.status = &status2; + op->data.recv_status_on_client.status_details = &details2; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata.recv_initial_metadata = + &initial_metadata_recv2; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + grpc_call_details_destroy(&call_details); + grpc_call_details_init(&call_details); + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( + f.server, &s2, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(201))); + + CQ_EXPECT_COMPLETION(cqv, tag(302), 1); + /* first request is finished, we should be able to start the second */ + CQ_EXPECT_COMPLETION(cqv, tag(401), 1); + CQ_EXPECT_COMPLETION(cqv, tag(201), 1); + cq_verify(cqv); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + 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_UNIMPLEMENTED; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s2, ops, (size_t)(op - ops), tag(202), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + CQ_EXPECT_COMPLETION(cqv, tag(402), 1); + CQ_EXPECT_COMPLETION(cqv, tag(202), 1); + cq_verify(cqv); + + cq_verifier_destroy(cqv); + + grpc_call_destroy(c1); + grpc_call_destroy(s1); + grpc_call_destroy(c2); + grpc_call_destroy(s2); + + grpc_slice_unref(details1); + grpc_slice_unref(details2); + grpc_metadata_array_destroy(&initial_metadata_recv1); + grpc_metadata_array_destroy(&trailing_metadata_recv1); + grpc_metadata_array_destroy(&initial_metadata_recv2); + grpc_metadata_array_destroy(&trailing_metadata_recv2); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + + end_test(&f); + config.tear_down_data(&f); +} + +static void test_max_concurrent_streams_with_timeout_on_second( + grpc_end2end_test_config config) { + grpc_end2end_test_fixture f; + grpc_arg server_arg; + grpc_channel_args server_args; + grpc_call *c1; + grpc_call *c2; + grpc_call *s1; + cq_verifier *cqv; + grpc_call_details call_details; + grpc_metadata_array request_metadata_recv; + grpc_metadata_array initial_metadata_recv1; + grpc_metadata_array trailing_metadata_recv1; + grpc_metadata_array initial_metadata_recv2; + grpc_metadata_array trailing_metadata_recv2; + grpc_status_code status1; + grpc_call_error error; + grpc_slice details1 = grpc_empty_slice(); + grpc_status_code status2; + grpc_slice details2 = grpc_empty_slice(); + grpc_op ops[6]; + grpc_op *op; + int was_cancelled; + + server_arg.key = GRPC_ARG_MAX_CONCURRENT_STREAMS; + server_arg.type = GRPC_ARG_INTEGER; + server_arg.value.integer = 1; + + server_args.num_args = 1; + server_args.args = &server_arg; + + f = begin_test(config, "test_max_concurrent_streams_with_timeout_on_second", + NULL, &server_args); + cqv = cq_verifier_create(f.cq); + + grpc_metadata_array_init(&request_metadata_recv); + grpc_metadata_array_init(&initial_metadata_recv1); + grpc_metadata_array_init(&trailing_metadata_recv1); + grpc_metadata_array_init(&initial_metadata_recv2); + grpc_metadata_array_init(&trailing_metadata_recv2); + grpc_call_details_init(&call_details); + + /* perform a ping-pong to ensure that settings have had a chance to round + trip */ + simple_request_body(config, f); + /* perform another one to make sure that the one stream case still works */ + simple_request_body(config, f); + + /* start two requests - ensuring that the second is not accepted until + the first completes , and the second request will timeout in the + concurrent_list */ + c1 = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/alpha"), + get_host_override_slice("foo.test.google.fr:1234", config), + n_seconds_time(1000), NULL); + GPR_ASSERT(c1); + c2 = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/beta"), + get_host_override_slice("foo.test.google.fr:1234", config), + n_seconds_time(3), NULL); + GPR_ASSERT(c2); + + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( + f.server, &s1, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101))); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + 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_recv1; + op->data.recv_status_on_client.status = &status1; + op->data.recv_status_on_client.status_details = &details1; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata.recv_initial_metadata = + &initial_metadata_recv1; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + CQ_EXPECT_COMPLETION(cqv, tag(101), 1); + CQ_EXPECT_COMPLETION(cqv, tag(301), 1); + cq_verify(cqv); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + 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_recv2; + op->data.recv_status_on_client.status = &status2; + op->data.recv_status_on_client.status_details = &details2; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata.recv_initial_metadata = + &initial_metadata_recv2; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + /* the second request is time out*/ + CQ_EXPECT_COMPLETION(cqv, tag(401), 0); + CQ_EXPECT_COMPLETION(cqv, tag(402), 1); + cq_verify(cqv); + + /* second request is finished because of time out, so destroy the second call + */ + grpc_call_destroy(c2); + + /* now reply the first call */ + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + 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_UNIMPLEMENTED; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s1, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + CQ_EXPECT_COMPLETION(cqv, tag(302), 1); + CQ_EXPECT_COMPLETION(cqv, tag(102), 1); + cq_verify(cqv); + + cq_verifier_destroy(cqv); + + grpc_call_destroy(c1); + grpc_call_destroy(s1); + + grpc_slice_unref(details1); + grpc_slice_unref(details2); grpc_metadata_array_destroy(&initial_metadata_recv1); grpc_metadata_array_destroy(&trailing_metadata_recv1); grpc_metadata_array_destroy(&initial_metadata_recv2); @@ -445,6 +834,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { } void max_concurrent_streams(grpc_end2end_test_config config) { + test_max_concurrent_streams_with_timeout_on_first(config); + test_max_concurrent_streams_with_timeout_on_second(config); test_max_concurrent_streams(config); } diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index c222d9dfae..b15d30f58c 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -43,6 +43,7 @@ #include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" @@ -55,7 +56,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); // We intentionally do not pass the client and server args to // create_fixture(), since we don't want the limit enforced on the // proxy, only on the backend server. @@ -66,7 +67,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -82,7 +83,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -108,9 +109,12 @@ static void end_test(grpc_end2end_test_fixture *f) { // recv limit on server. static void test_max_message_length_on_request(grpc_end2end_test_config config, bool send_limit, - bool use_service_config) { - gpr_log(GPR_INFO, "testing request with send_limit=%d use_service_config=%d", - send_limit, use_service_config); + bool use_service_config, + bool use_string_json_value) { + gpr_log(GPR_INFO, + "testing request with send_limit=%d use_service_config=%d " + "use_string_json_value=%d", + send_limit, use_service_config, use_string_json_value); grpc_end2end_test_fixture f; grpc_call *c = NULL; @@ -129,8 +133,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; grpc_channel_args *client_args = NULL; @@ -142,14 +145,23 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, arg.type = GRPC_ARG_STRING; arg.key = GRPC_ARG_SERVICE_CONFIG; arg.value.string = - "{\n" - " \"methodConfig\": [ {\n" - " \"name\": [\n" - " { \"service\": \"service\", \"method\": \"method\" }\n" - " ],\n" - " \"maxRequestMessageBytes\": \"5\"\n" - " } ]\n" - "}"; + use_string_json_value + ? "{\n" + " \"methodConfig\": [ {\n" + " \"name\": [\n" + " { \"service\": \"service\", \"method\": \"method\" }\n" + " ],\n" + " \"maxRequestMessageBytes\": \"5\"\n" + " } ]\n" + "}" + : "{\n" + " \"methodConfig\": [ {\n" + " \"name\": [\n" + " { \"service\": \"service\", \"method\": \"method\" }\n" + " ],\n" + " \"maxRequestMessageBytes\": 5\n" + " } ]\n" + "}"; client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1); } else { // Set limit via channel args. @@ -168,14 +180,19 @@ 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); c = grpc_channel_create_call( - f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/service/method", - get_host_override_string("foo.test.google.fr:1234", config), + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/service/method"), + get_host_override_slice("foo.test.google.fr:1234", config), gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(c); @@ -192,7 +209,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -201,7 +218,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -209,7 +226,6 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, 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++; @@ -237,7 +253,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &recv_payload; + op->data.recv_message.recv_message = &recv_payload; op->flags = 0; op->reserved = NULL; op++; @@ -248,19 +264,20 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, CQ_EXPECT_COMPLETION(cqv, tag(1), 1); cq_verify(cqv); - GPR_ASSERT(0 == strcmp(call_details.method, "/service/method")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/service/method")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); done: GPR_ASSERT(status == GRPC_STATUS_INVALID_ARGUMENT); - GPR_ASSERT(strcmp(details, - send_limit - ? "Sent message larger than max (11 vs. 5)" - : "Received message larger than max (11 vs. 5)") == 0); + GPR_ASSERT( + grpc_slice_str_cmp( + details, send_limit + ? "Sent message larger than max (11 vs. 5)" + : "Received message larger than max (11 vs. 5)") == 0); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -282,9 +299,12 @@ done: // recv limit on client. static void test_max_message_length_on_response(grpc_end2end_test_config config, bool send_limit, - bool use_service_config) { - gpr_log(GPR_INFO, "testing response with send_limit=%d use_service_config=%d", - send_limit, use_service_config); + bool use_service_config, + bool use_string_json_value) { + gpr_log(GPR_INFO, + "testing response with send_limit=%d use_service_config=%d " + "use_string_json_value=%d", + send_limit, use_service_config, use_string_json_value); grpc_end2end_test_fixture f; grpc_call *c = NULL; @@ -303,8 +323,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; grpc_channel_args *client_args = NULL; @@ -316,14 +335,23 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, arg.type = GRPC_ARG_STRING; arg.key = GRPC_ARG_SERVICE_CONFIG; arg.value.string = - "{\n" - " \"methodConfig\": [ {\n" - " \"name\": [\n" - " { \"service\": \"service\", \"method\": \"method\" }\n" - " ],\n" - " \"maxResponseMessageBytes\": \"5\"\n" - " } ]\n" - "}"; + use_string_json_value + ? "{\n" + " \"methodConfig\": [ {\n" + " \"name\": [\n" + " { \"service\": \"service\", \"method\": \"method\" }\n" + " ],\n" + " \"maxResponseMessageBytes\": \"5\"\n" + " } ]\n" + "}" + : "{\n" + " \"methodConfig\": [ {\n" + " \"name\": [\n" + " { \"service\": \"service\", \"method\": \"method\" }\n" + " ],\n" + " \"maxResponseMessageBytes\": 5\n" + " } ]\n" + "}"; client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1); } else { // Set limit via channel args. @@ -342,14 +370,19 @@ 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, - "/service/method", "foo.test.google.fr:1234", - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/service/method"), + get_host_override_slice("foo.test.google.fr:1234", config), + gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -369,12 +402,12 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &recv_payload; + op->data.recv_message.recv_message = &recv_payload; op->flags = 0; op->reserved = NULL; op++; @@ -382,7 +415,6 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, 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++; @@ -409,14 +441,15 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; 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"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -427,16 +460,18 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, CQ_EXPECT_COMPLETION(cqv, tag(1), 1); cq_verify(cqv); - GPR_ASSERT(0 == strcmp(call_details.method, "/service/method")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/service/method")); + GPR_ASSERT(0 == + grpc_slice_str_cmp(call_details.host, "foo.test.google.fr:1234")); GPR_ASSERT(status == GRPC_STATUS_INVALID_ARGUMENT); - GPR_ASSERT(strcmp(details, - send_limit - ? "Sent message larger than max (11 vs. 5)" - : "Received message larger than max (11 vs. 5)") == 0); + GPR_ASSERT( + grpc_slice_str_cmp( + details, send_limit + ? "Sent message larger than max (11 vs. 5)" + : "Received message larger than max (11 vs. 5)") == 0); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -455,17 +490,29 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, void max_message_length(grpc_end2end_test_config config) { test_max_message_length_on_request(config, false /* send_limit */, - false /* use_service_config */); + false /* use_service_config */, + false /* use_string_json_value */); test_max_message_length_on_request(config, true /* send_limit */, - false /* use_service_config */); + false /* use_service_config */, + false /* use_string_json_value */); test_max_message_length_on_response(config, false /* send_limit */, - false /* use_service_config */); + false /* use_service_config */, + false /* use_string_json_value */); test_max_message_length_on_response(config, true /* send_limit */, - false /* use_service_config */); + false /* use_service_config */, + false /* use_string_json_value */); + test_max_message_length_on_request(config, true /* send_limit */, + true /* use_service_config */, + false /* use_string_json_value */); test_max_message_length_on_request(config, true /* send_limit */, - true /* use_service_config */); + true /* use_service_config */, + true /* use_string_json_value */); + test_max_message_length_on_response(config, false /* send_limit */, + true /* use_service_config */, + false /* use_string_json_value */); test_max_message_length_on_response(config, false /* send_limit */, - true /* use_service_config */); + true /* use_service_config */, + true /* use_string_json_value */); } void max_message_length_pre_init(void) {} diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index 929777d39e..0b61efbac9 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -52,7 +52,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +76,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -108,14 +108,14 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_metadata_array trailing_metadata_recv; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -128,12 +128,11 @@ static void simple_request_body(grpc_end2end_test_config config, 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++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -155,7 +154,7 @@ static void simple_request_body(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_DEADLINE_EXCEEDED); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c index 2ebda2ccb8..9cef02b2b3 100644 --- a/test/core/end2end/tests/network_status_change.c +++ b/test/core/end2end/tests/network_status_change.c @@ -53,7 +53,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(500); } @@ -77,7 +77,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -119,13 +119,13 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -142,7 +142,7 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -151,7 +151,7 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -159,7 +159,6 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { 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++; @@ -179,7 +178,7 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -201,7 +200,8 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { 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"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -214,11 +214,11 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { // Expected behavior of a RPC when network is lost. GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/no_logging.c b/test/core/end2end/tests/no_logging.c index 54614cb029..56e48a88a8 100644 --- a/test/core/end2end/tests/no_logging.c +++ b/test/core/end2end/tests/no_logging.c @@ -80,7 +80,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -88,7 +88,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -104,7 +104,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -139,14 +139,14 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; char *peer; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -171,7 +171,7 @@ static void simple_request_body(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -179,7 +179,6 @@ static void simple_request_body(grpc_end2end_test_config config, 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++; @@ -210,7 +209,8 @@ static void simple_request_body(grpc_end2end_test_config config, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -227,14 +227,14 @@ static void simple_request_body(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(0 == call_details.flags); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/no_op.c b/test/core/end2end/tests/no_op.c index 8b29c219dc..62fc728c3e 100644 --- a/test/core/end2end/tests/no_op.c +++ b/test/core/end2end/tests/no_op.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index 4a88c5f2a8..b04ee5705c 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -138,13 +138,13 @@ static void request_response_with_payload(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -161,7 +161,7 @@ static void request_response_with_payload(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -170,12 +170,12 @@ static void request_response_with_payload(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -183,7 +183,6 @@ static void request_response_with_payload(grpc_end2end_test_config config, 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++; @@ -205,7 +204,7 @@ static void request_response_with_payload(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -223,14 +222,15 @@ static void request_response_with_payload(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; 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"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -242,8 +242,8 @@ static void request_response_with_payload(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); @@ -251,7 +251,7 @@ static void request_response_with_payload(grpc_end2end_test_config config, GPR_ASSERT( byte_buffer_eq_slice(response_payload_recv, response_payload_slice)); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/ping.c b/test/core/end2end/tests/ping.c index 5e5169dedc..f5bfac2255 100644 --- a/test/core/end2end/tests/ping.c +++ b/test/core/end2end/tests/ping.c @@ -37,6 +37,7 @@ #include <grpc/support/sync.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> +#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" @@ -48,7 +49,15 @@ static void test_ping(grpc_end2end_test_config config) { grpc_connectivity_state state = GRPC_CHANNEL_IDLE; int i; - config.init_client(&f, NULL); + grpc_arg a[] = {{.type = GRPC_ARG_INTEGER, + .key = GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS, + .value.integer = 0}, + {.type = GRPC_ARG_INTEGER, + .key = GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA, + .value.integer = 20}}; + grpc_channel_args client_args = {.num_args = GPR_ARRAY_SIZE(a), .args = a}; + + config.init_client(&f, &client_args); config.init_server(&f, NULL); grpc_channel_ping(f.client, f.cq, tag(0), NULL); @@ -61,7 +70,7 @@ static void test_ping(grpc_end2end_test_config config) { READY is reached */ while (state != GRPC_CHANNEL_READY) { grpc_channel_watch_connectivity_state( - f.client, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(99)); + f.client, state, grpc_timeout_seconds_to_deadline(3), f.cq, tag(99)); CQ_EXPECT_COMPLETION(cqv, tag(99), 1); cq_verify(cqv); state = grpc_channel_check_connectivity_state(f.client, 0); diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 0a1566e9c2..848f76018d 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -112,8 +112,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; grpc_byte_buffer *request_payload; grpc_byte_buffer *request_payload_recv; @@ -126,8 +125,9 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, grpc_slice_from_copied_string("hello you"); 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -144,7 +144,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -152,7 +152,6 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, 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++; @@ -188,12 +187,12 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -203,7 +202,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -215,7 +214,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; op->flags = 0; op->reserved = NULL; op++; @@ -248,7 +247,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -270,7 +270,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); grpc_call_details_destroy(&call_details); - gpr_free(details); + grpc_slice_unref(details); end_test(&f); config.tear_down_data(&f); diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index 6594b420b9..9c8ce89c83 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -52,7 +52,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +76,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -111,8 +111,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; c = grpc_channel_create_registered_call( @@ -136,7 +135,7 @@ static void simple_request_body(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -144,7 +143,6 @@ static void simple_request_body(grpc_end2end_test_config config, 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++; @@ -168,7 +166,8 @@ static void simple_request_body(grpc_end2end_test_config config, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -185,13 +184,13 @@ static void simple_request_body(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index 9c18e155f3..329359e08b 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -51,7 +51,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -59,7 +59,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -75,7 +75,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -117,13 +117,13 @@ static void test_invoke_request_with_flags( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; grpc_call_error expectation; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -140,7 +140,7 @@ static void test_invoke_request_with_flags( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = flags_for_op[op->op]; op->reserved = NULL; op++; @@ -149,7 +149,7 @@ static void test_invoke_request_with_flags( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = flags_for_op[op->op]; op->reserved = NULL; op++; @@ -157,7 +157,6 @@ static void test_invoke_request_with_flags( 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 = flags_for_op[op->op]; op->reserved = NULL; op++; @@ -168,9 +167,9 @@ static void test_invoke_request_with_flags( if (expectation == GRPC_CALL_OK) { CQ_EXPECT_COMPLETION(cqv, tag(1), 1); cq_verify(cqv); + grpc_slice_unref(details); } - gpr_free(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index c84e3ac5b5..f71f92bbb8 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -116,13 +116,13 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -139,7 +139,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -148,7 +148,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -156,7 +156,6 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { 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++; @@ -177,7 +176,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -197,7 +196,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { 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"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -209,14 +209,14 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(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_recv, "hello world")); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.c index c919faea89..4f9ed7a3a1 100644 --- a/test/core/end2end/tests/resource_quota_server.c +++ b/test/core/end2end/tests/resource_quota_server.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -149,8 +149,7 @@ void resource_quota_server(grpc_end2end_test_config config) { grpc_call_details *call_details = malloc(sizeof(grpc_call_details) * NUM_CALLS); grpc_status_code *status = malloc(sizeof(grpc_status_code) * NUM_CALLS); - char **details = malloc(sizeof(char *) * NUM_CALLS); - size_t *details_capacity = malloc(sizeof(size_t) * NUM_CALLS); + grpc_slice *details = malloc(sizeof(grpc_slice) * NUM_CALLS); grpc_byte_buffer **request_payload_recv = malloc(sizeof(grpc_byte_buffer *) * NUM_CALLS); int *was_cancelled = malloc(sizeof(int) * NUM_CALLS); @@ -161,6 +160,7 @@ void resource_quota_server(grpc_end2end_test_config config) { int pending_server_end_calls = 0; int cancelled_calls_on_client = 0; int cancelled_calls_on_server = 0; + int deadline_exceeded = 0; grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); @@ -173,8 +173,6 @@ void resource_quota_server(grpc_end2end_test_config config) { grpc_metadata_array_init(&trailing_metadata_recv[i]); grpc_metadata_array_init(&request_metadata_recv[i]); grpc_call_details_init(&call_details[i]); - details[i] = NULL; - details_capacity[i] = 0; request_payload_recv[i] = NULL; was_cancelled[i] = 0; } @@ -190,8 +188,10 @@ void resource_quota_server(grpc_end2end_test_config config) { for (int i = 0; i < NUM_CALLS; i++) { client_calls[i] = grpc_channel_create_call( - f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", - "foo.test.google.fr", n_seconds_time(60), NULL); + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr", config), + n_seconds_time(60), NULL); memset(ops, 0, sizeof(ops)); op = ops; @@ -201,7 +201,7 @@ void resource_quota_server(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -210,7 +210,8 @@ void resource_quota_server(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv[i]; + op->data.recv_initial_metadata.recv_initial_metadata = + &initial_metadata_recv[i]; op->flags = 0; op->reserved = NULL; op++; @@ -219,8 +220,6 @@ void resource_quota_server(grpc_end2end_test_config config) { &trailing_metadata_recv[i]; op->data.recv_status_on_client.status = &status[i]; op->data.recv_status_on_client.status_details = &details[i]; - op->data.recv_status_on_client.status_details_capacity = - &details_capacity[i]; op->flags = 0; op->reserved = NULL; op++; @@ -249,6 +248,9 @@ void resource_quota_server(grpc_end2end_test_config config) { case GRPC_STATUS_RESOURCE_EXHAUSTED: cancelled_calls_on_client++; break; + case GRPC_STATUS_DEADLINE_EXCEEDED: + deadline_exceeded++; + break; case GRPC_STATUS_OK: break; default: @@ -260,7 +262,7 @@ void resource_quota_server(grpc_end2end_test_config config) { grpc_metadata_array_destroy(&initial_metadata_recv[call_id]); grpc_metadata_array_destroy(&trailing_metadata_recv[call_id]); grpc_call_destroy(client_calls[call_id]); - gpr_free(details[call_id]); + grpc_slice_unref(details[call_id]); pending_client_calls--; } else if (ev_tag < SERVER_RECV_BASE_TAG) { @@ -277,7 +279,7 @@ void resource_quota_server(grpc_end2end_test_config config) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv[call_id]; + op->data.recv_message.recv_message = &request_payload_recv[call_id]; op->flags = 0; op->reserved = NULL; op++; @@ -317,7 +319,8 @@ void resource_quota_server(grpc_end2end_test_config config) { 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"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -344,24 +347,19 @@ void resource_quota_server(grpc_end2end_test_config config) { } } - gpr_log( - GPR_INFO, - "Done. %d total calls: %d cancelled at server, %d cancelled at client.", - NUM_CALLS, cancelled_calls_on_server, cancelled_calls_on_client); - - /* The call may be cancelled after the server has sent its status but before - * the client has received it. This means that we should see strictly more - * failures on the client than on the server. */ - GPR_ASSERT(cancelled_calls_on_client >= cancelled_calls_on_server); - /* However, we shouldn't see radically more... 0.9 is a guessed bound on what - * we'd want that ratio to be... to at least trigger some investigation should - * that ratio become much higher. */ - GPR_ASSERT(cancelled_calls_on_server >= 0.9 * cancelled_calls_on_client); + gpr_log(GPR_INFO, + "Done. %d total calls: %d cancelled at server, %d cancelled at " + "client, %d timed out.", + NUM_CALLS, cancelled_calls_on_server, cancelled_calls_on_client, + deadline_exceeded); grpc_byte_buffer_destroy(request_payload); grpc_slice_unref(request_payload_slice); grpc_resource_quota_unref(resource_quota); + end_test(&f); + config.tear_down_data(&f); + free(client_calls); free(server_calls); free(initial_metadata_recv); @@ -370,12 +368,8 @@ void resource_quota_server(grpc_end2end_test_config config) { free(call_details); free(status); free(details); - free(details_capacity); free(request_payload_recv); free(was_cancelled); - - end_test(&f); - config.tear_down_data(&f); } void resource_quota_server_pre_init(void) {} diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index 3bb25fd924..b42d17002e 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -52,7 +52,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +76,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -111,13 +111,13 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -134,7 +134,7 @@ static void simple_request_body(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -142,7 +142,6 @@ static void simple_request_body(grpc_end2end_test_config config, 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++; @@ -166,7 +165,8 @@ static void simple_request_body(grpc_end2end_test_config config, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -183,13 +183,13 @@ static void simple_request_body(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index b80a2e35f2..c019682ea6 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -100,13 +100,13 @@ static void test_early_server_shutdown_finishes_inflight_calls( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -128,7 +128,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -136,7 +136,6 @@ static void test_early_server_shutdown_finishes_inflight_calls( 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++; @@ -172,12 +171,12 @@ static void test_early_server_shutdown_finishes_inflight_calls( grpc_server_destroy(f.server); GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/shutdown_finishes_tags.c b/test/core/end2end/tests/shutdown_finishes_tags.c index 1d110a74ea..5540d2aab9 100644 --- a/test/core/end2end/tests/shutdown_finishes_tags.c +++ b/test/core/end2end/tests/shutdown_finishes_tags.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/simple_cacheable_request.c b/test/core/end2end/tests/simple_cacheable_request.c index 2c229b08fe..4eef02e9ee 100644 --- a/test/core/end2end/tests/simple_cacheable_request.c +++ b/test/core/end2end/tests/simple_cacheable_request.c @@ -52,7 +52,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +76,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -111,12 +111,22 @@ static void test_cacheable_request_response_with_metadata_and_payload( grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); - grpc_metadata meta_c[2] = { - {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}}; - grpc_metadata meta_s[2] = { - {"key3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"), + grpc_slice_from_static_string("val1"), + 0, + {{NULL, NULL, NULL, NULL}}}, + {grpc_slice_from_static_string("key2"), + grpc_slice_from_static_string("val2"), + 0, + {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_s[2] = {{grpc_slice_from_static_string("key3"), + grpc_slice_from_static_string("val3"), + 0, + {{NULL, NULL, NULL, NULL}}}, + {grpc_slice_from_static_string("key4"), + grpc_slice_from_static_string("val4"), + 0, + {{NULL, NULL, NULL, NULL}}}}; grpc_end2end_test_fixture f = begin_test( config, "test_cacheable_request_response_with_metadata_and_payload", NULL, NULL); @@ -131,13 +141,13 @@ static void test_cacheable_request_response_with_metadata_and_payload( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -155,7 +165,7 @@ static void test_cacheable_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -164,12 +174,12 @@ static void test_cacheable_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -177,7 +187,6 @@ static void test_cacheable_request_response_with_metadata_and_payload( 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++; @@ -200,7 +209,7 @@ static void test_cacheable_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -218,14 +227,15 @@ static void test_cacheable_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; 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"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -237,8 +247,8 @@ static void test_cacheable_request_response_with_metadata_and_payload( cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); if (config.feature_mask & FEATURE_MASK_SUPPORTS_REQUEST_PROXYING) { @@ -254,7 +264,7 @@ static void test_cacheable_request_response_with_metadata_and_payload( GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key3", "val3")); GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key4", "val4")); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index 414a03d98b..e3b6aee783 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -46,7 +46,7 @@ static void *tag(intptr_t t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -62,7 +62,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -100,15 +100,16 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; config.init_client(f, client_args); + config.init_server(f, server_args); 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, + f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -129,7 +130,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -137,15 +138,12 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, 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(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - config.init_server(f, server_args); - error = grpc_server_request_call(f->server, &s, &call_details, &request_metadata_recv, f->cq, f->cq, tag(101)); @@ -163,7 +161,8 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -180,13 +179,13 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -208,7 +207,8 @@ static void test_simple_delayed_request_short(grpc_end2end_test_config config) { client_args.args = arg_array; client_args.num_args = 1; - gpr_log(GPR_INFO, "%s/%s", "test_simple_delayed_request_short", config.name); + gpr_log(GPR_INFO, "Running test: %s/%s", "test_simple_delayed_request_short", + config.name); f = config.create_fixture(NULL, NULL); simple_delayed_request_body(config, &f, &client_args, NULL, 100000); @@ -226,7 +226,8 @@ static void test_simple_delayed_request_long(grpc_end2end_test_config config) { client_args.args = arg_array; client_args.num_args = 1; - gpr_log(GPR_INFO, "%s/%s", "test_simple_delayed_request_long", config.name); + gpr_log(GPR_INFO, "Running test: %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, &client_args, NULL, 1500000); diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index 5490cc2b75..7ab5563cfa 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -109,12 +109,22 @@ static void test_request_response_with_metadata_and_payload( grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); - grpc_metadata meta_c[2] = { - {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}}; - grpc_metadata meta_s[2] = { - {"key3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"), + grpc_slice_from_static_string("val1"), + 0, + {{NULL, NULL, NULL, NULL}}}, + {grpc_slice_from_static_string("key2"), + grpc_slice_from_static_string("val2"), + 0, + {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_s[2] = {{grpc_slice_from_static_string("key3"), + grpc_slice_from_static_string("val3"), + 0, + {{NULL, NULL, NULL, NULL}}}, + {grpc_slice_from_static_string("key4"), + grpc_slice_from_static_string("val4"), + 0, + {{NULL, NULL, NULL, NULL}}}}; grpc_end2end_test_fixture f = begin_test( config, "test_request_response_with_metadata_and_payload", NULL, NULL); cq_verifier *cqv = cq_verifier_create(f.cq); @@ -128,13 +138,13 @@ static void test_request_response_with_metadata_and_payload( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -152,7 +162,7 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -161,12 +171,12 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -174,7 +184,6 @@ static void test_request_response_with_metadata_and_payload( 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++; @@ -197,7 +206,7 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -215,14 +224,15 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; 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"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -234,8 +244,8 @@ static void test_request_response_with_metadata_and_payload( cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); @@ -246,7 +256,7 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key3", "val3")); GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key4", "val4")); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index 2dea5d6af2..af5d74959e 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -52,7 +52,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +76,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -111,14 +111,14 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; int was_cancelled = 2; char *peer; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -144,7 +144,7 @@ static void simple_request_body(grpc_end2end_test_config config, op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -152,7 +152,6 @@ static void simple_request_body(grpc_end2end_test_config config, 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++; @@ -185,7 +184,8 @@ static void simple_request_body(grpc_end2end_test_config config, 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_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -202,14 +202,14 @@ static void simple_request_body(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(0 == call_details.flags); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); @@ -236,7 +236,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { begin_test(config, "test_invoke_10_simple_requests", NULL, NULL); for (i = 0; i < 10; i++) { simple_request_body(config, f); - gpr_log(GPR_INFO, "Passed simple request %d", i); + gpr_log(GPR_INFO, "Running test: Passed simple request %d", i); } end_test(&f); config.tear_down_data(&f); diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index 583bc9268f..42055907c8 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -51,8 +51,8 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, grpc_channel_args *server_args, bool request_status_early) { grpc_end2end_test_fixture f; - gpr_log(GPR_INFO, "%s/%s/request_status_early=%s", test_name, config.name, - request_status_early ? "true" : "false"); + gpr_log(GPR_INFO, "Running test: %s/%s/request_status_early=%s", test_name, + config.name, request_status_early ? "true" : "false"); f = config.create_fixture(client_args, server_args); config.init_server(&f, server_args); config.init_client(&f, client_args); @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -76,7 +76,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -121,13 +121,13 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -144,17 +144,16 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload1_recv; + op->data.recv_message.recv_message = &response_payload1_recv; op++; if (request_status_early) { 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++; } error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); @@ -172,7 +171,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { op->data.send_initial_metadata.count = 0; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload1; + op->data.send_message.send_message = response_payload1; op++; error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); GPR_ASSERT(GRPC_CALL_OK == error); @@ -183,7 +182,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload2; + op->data.send_message.send_message = response_payload2; op++; error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); @@ -202,7 +201,8 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { 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_FAILED_PRECONDITION; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op++; error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL); GPR_ASSERT(GRPC_CALL_OK == error); @@ -211,7 +211,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload2_recv; + op->data.recv_message.recv_message = &response_payload2_recv; op++; error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); GPR_ASSERT(GRPC_CALL_OK == error); @@ -232,7 +232,6 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { 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++; error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL); GPR_ASSERT(GRPC_CALL_OK == error); @@ -245,13 +244,13 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { } GPR_ASSERT(status == GRPC_STATUS_FAILED_PRECONDITION); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 9fd4fbc052..dbbda505bc 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, 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); + gpr_log(GPR_INFO, "Running test: %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); @@ -58,7 +58,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); + return grpc_timeout_seconds_to_deadline(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -74,7 +74,7 @@ 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) + f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -109,15 +109,30 @@ static void test_request_response_with_metadata_and_payload( grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); - grpc_metadata meta_c[2] = { - {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}}; - grpc_metadata meta_s[2] = { - {"key3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}}}; - grpc_metadata meta_t[2] = { - {"key5", "val5", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key6", "val6", 4, 0, {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"), + grpc_slice_from_static_string("val1"), + 0, + {{NULL, NULL, NULL, NULL}}}, + {grpc_slice_from_static_string("key2"), + grpc_slice_from_static_string("val2"), + 0, + {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_s[2] = {{grpc_slice_from_static_string("key3"), + grpc_slice_from_static_string("val3"), + 0, + {{NULL, NULL, NULL, NULL}}}, + {grpc_slice_from_static_string("key4"), + grpc_slice_from_static_string("val4"), + 0, + {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_t[2] = {{grpc_slice_from_static_string("key5"), + grpc_slice_from_static_string("val5"), + 0, + {{NULL, NULL, NULL, NULL}}}, + {grpc_slice_from_static_string("key6"), + grpc_slice_from_static_string("val6"), + 0, + {{NULL, NULL, NULL, NULL}}}}; grpc_end2end_test_fixture f = begin_test( config, "test_request_response_with_metadata_and_payload", NULL, NULL); cq_verifier *cqv = cq_verifier_create(f.cq); @@ -131,13 +146,13 @@ static void test_request_response_with_metadata_and_payload( grpc_call_details call_details; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; 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, + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); @@ -155,7 +170,7 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; @@ -164,12 +179,12 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -177,7 +192,6 @@ static void test_request_response_with_metadata_and_payload( 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++; @@ -200,7 +214,7 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -218,7 +232,7 @@ static void test_request_response_with_metadata_and_payload( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; op->flags = 0; op->reserved = NULL; op++; @@ -226,7 +240,8 @@ static void test_request_response_with_metadata_and_payload( op->data.send_status_from_server.trailing_metadata_count = 2; op->data.send_status_from_server.trailing_metadata = meta_t; op->data.send_status_from_server.status = GRPC_STATUS_OK; - op->data.send_status_from_server.status_details = "xyz"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -238,8 +253,8 @@ static void test_request_response_with_metadata_and_payload( cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(0 == strcmp(details, "xyz")); - GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); @@ -251,7 +266,7 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(contains_metadata(&trailing_metadata_recv, "key5", "val5")); GPR_ASSERT(contains_metadata(&trailing_metadata_recv, "key6", "val6")); - gpr_free(details); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); diff --git a/test/core/end2end/tests/write_buffering.c b/test/core/end2end/tests/write_buffering.c new file mode 100644 index 0000000000..abf90ca6e0 --- /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, "Running test: %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; + grpc_slice details = grpc_empty_slice(); + int was_cancelled = 2; + + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("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.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.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.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.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.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->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; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; + 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 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(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")); + + grpc_slice_unref(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..8c02b425ba --- /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, "Running test: %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; + grpc_slice details = grpc_empty_slice(); + int was_cancelled = 2; + + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/foo"), + get_host_override_slice("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.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.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.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.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->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; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; + 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 == grpc_slice_str_cmp(details, "xyz")); + GPR_ASSERT(0 == grpc_slice_str_cmp(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); + + grpc_slice_unref(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/fling/client.c b/test/core/fling/client.c index e717b7f7fe..85bab6d431 100644 --- a/test/core/fling/client.c +++ b/test/core/fling/client.c @@ -57,8 +57,7 @@ static grpc_metadata_array initial_metadata_recv; static grpc_metadata_array trailing_metadata_recv; static grpc_byte_buffer *response_payload_recv = NULL; static grpc_status_code status; -static char *details = NULL; -static size_t details_capacity = 0; +static grpc_slice details; static grpc_op *op; static void init_ping_pong_request(void) { @@ -72,29 +71,30 @@ static void init_ping_pong_request(void) { op->data.send_initial_metadata.count = 0; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = the_buffer; + op->data.send_message.send_message = the_buffer; op++; op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; 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++; } static void step_ping_pong_request(void) { GPR_TIMER_BEGIN("ping_pong", 1); - call = grpc_channel_create_call(channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, - "/Reflector/reflectUnary", "localhost", - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + grpc_slice host = grpc_slice_from_static_string("localhost"); + call = grpc_channel_create_call( + channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, + grpc_slice_from_static_string("/Reflector/reflectUnary"), &host, + gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, (size_t)(op - ops), (void *)1, NULL)); @@ -109,13 +109,16 @@ static void init_ping_pong_stream(void) { grpc_metadata_array_init(&initial_metadata_recv); grpc_call_error error; - call = grpc_channel_create_call(channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, - "/Reflector/reflectStream", "localhost", - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + grpc_slice host = grpc_slice_from_static_string("localhost"); + call = grpc_channel_create_call( + channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, + grpc_slice_from_static_string("/Reflector/reflectStream"), &host, + gpr_inf_future(GPR_CLOCK_REALTIME), NULL); stream_init_ops[0].op = GRPC_OP_SEND_INITIAL_METADATA; stream_init_ops[0].data.send_initial_metadata.count = 0; stream_init_ops[1].op = GRPC_OP_RECV_INITIAL_METADATA; - stream_init_ops[1].data.recv_initial_metadata = &initial_metadata_recv; + stream_init_ops[1].data.recv_initial_metadata.recv_initial_metadata = + &initial_metadata_recv; error = grpc_call_start_batch(call, stream_init_ops, 2, (void *)1, NULL); GPR_ASSERT(GRPC_CALL_OK == error); grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); @@ -123,9 +126,9 @@ static void init_ping_pong_stream(void) { grpc_metadata_array_init(&initial_metadata_recv); stream_step_ops[0].op = GRPC_OP_SEND_MESSAGE; - stream_step_ops[0].data.send_message = the_buffer; + stream_step_ops[0].data.send_message.send_message = the_buffer; stream_step_ops[1].op = GRPC_OP_RECV_MESSAGE; - stream_step_ops[1].data.recv_message = &response_payload_recv; + stream_step_ops[1].data.recv_message.recv_message = &response_payload_recv; } static void step_ping_pong_stream(void) { @@ -211,9 +214,9 @@ int main(int argc, char **argv) { sc.init(); - gpr_timespec end_warmup = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(warmup_seconds); + gpr_timespec end_warmup = grpc_timeout_seconds_to_deadline(warmup_seconds); gpr_timespec end_profiling = - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(warmup_seconds + benchmark_seconds); + grpc_timeout_seconds_to_deadline(warmup_seconds + benchmark_seconds); while (gpr_time_cmp(gpr_now(end_warmup.clock_type), end_warmup) < 0) { sc.do_one_step(); diff --git a/test/core/fling/server.c b/test/core/fling/server.c index fd446f1128..7ea54b1167 100644 --- a/test/core/fling/server.c +++ b/test/core/fling/server.c @@ -107,18 +107,18 @@ static void handle_unary_method(void) { op->data.send_initial_metadata.count = 0; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &terminal_buffer; + op->data.recv_message.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->data.send_message.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->data.send_status_from_server.status_details = NULL; op++; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; @@ -144,7 +144,7 @@ static void start_read_op(int t) { grpc_call_error error; /* Starting read at server */ read_op.op = GRPC_OP_RECV_MESSAGE; - read_op.data.recv_message = &payload_buffer; + read_op.data.recv_message.recv_message = &payload_buffer; error = grpc_call_start_batch(call, &read_op, 1, tag(t), NULL); GPR_ASSERT(GRPC_CALL_OK == error); } @@ -157,7 +157,7 @@ static void start_write_op(void) { if (payload_buffer == NULL) { gpr_log(GPR_INFO, "NULL payload buffer !!!"); } - write_op.data.send_message = payload_buffer; + write_op.data.send_message.send_message = payload_buffer; error = grpc_call_start_batch(call, &write_op, 1, tagarg, NULL); GPR_ASSERT(GRPC_CALL_OK == error); } @@ -168,7 +168,7 @@ static void start_send_status(void) { status_op[0].op = GRPC_OP_SEND_STATUS_FROM_SERVER; status_op[0].data.send_status_from_server.status = GRPC_STATUS_OK; status_op[0].data.send_status_from_server.trailing_metadata_count = 0; - status_op[0].data.send_status_from_server.status_details = ""; + status_op[0].data.send_status_from_server.status_details = NULL; status_op[1].op = GRPC_OP_RECV_CLOSE_ON_SERVER; status_op[1].data.recv_close_on_server.cancelled = &was_cancelled; @@ -244,7 +244,7 @@ int main(int argc, char **argv) { 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) + cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_completion_queue_shutdown(cq); shutdown_started = 1; @@ -259,8 +259,8 @@ int main(int argc, char **argv) { switch ((intptr_t)s) { case FLING_SERVER_NEW_REQUEST: if (call != NULL) { - if (0 == - strcmp(call_details.method, "/Reflector/reflectStream")) { + if (0 == grpc_slice_str_cmp(call_details.method, + "/Reflector/reflectStream")) { /* Received streaming call. Send metadata here. */ start_read_op(FLING_SERVER_READ_FOR_STREAMING); send_initial_metadata(); diff --git a/test/core/handshake/client_ssl.c b/test/core/handshake/client_ssl.c index 24281e0b41..a22133e629 100644 --- a/test/core/handshake/client_ssl.c +++ b/test/core/handshake/client_ssl.c @@ -104,7 +104,8 @@ static int alpn_select_cb(SSL *ssl, const uint8_t **out, uint8_t *out_len, bool grpc_exp_seen = false; bool h2_seen = false; const char *inp = (const char *)in; - for (int i = 0; i < (int)in_len; ++i) { + const char *in_end = inp + in_len; + while (inp < in_end) { const size_t length = (size_t)*inp++; if (length == strlen("grpc-exp") && strncmp(inp, "grpc-exp", length) == 0) { grpc_exp_seen = true; @@ -117,6 +118,7 @@ static int alpn_select_cb(SSL *ssl, const uint8_t **out, uint8_t *out_len, inp += length; } + GPR_ASSERT(inp == in_end); GPR_ASSERT(grpc_exp_seen); GPR_ASSERT(h2_seen); @@ -272,8 +274,8 @@ static bool client_ssl_test(char *server_alpn_preferred) { grpc_completion_queue *cq = grpc_completion_queue_create(NULL); while (state != GRPC_CHANNEL_READY && retries-- > 0) { grpc_channel_watch_connectivity_state( - channel, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), cq, NULL); - gpr_timespec cq_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5); + channel, state, grpc_timeout_seconds_to_deadline(3), cq, NULL); + gpr_timespec cq_deadline = grpc_timeout_seconds_to_deadline(5); grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, NULL); GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); state = diff --git a/test/core/handshake/server_ssl.c b/test/core/handshake/server_ssl.c index f39b0040a6..0bd5a03cff 100644 --- a/test/core/handshake/server_ssl.c +++ b/test/core/handshake/server_ssl.c @@ -113,7 +113,7 @@ static void server_thread(void *arg) { // sleeping between polls. int retries = 10; while (!gpr_event_get(&client_handshake_complete) && retries-- > 0) { - const gpr_timespec cq_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1); + const gpr_timespec cq_deadline = grpc_timeout_seconds_to_deadline(1); grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, NULL); GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT); } @@ -122,7 +122,7 @@ static void server_thread(void *arg) { grpc_server_shutdown_and_notify(server, cq, NULL); grpc_completion_queue_shutdown(cq); - const gpr_timespec cq_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5); + const gpr_timespec cq_deadline = grpc_timeout_seconds_to_deadline(5); grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, NULL); GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); 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 3e312c1dde..6cc00f871d 100644 --- a/test/core/http/httpcli_test.c +++ b/test/core/http/httpcli_test.c @@ -51,7 +51,7 @@ static gpr_mu *g_mu; static grpc_polling_entity g_pops; static gpr_timespec n_seconds_time(int seconds) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(seconds); + return grpc_timeout_seconds_to_deadline(seconds); } static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { @@ -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 d06035149e..e1a26d91e9 100644 --- a/test/core/http/httpscli_test.c +++ b/test/core/http/httpscli_test.c @@ -51,7 +51,7 @@ static gpr_mu *g_mu; static grpc_polling_entity g_pops; static gpr_timespec n_seconds_time(int seconds) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(seconds); + return grpc_timeout_seconds_to_deadline(seconds); } static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { @@ -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..d73d5c175c 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; @@ -92,15 +92,14 @@ static void test_code(void) { grpc_endpoint_read(&exec_ctx, &endpoint, NULL, NULL); grpc_endpoint_get_peer(&endpoint); grpc_endpoint_write(&exec_ctx, &endpoint, NULL, NULL); - grpc_endpoint_shutdown(&exec_ctx, &endpoint); + grpc_endpoint_shutdown(&exec_ctx, &endpoint, GRPC_ERROR_CANCELLED); grpc_endpoint_destroy(&exec_ctx, &endpoint); grpc_endpoint_add_to_pollset(&exec_ctx, &endpoint, NULL); grpc_endpoint_add_to_pollset_set(&exec_ctx, &endpoint, NULL); /* 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..4c9275a673 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,14 +95,15 @@ 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 // picking it up - gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100)); + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100)); } grpc_exec_ctx_finish(&exec_ctx); } @@ -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..94067a8ca4 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" /* @@ -185,7 +187,7 @@ static void read_and_write_test(grpc_endpoint_test_config config, size_t num_bytes, size_t write_size, size_t slice_size, bool shutdown) { struct read_and_write_test_state state; - gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); + gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20); grpc_endpoint_test_fixture f = begin_test(config, "read_and_write_test", slice_size); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -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); @@ -230,9 +233,11 @@ static void read_and_write_test(grpc_endpoint_test_config config, if (shutdown) { gpr_log(GPR_DEBUG, "shutdown read"); - grpc_endpoint_shutdown(&exec_ctx, state.read_ep); + grpc_endpoint_shutdown(&exec_ctx, state.read_ep, + GRPC_ERROR_CREATE("Test Shutdown")); gpr_log(GPR_DEBUG, "shutdown write"); - grpc_endpoint_shutdown(&exec_ctx, state.write_ep); + grpc_endpoint_shutdown(&exec_ctx, state.write_ep, + GRPC_ERROR_CREATE("Test Shutdown")); } grpc_exec_ctx_flush(&exec_ctx); @@ -249,8 +254,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 +295,26 @@ 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); + grpc_endpoint_shutdown(&exec_ctx, f.client_ep, + GRPC_ERROR_CREATE("Test Shutdown")); 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); + grpc_endpoint_shutdown(&exec_ctx, f.client_ep, + GRPC_ERROR_CREATE("Test Shutdown")); 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..5b05ea3338 100644 --- a/test/core/iomgr/ev_epoll_linux_test.c +++ b/test/core/iomgr/ev_epoll_linux_test.c @@ -45,6 +45,7 @@ #include <grpc/support/log.h> #include "src/core/lib/iomgr/iomgr.h" +#include "src/core/lib/iomgr/workqueue.h" #include "test/core/util/test_config.h" typedef struct test_pollset { @@ -60,6 +61,22 @@ typedef struct test_fd { /* num_fds should be an even number */ static void test_fd_init(test_fd *tfds, int *fds, int num_fds) { int i; + int r; + + /* Create some dummy file descriptors. Currently using pipe file descriptors + * for this test but we could use any other type of file descriptors. Also, + * since pipe() used in this test creates two fds in each call, num_fds should + * be an even number */ + GPR_ASSERT((num_fds % 2) == 0); + for (i = 0; i < num_fds; i = i + 2) { + r = pipe(fds + i); + if (r != 0) { + gpr_log(GPR_ERROR, "Error in creating pipe. %d (%s)", errno, + strerror(errno)); + return; + } + } + for (i = 0; i < num_fds; i++) { tfds[i].inner_fd = fds[i]; tfds[i].fd = grpc_fd_create(fds[i], "test_fd"); @@ -72,7 +89,8 @@ static void test_fd_cleanup(grpc_exec_ctx *exec_ctx, test_fd *tfds, int i; for (i = 0; i < num_fds; i++) { - grpc_fd_shutdown(exec_ctx, tfds[i].fd); + grpc_fd_shutdown(exec_ctx, tfds[i].fd, + GRPC_ERROR_CREATE("test_fd_cleanup")); grpc_exec_ctx_flush(exec_ctx); grpc_fd_orphan(exec_ctx, tfds[i].fd, NULL, &release_fd, "test_fd_cleanup"); @@ -102,7 +120,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); @@ -110,8 +129,80 @@ static void test_pollset_cleanup(grpc_exec_ctx *exec_ctx, } } -#define NUM_FDS 8 -#define NUM_POLLSETS 4 +static void increment(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { + ++*(int *)arg; +} + +/* + * Validate that merging two workqueues preserves the closures in each queue. + * This is a regression test for a bug in + * polling_island_merge()[ev_epoll_linux.c], where the parent relationship was + * inverted. + */ +static void test_pollset_queue_merge_items() { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + const int num_fds = 2; + const int num_pollsets = 2; + const int num_closures = 4; + test_fd tfds[num_fds]; + int fds[num_fds]; + test_pollset pollsets[num_pollsets]; + grpc_closure closures[num_closures]; + int i; + int result = 0; + + test_fd_init(tfds, fds, num_fds); + test_pollset_init(pollsets, num_pollsets); + + /* Two distinct polling islands, each with their own FD and pollset. */ + for (i = 0; i < num_fds; i++) { + grpc_pollset_add_fd(&exec_ctx, pollsets[i].pollset, tfds[i].fd); + grpc_exec_ctx_flush(&exec_ctx); + } + + /* Enqeue the closures, 3 to polling island 0 and 1 to polling island 1. */ + grpc_closure_init( + closures, increment, &result, + grpc_workqueue_scheduler(grpc_fd_get_polling_island(tfds[0].fd))); + grpc_closure_init( + closures + 1, increment, &result, + grpc_workqueue_scheduler(grpc_fd_get_polling_island(tfds[0].fd))); + grpc_closure_init( + closures + 2, increment, &result, + grpc_workqueue_scheduler(grpc_fd_get_polling_island(tfds[0].fd))); + grpc_closure_init( + closures + 3, increment, &result, + grpc_workqueue_scheduler(grpc_fd_get_polling_island(tfds[1].fd))); + for (i = 0; i < num_closures; ++i) { + grpc_closure_sched(&exec_ctx, closures + i, GRPC_ERROR_NONE); + } + + /* Merge the two polling islands. */ + grpc_pollset_add_fd(&exec_ctx, pollsets[0].pollset, tfds[1].fd); + grpc_exec_ctx_flush(&exec_ctx); + + /* + * Execute the closures, verify we see each one execute when executing work on + * the merged polling island. + */ + grpc_pollset_worker *worker = NULL; + for (i = 0; i < num_closures; ++i) { + const gpr_timespec deadline = gpr_time_add( + gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(2, GPR_TIMESPAN)); + gpr_mu_lock(pollsets[1].mu); + GRPC_LOG_IF_ERROR( + "grpc_pollset_work", + grpc_pollset_work(&exec_ctx, pollsets[1].pollset, &worker, + gpr_now(GPR_CLOCK_MONOTONIC), deadline)); + gpr_mu_unlock(pollsets[1].mu); + } + GPR_ASSERT(result == num_closures); + + test_fd_cleanup(&exec_ctx, tfds, num_fds); + test_pollset_cleanup(&exec_ctx, pollsets, num_pollsets); + grpc_exec_ctx_finish(&exec_ctx); +} + /* * Cases to test: * case 1) Polling islands of both fd and pollset are NULL @@ -124,28 +215,16 @@ static void test_pollset_cleanup(grpc_exec_ctx *exec_ctx, * */ static void test_add_fd_to_pollset() { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - test_fd tfds[NUM_FDS]; - int fds[NUM_FDS]; - test_pollset pollsets[NUM_POLLSETS]; + const int num_fds = 8; + const int num_pollsets = 4; + test_fd tfds[num_fds]; + int fds[num_fds]; + test_pollset pollsets[num_pollsets]; void *expected_pi = NULL; int i; - int r; - /* Create some dummy file descriptors. Currently using pipe file descriptors - * for this test but we could use any other type of file descriptors. Also, - * since pipe() used in this test creates two fds in each call, NUM_FDS should - * be an even number */ - for (i = 0; i < NUM_FDS; i = i + 2) { - r = pipe(fds + i); - if (r != 0) { - gpr_log(GPR_ERROR, "Error in creating pipe. %d (%s)", errno, - strerror(errno)); - return; - } - } - - test_fd_init(tfds, fds, NUM_FDS); - test_pollset_init(pollsets, NUM_POLLSETS); + test_fd_init(tfds, fds, num_fds); + test_pollset_init(pollsets, num_pollsets); /*Step 1. * Create three polling islands (This will exercise test case 1 and 2) with @@ -206,19 +285,19 @@ static void test_add_fd_to_pollset() { /* Compare Fd:0's polling island with that of all other Fds */ expected_pi = grpc_fd_get_polling_island(tfds[0].fd); - for (i = 1; i < NUM_FDS; i++) { + for (i = 1; i < num_fds; i++) { GPR_ASSERT(grpc_are_polling_islands_equal( expected_pi, grpc_fd_get_polling_island(tfds[i].fd))); } /* Compare Fd:0's polling island with that of all other pollsets */ - for (i = 0; i < NUM_POLLSETS; i++) { + for (i = 0; i < num_pollsets; i++) { GPR_ASSERT(grpc_are_polling_islands_equal( expected_pi, grpc_pollset_get_polling_island(pollsets[i].pollset))); } - test_fd_cleanup(&exec_ctx, tfds, NUM_FDS); - test_pollset_cleanup(&exec_ctx, pollsets, NUM_POLLSETS); + test_fd_cleanup(&exec_ctx, tfds, num_fds); + test_pollset_cleanup(&exec_ctx, pollsets, num_pollsets); grpc_exec_ctx_finish(&exec_ctx); } @@ -230,13 +309,19 @@ int main(int argc, char **argv) { poll_strategy = grpc_get_poll_strategy_name(); if (poll_strategy != NULL && strcmp(poll_strategy, "epoll") == 0) { test_add_fd_to_pollset(); + test_pollset_queue_merge_items(); } else { gpr_log(GPR_INFO, "Skipping the test. The test is only relevant for 'epoll' " "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..4726e935d8 100644 --- a/test/core/iomgr/fd_posix_test.c +++ b/test/core/iomgr/fd_posix_test.c @@ -132,7 +132,8 @@ static void session_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */ grpc_fd_orphan(exec_ctx, se->em_fd, NULL, NULL, "a"); gpr_free(se); /* Start to shutdown listen fd. */ - grpc_fd_shutdown(exec_ctx, sv->em_fd); + grpc_fd_shutdown(exec_ctx, sv->em_fd, + GRPC_ERROR_CREATE("session_shutdown_cb")); } /* Called when data become readable in a session. */ @@ -219,8 +220,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 +250,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 +334,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 +460,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 +547,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/pollset_set_test.c b/test/core/iomgr/pollset_set_test.c new file mode 100644 index 0000000000..40fa858602 --- /dev/null +++ b/test/core/iomgr/pollset_set_test.c @@ -0,0 +1,467 @@ +/* + * + * 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 "src/core/lib/iomgr/port.h" + +/* This test only relevant on linux systems where epoll is available */ +#ifdef GRPC_LINUX_EPOLL + +#include <errno.h> +#include <string.h> +#include <unistd.h> + +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/useful.h> + +#include "src/core/lib/iomgr/ev_posix.h" +#include "src/core/lib/iomgr/iomgr.h" +#include "test/core/util/test_config.h" + +/******************************************************************************* + * test_pollset_set + */ + +typedef struct test_pollset_set { grpc_pollset_set *pss; } test_pollset_set; + +void init_test_pollset_sets(test_pollset_set *pollset_sets, const int num_pss) { + for (int i = 0; i < num_pss; i++) { + pollset_sets[i].pss = grpc_pollset_set_create(); + } +} + +void cleanup_test_pollset_sets(test_pollset_set *pollset_sets, + const int num_pss) { + for (int i = 0; i < num_pss; i++) { + grpc_pollset_set_destroy(pollset_sets[i].pss); + pollset_sets[i].pss = NULL; + } +} + +/******************************************************************************* + * test_pollset + */ + +typedef struct test_pollset { + grpc_pollset *ps; + gpr_mu *mu; +} test_pollset; + +static void init_test_pollsets(test_pollset *pollsets, const int num_pollsets) { + for (int i = 0; i < num_pollsets; i++) { + pollsets[i].ps = gpr_malloc(grpc_pollset_size()); + grpc_pollset_init(pollsets[i].ps, &pollsets[i].mu); + } +} + +static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, + grpc_error *error) { + grpc_pollset_destroy(p); +} + +static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx, + test_pollset *pollsets, + const int num_pollsets) { + grpc_closure destroyed; + for (int i = 0; i < num_pollsets; i++) { + grpc_closure_init(&destroyed, destroy_pollset, pollsets[i].ps, + grpc_schedule_on_exec_ctx); + grpc_pollset_shutdown(exec_ctx, pollsets[i].ps, &destroyed); + + grpc_exec_ctx_flush(exec_ctx); + gpr_free(pollsets[i].ps); + pollsets[i].ps = NULL; + } +} + +/******************************************************************************* + * test_fd + */ + +typedef struct test_fd { + grpc_fd *fd; + grpc_wakeup_fd wakeup_fd; + + bool is_on_readable_called; /* Is on_readable closure is called ? */ + grpc_closure on_readable; /* Closure to call when this fd is readable */ +} test_fd; + +void on_readable(grpc_exec_ctx *exec_ctx, void *tfd, grpc_error *error) { + ((test_fd *)tfd)->is_on_readable_called = true; +} + +static void reset_test_fd(grpc_exec_ctx *exec_ctx, test_fd *tfd) { + tfd->is_on_readable_called = false; + + grpc_closure_init(&tfd->on_readable, on_readable, tfd, + grpc_schedule_on_exec_ctx); + grpc_fd_notify_on_read(exec_ctx, tfd->fd, &tfd->on_readable); +} + +static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, + const int num_fds) { + for (int i = 0; i < num_fds; i++) { + GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_init(&tfds[i].wakeup_fd)); + tfds[i].fd = grpc_fd_create(GRPC_WAKEUP_FD_GET_READ_FD(&tfds[i].wakeup_fd), + "test_fd"); + reset_test_fd(exec_ctx, &tfds[i]); + } +} + +static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, + const int num_fds) { + int release_fd; + + for (int i = 0; i < num_fds; i++) { + grpc_fd_shutdown(exec_ctx, tfds[i].fd, GRPC_ERROR_CREATE("fd cleanup")); + grpc_exec_ctx_flush(exec_ctx); + + /* grpc_fd_orphan frees the memory allocated for grpc_fd. Normally it also + * calls close() on the underlying fd. In our case, we are using + * grpc_wakeup_fd and we would like to destroy it ourselves (by calling + * grpc_wakeup_fd_destroy). To prevent grpc_fd from calling close() on the + * underlying fd, call it with a non-NULL 'release_fd' parameter */ + grpc_fd_orphan(exec_ctx, tfds[i].fd, NULL, &release_fd, "test_fd_cleanup"); + grpc_exec_ctx_flush(exec_ctx); + + grpc_wakeup_fd_destroy(&tfds[i].wakeup_fd); + } +} + +static void make_test_fds_readable(test_fd *tfds, const int num_fds) { + for (int i = 0; i < num_fds; i++) { + GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_wakeup(&tfds[i].wakeup_fd)); + } +} + +static void verify_readable_and_reset(grpc_exec_ctx *exec_ctx, test_fd *tfds, + const int num_fds) { + for (int i = 0; i < num_fds; i++) { + /* Verify that the on_readable callback was called */ + GPR_ASSERT(tfds[i].is_on_readable_called); + + /* Reset the tfd[i] structure */ + GPR_ASSERT(GRPC_ERROR_NONE == + grpc_wakeup_fd_consume_wakeup(&tfds[i].wakeup_fd)); + reset_test_fd(exec_ctx, &tfds[i]); + } +} + +/******************************************************************************* + * Main tests + */ + +/* Test some typical scenarios in pollset_set */ +static void pollset_set_test_basic() { + /* We construct the following structure for this test: + * + * +---> FD0 (Added before PSS1, PS1 and PS2 are added to PSS0) + * | + * +---> FD5 (Added after PSS1, PS1 and PS2 are added to PSS0) + * | + * | + * | +---> FD1 (Added before PSS1 is added to PSS0) + * | | + * | +---> FD6 (Added after PSS1 is added to PSS0) + * | | + * +---> PSS1--+ +--> FD2 (Added before PS0 is added to PSS1) + * | | | + * | +---> PS0---+ + * | | + * PSS0---+ +--> FD7 (Added after PS0 is added to PSS1) + * | + * | + * | +---> FD3 (Added before PS1 is added to PSS0) + * | | + * +---> PS1---+ + * | | + * | +---> FD8 (Added after PS1 added to PSS0) + * | + * | + * | +---> FD4 (Added before PS2 is added to PSS0) + * | | + * +---> PS2---+ + * | + * +---> FD9 (Added after PS2 is added to PSS0) + */ + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_pollset_worker *worker; + gpr_timespec deadline; + + test_fd tfds[10]; + test_pollset pollsets[3]; + test_pollset_set pollset_sets[2]; + const int num_fds = GPR_ARRAY_SIZE(tfds); + const int num_ps = GPR_ARRAY_SIZE(pollsets); + const int num_pss = GPR_ARRAY_SIZE(pollset_sets); + + init_test_fds(&exec_ctx, tfds, num_fds); + init_test_pollsets(pollsets, num_ps); + init_test_pollset_sets(pollset_sets, num_pss); + + /* Construct the pollset_set/pollset/fd tree (see diagram above) */ + + grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd); + grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd); + + grpc_pollset_add_fd(&exec_ctx, pollsets[0].ps, tfds[2].fd); + grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[3].fd); + grpc_pollset_add_fd(&exec_ctx, pollsets[2].ps, tfds[4].fd); + + grpc_pollset_set_add_pollset_set(&exec_ctx, pollset_sets[0].pss, + pollset_sets[1].pss); + + grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[1].pss, pollsets[0].ps); + grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[1].ps); + grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[2].ps); + + grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[5].fd); + grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[6].fd); + + grpc_pollset_add_fd(&exec_ctx, pollsets[0].ps, tfds[7].fd); + grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[8].fd); + grpc_pollset_add_fd(&exec_ctx, pollsets[2].ps, tfds[9].fd); + + grpc_exec_ctx_flush(&exec_ctx); + + /* Test that if any FD in the above structure is readable, it is observable by + * doing grpc_pollset_work on any pollset + * + * For every pollset, do the following: + * - (Ensure that all FDs are in reset state) + * - Make all FDs readable + * - Call grpc_pollset_work() on the pollset + * - Flush the exec_ctx + * - Verify that on_readable call back was called for all FDs (and + * reset the FDs) + * */ + for (int i = 0; i < num_ps; i++) { + make_test_fds_readable(tfds, num_fds); + + gpr_mu_lock(pollsets[i].mu); + deadline = grpc_timeout_milliseconds_to_deadline(2); + GPR_ASSERT(GRPC_ERROR_NONE == + grpc_pollset_work(&exec_ctx, pollsets[i].ps, &worker, + gpr_now(GPR_CLOCK_MONOTONIC), deadline)); + gpr_mu_unlock(pollsets[i].mu); + + grpc_exec_ctx_flush(&exec_ctx); + + verify_readable_and_reset(&exec_ctx, tfds, num_fds); + grpc_exec_ctx_flush(&exec_ctx); + } + + /* Test tear down */ + grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd); + grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[5].fd); + grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd); + grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[6].fd); + grpc_exec_ctx_flush(&exec_ctx); + + grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[1].pss, pollsets[0].ps); + grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[1].ps); + grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[2].ps); + + grpc_pollset_set_del_pollset_set(&exec_ctx, pollset_sets[0].pss, + pollset_sets[1].pss); + grpc_exec_ctx_flush(&exec_ctx); + + cleanup_test_fds(&exec_ctx, tfds, num_fds); + cleanup_test_pollsets(&exec_ctx, pollsets, num_ps); + cleanup_test_pollset_sets(pollset_sets, num_pss); + grpc_exec_ctx_finish(&exec_ctx); +} + +/* Same FD added multiple times to the pollset_set tree */ +void pollset_set_test_dup_fds() { + /* We construct the following structure for this test: + * + * +---> FD0 + * | + * | + * PSS0---+ + * | +---> FD0 (also under PSS0) + * | | + * +---> PSS1--+ +--> FD1 (also under PSS1) + * | | + * +---> PS ---+ + * | | + * | +--> FD2 + * +---> FD1 + */ + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_pollset_worker *worker; + gpr_timespec deadline; + + test_fd tfds[3]; + test_pollset pollset; + test_pollset_set pollset_sets[2]; + const int num_fds = GPR_ARRAY_SIZE(tfds); + const int num_ps = 1; + const int num_pss = GPR_ARRAY_SIZE(pollset_sets); + + init_test_fds(&exec_ctx, tfds, num_fds); + init_test_pollsets(&pollset, num_ps); + init_test_pollset_sets(pollset_sets, num_pss); + + /* Construct the structure */ + grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd); + grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[0].fd); + grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd); + + grpc_pollset_add_fd(&exec_ctx, pollset.ps, tfds[1].fd); + grpc_pollset_add_fd(&exec_ctx, pollset.ps, tfds[2].fd); + + grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[1].pss, pollset.ps); + grpc_pollset_set_add_pollset_set(&exec_ctx, pollset_sets[0].pss, + pollset_sets[1].pss); + + /* Test. Make all FDs readable and make sure that can be observed by doing a + * grpc_pollset_work on the pollset 'PS' */ + make_test_fds_readable(tfds, num_fds); + + gpr_mu_lock(pollset.mu); + deadline = grpc_timeout_milliseconds_to_deadline(2); + GPR_ASSERT(GRPC_ERROR_NONE == + grpc_pollset_work(&exec_ctx, pollset.ps, &worker, + gpr_now(GPR_CLOCK_MONOTONIC), deadline)); + gpr_mu_unlock(pollset.mu); + grpc_exec_ctx_flush(&exec_ctx); + + verify_readable_and_reset(&exec_ctx, tfds, num_fds); + grpc_exec_ctx_flush(&exec_ctx); + + /* Tear down */ + grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd); + grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[0].fd); + grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd); + + grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[1].pss, pollset.ps); + grpc_pollset_set_del_pollset_set(&exec_ctx, pollset_sets[0].pss, + pollset_sets[1].pss); + grpc_exec_ctx_flush(&exec_ctx); + + cleanup_test_fds(&exec_ctx, tfds, num_fds); + cleanup_test_pollsets(&exec_ctx, &pollset, num_ps); + cleanup_test_pollset_sets(pollset_sets, num_pss); + grpc_exec_ctx_finish(&exec_ctx); +} + +/* Pollset_set with an empty pollset */ +void pollset_set_test_empty_pollset() { + /* We construct the following structure for this test: + * + * +---> PS0 (EMPTY) + * | + * +---> FD0 + * | + * PSS0---+ + * | +---> FD1 + * | | + * +---> PS1--+ + * | + * +---> FD2 + */ + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_pollset_worker *worker; + gpr_timespec deadline; + + test_fd tfds[3]; + test_pollset pollsets[2]; + test_pollset_set pollset_set; + const int num_fds = GPR_ARRAY_SIZE(tfds); + const int num_ps = GPR_ARRAY_SIZE(pollsets); + const int num_pss = 1; + + init_test_fds(&exec_ctx, tfds, num_fds); + init_test_pollsets(pollsets, num_ps); + init_test_pollset_sets(&pollset_set, num_pss); + + /* Construct the structure */ + grpc_pollset_set_add_fd(&exec_ctx, pollset_set.pss, tfds[0].fd); + grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[1].fd); + grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[2].fd); + + grpc_pollset_set_add_pollset(&exec_ctx, pollset_set.pss, pollsets[0].ps); + grpc_pollset_set_add_pollset(&exec_ctx, pollset_set.pss, pollsets[1].ps); + + /* Test. Make all FDs readable and make sure that can be observed by doing + * grpc_pollset_work on the empty pollset 'PS0' */ + make_test_fds_readable(tfds, num_fds); + + gpr_mu_lock(pollsets[0].mu); + deadline = grpc_timeout_milliseconds_to_deadline(2); + GPR_ASSERT(GRPC_ERROR_NONE == + grpc_pollset_work(&exec_ctx, pollsets[0].ps, &worker, + gpr_now(GPR_CLOCK_MONOTONIC), deadline)); + gpr_mu_unlock(pollsets[0].mu); + grpc_exec_ctx_flush(&exec_ctx); + + verify_readable_and_reset(&exec_ctx, tfds, num_fds); + grpc_exec_ctx_flush(&exec_ctx); + + /* Tear down */ + grpc_pollset_set_del_fd(&exec_ctx, pollset_set.pss, tfds[0].fd); + grpc_pollset_set_del_pollset(&exec_ctx, pollset_set.pss, pollsets[0].ps); + grpc_pollset_set_del_pollset(&exec_ctx, pollset_set.pss, pollsets[1].ps); + grpc_exec_ctx_flush(&exec_ctx); + + cleanup_test_fds(&exec_ctx, tfds, num_fds); + cleanup_test_pollsets(&exec_ctx, pollsets, num_ps); + cleanup_test_pollset_sets(&pollset_set, num_pss); + grpc_exec_ctx_finish(&exec_ctx); +} + +int main(int argc, char **argv) { + const char *poll_strategy = grpc_get_poll_strategy_name(); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_test_init(argc, argv); + grpc_iomgr_init(); + + if (poll_strategy != NULL && strcmp(poll_strategy, "epoll") == 0) { + pollset_set_test_basic(); + pollset_set_test_dup_fds(); + pollset_set_test_empty_pollset(); + } else { + gpr_log(GPR_INFO, + "Skipping the test. The test is only relevant for 'epoll' " + "strategy. and the current strategy is: '%s'", + poll_strategy); + } + + grpc_iomgr_shutdown(&exec_ctx); + grpc_exec_ctx_finish(&exec_ctx); + return 0; +} +#else /* defined(GRPC_LINUX_EPOLL) */ +int main(int argc, char **argv) { return 0; } +#endif /* !defined(GRPC_LINUX_EPOLL) */ diff --git a/test/core/iomgr/resolve_address_posix_test.c b/test/core/iomgr/resolve_address_posix_test.c new file mode 100644 index 0000000000..a4feff8b00 --- /dev/null +++ b/test/core/iomgr/resolve_address_posix_test.c @@ -0,0 +1,188 @@ +/* + * + * 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 "src/core/lib/iomgr/resolve_address.h" + +#include <string.h> +#include <sys/un.h> + +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/sync.h> +#include <grpc/support/thd.h> +#include <grpc/support/time.h> +#include <grpc/support/useful.h> +#include "src/core/lib/iomgr/executor.h" +#include "src/core/lib/iomgr/iomgr.h" +#include "test/core/util/test_config.h" + +static gpr_timespec test_deadline(void) { + return grpc_timeout_seconds_to_deadline(100); +} + +typedef struct args_struct { + gpr_event ev; + grpc_resolved_addresses *addrs; + gpr_atm done_atm; + gpr_mu *mu; + grpc_pollset *pollset; + grpc_pollset_set *pollset_set; +} args_struct; + +static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} + +void args_init(grpc_exec_ctx *exec_ctx, args_struct *args) { + gpr_event_init(&args->ev); + args->pollset = gpr_malloc(grpc_pollset_size()); + grpc_pollset_init(args->pollset, &args->mu); + args->pollset_set = grpc_pollset_set_create(); + grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset); + args->addrs = NULL; +} + +void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { + GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline())); + grpc_resolved_addresses_destroy(args->addrs); + 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_schedule_on_exec_ctx); + grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb); + // 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); +} + +static gpr_timespec n_sec_deadline(int seconds) { + return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_seconds(seconds, GPR_TIMESPAN)); +} + +static void actually_poll(void *argsp) { + args_struct *args = argsp; + gpr_timespec deadline = n_sec_deadline(10); + while (true) { + bool done = gpr_atm_acq_load(&args->done_atm) != 0; + if (done) { + break; + } + gpr_timespec time_left = + gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME)); + gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done, + time_left.tv_sec, time_left.tv_nsec); + GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0); + grpc_pollset_worker *worker = NULL; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + gpr_mu_lock(args->mu); + GRPC_LOG_IF_ERROR( + "pollset_work", + grpc_pollset_work(&exec_ctx, args->pollset, &worker, + gpr_now(GPR_CLOCK_REALTIME), n_sec_deadline(1))); + gpr_mu_unlock(args->mu); + grpc_exec_ctx_finish(&exec_ctx); + } + gpr_event_set(&args->ev, (void *)1); +} + +static void poll_pollset_until_request_done(args_struct *args) { + gpr_atm_rel_store(&args->done_atm, 0); + gpr_thd_id id; + gpr_thd_new(&id, actually_poll, args, NULL); +} + +static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp, + grpc_error *err) { + args_struct *args = argsp; + GPR_ASSERT(err == GRPC_ERROR_NONE); + GPR_ASSERT(args->addrs != NULL); + GPR_ASSERT(args->addrs->naddrs > 0); + gpr_atm_rel_store(&args->done_atm, 1); +} + +static void must_fail(grpc_exec_ctx *exec_ctx, void *argsp, grpc_error *err) { + args_struct *args = argsp; + GPR_ASSERT(err != GRPC_ERROR_NONE); + gpr_atm_rel_store(&args->done_atm, 1); +} + +static void test_unix_socket(void) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + args_struct args; + args_init(&exec_ctx, &args); + poll_pollset_until_request_done(&args); + grpc_resolve_address( + &exec_ctx, "unix:/path/name", 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); +} + +static void test_unix_socket_path_name_too_long(void) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + args_struct args; + args_init(&exec_ctx, &args); + const char prefix[] = "unix:/path/name"; + size_t path_name_length = + GPR_ARRAY_SIZE(((struct sockaddr_un *)0)->sun_path) + 6; + char *path_name = gpr_malloc(sizeof(char) * path_name_length); + memset(path_name, 'a', path_name_length); + memcpy(path_name, prefix, strlen(prefix) - 1); + path_name[path_name_length - 1] = '\0'; + + poll_pollset_until_request_done(&args); + grpc_resolve_address( + &exec_ctx, path_name, NULL, args.pollset_set, + grpc_closure_create(must_fail, &args, grpc_schedule_on_exec_ctx), + &args.addrs); + gpr_free(path_name); + args_finish(&exec_ctx, &args); + grpc_exec_ctx_finish(&exec_ctx); +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + grpc_executor_init(); + grpc_iomgr_init(); + test_unix_socket(); + test_unix_socket_path_name_too_long(); + { + 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/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c index e4136a7a7a..54de9a20e1 100644 --- a/test/core/iomgr/resolve_address_test.c +++ b/test/core/iomgr/resolve_address_test.c @@ -42,7 +42,7 @@ #include "test/core/util/test_config.h" static gpr_timespec test_deadline(void) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(100); + return grpc_timeout_seconds_to_deadline(100); } typedef struct args_struct { @@ -71,7 +71,8 @@ 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_destroy() grpc_exec_ctx_flush(exec_ctx); @@ -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..dcdff8efb1 100644 --- a/test/core/iomgr/tcp_client_posix_test.c +++ b/test/core/iomgr/tcp_client_posix_test.c @@ -57,7 +57,7 @@ static int g_connections_complete = 0; static grpc_endpoint *g_connecting = NULL; static gpr_timespec test_deadline(void) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10); + return grpc_timeout_seconds_to_deadline(10); } static void finish_connection() { @@ -72,7 +72,8 @@ static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { GPR_ASSERT(g_connecting != NULL); GPR_ASSERT(error == GRPC_ERROR_NONE); - grpc_endpoint_shutdown(exec_ctx, g_connecting); + grpc_endpoint_shutdown(exec_ctx, g_connecting, + GRPC_ERROR_CREATE("must_succeed called")); grpc_endpoint_destroy(exec_ctx, g_connecting); g_connecting = NULL; finish_connection(); @@ -113,7 +114,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)); @@ -134,7 +135,7 @@ void test_succeeds(void) { "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)))); + grpc_timeout_seconds_to_deadline(5)))); gpr_mu_unlock(g_mu); grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(g_mu); @@ -163,7 +164,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 +208,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..99ecd581c6 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" @@ -173,7 +175,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { grpc_endpoint *ep; struct read_socket_state state; size_t written_bytes; - gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); + gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, "Read test of size %" PRIuPTR ", slice size %" PRIuPTR, @@ -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); } @@ -224,7 +226,7 @@ static void large_read_test(size_t slice_size) { grpc_endpoint *ep; struct read_socket_state state; ssize_t written_bytes; - gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); + gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, "Start large read test, slice size %" PRIuPTR, slice_size); @@ -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); } @@ -328,7 +330,7 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) { "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC), - GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10)))); + grpc_timeout_milliseconds_to_deadline(10)))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); do { @@ -361,7 +363,7 @@ static void write_test(size_t num_bytes, size_t slice_size) { uint8_t current_data = 0; grpc_slice_buffer outgoing; grpc_closure write_done_closure; - gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); + gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, @@ -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); @@ -425,11 +428,12 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { struct read_socket_state state; size_t written_bytes; int fd; - gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); + gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20); 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 9a7810e227..7122cd1e86 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. @@ -121,7 +121,7 @@ static void server_weak_ref_set(server_weak_ref *weak_ref, static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, grpc_pollset *pollset, grpc_tcp_server_acceptor *acceptor) { - grpc_endpoint_shutdown(exec_ctx, tcp); + grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE("Connected")); grpc_endpoint_destroy(exec_ctx, tcp); on_connect_result temp_result; @@ -202,7 +202,7 @@ static void test_no_op_with_port_and_start(void) { static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, socklen_t remote_len, on_connect_result *result) { - gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10); + gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10); int clifd = socket(remote->sa_family, SOCK_STREAM, 0); int nconnects_before; @@ -366,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..ba572017a2 100644 --- a/test/core/iomgr/udp_server_test.c +++ b/test/core/iomgr/udp_server_test.c @@ -58,6 +58,7 @@ static grpc_pollset *g_pollset; static gpr_mu *g_mu; static int g_number_of_reads = 0; +static int g_number_of_writes = 0; static int g_number_of_bytes_read = 0; static int g_number_of_orphan_calls = 0; @@ -78,7 +79,16 @@ static void on_read(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, gpr_mu_unlock(g_mu); } -static void on_fd_orphaned(grpc_fd *emfd) { +static void on_write(grpc_exec_ctx *exec_ctx, grpc_fd *emfd) { + gpr_mu_lock(g_mu); + g_number_of_writes++; + + GPR_ASSERT( + GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, NULL))); + gpr_mu_unlock(g_mu); +} + +static void on_fd_orphaned(grpc_exec_ctx *exec_ctx, grpc_fd *emfd) { gpr_log(GPR_INFO, "gRPC FD about to be orphaned: %d", grpc_fd_wrapped_fd(emfd)); g_number_of_orphan_calls++; @@ -111,8 +121,8 @@ static void test_no_op_with_port(void) { memset(&resolved_addr, 0, sizeof(resolved_addr)); resolved_addr.len = sizeof(struct sockaddr_in); addr->sin_family = AF_INET; - GPR_ASSERT( - grpc_udp_server_add_port(s, &resolved_addr, on_read, on_fd_orphaned)); + GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write, + on_fd_orphaned)); grpc_udp_server_destroy(&exec_ctx, s, NULL); grpc_exec_ctx_finish(&exec_ctx); @@ -132,8 +142,8 @@ static void test_no_op_with_port_and_start(void) { memset(&resolved_addr, 0, sizeof(resolved_addr)); resolved_addr.len = sizeof(struct sockaddr_in); addr->sin_family = AF_INET; - GPR_ASSERT( - grpc_udp_server_add_port(s, &resolved_addr, on_read, on_fd_orphaned)); + GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write, + on_fd_orphaned)); grpc_udp_server_start(&exec_ctx, s, NULL, 0, NULL); @@ -164,8 +174,8 @@ static void test_receive(int number_of_clients) { memset(&resolved_addr, 0, sizeof(resolved_addr)); resolved_addr.len = sizeof(struct sockaddr_storage); addr->ss_family = AF_INET; - GPR_ASSERT( - grpc_udp_server_add_port(s, &resolved_addr, on_read, on_fd_orphaned)); + GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write, + on_fd_orphaned)); svrfd = grpc_udp_server_get_fd(s, 0); GPR_ASSERT(svrfd >= 0); @@ -179,7 +189,7 @@ static void test_receive(int number_of_clients) { gpr_mu_lock(g_mu); for (i = 0; i < number_of_clients; i++) { - deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10); + deadline = grpc_timeout_seconds_to_deadline(10); number_of_reads_before = g_number_of_reads; /* Create a socket, send a packet to the UDP server. */ @@ -212,6 +222,9 @@ static void test_receive(int number_of_clients) { /* The server had a single FD, which is orphaned once in * * deactivated_all_ports, and once in grpc_udp_server_destroy. */ GPR_ASSERT(g_number_of_orphan_calls == 2); + + /* The write callback should have fired a few times. */ + GPR_ASSERT(g_number_of_writes > 0); } static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, @@ -234,11 +247,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..09f0e2d867 --- /dev/null +++ b/test/core/memory_usage/client.c @@ -0,0 +1,315 @@ +/* + * + * 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; + grpc_slice details; + 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.recv_initial_metadata = + &calls[call_idx].initial_metadata_recv; + op++; + + grpc_slice hostname = grpc_slice_from_static_string("localhost"); + calls[call_idx].call = grpc_channel_create_call( + channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, + grpc_slice_from_static_string("/Reflector/reflectUnary"), &hostname, + 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++; + + 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); + grpc_slice_unref(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, + grpc_slice 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.recv_initial_metadata = + &calls[call_idx].initial_metadata_recv; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message.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++; + + grpc_slice hostname = grpc_slice_from_static_string("localhost"); + calls[call_idx].call = grpc_channel_create_call( + channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, call_type, &hostname, + 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); + grpc_slice_unref(calls[call_idx].details); + calls[call_idx].details = grpc_empty_slice(); + 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 (size_t k = 0; k < GPR_ARRAY_SIZE(calls); k++) { + calls[k].details = grpc_empty_slice(); + } + + 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, grpc_slice_from_static_string("Reflector/GetBeforeSvrCreation")); + struct grpc_memory_counters after_server_create = send_snapshot_request( + 0, grpc_slice_from_static_string("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, grpc_slice_from_static_string("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, grpc_slice_from_static_string("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, grpc_slice_from_static_string("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..ab059c25b8 --- /dev/null +++ b/test/core/memory_usage/server.c @@ -0,0 +1,325 @@ +/* + * + * 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; + grpc_slice details = grpc_slice_from_static_string(""); + status_op.data.send_status_from_server.status_details = &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.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.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; + grpc_slice details = grpc_slice_from_static_string(""); + op->data.send_status_from_server.status_details = &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 == grpc_slice_str_cmp(s->call_details.method, + "/Reflector/reflectUnary")) { + s->state = FLING_SERVER_SEND_INIT_METADATA; + send_initial_metadata_unary(s); + } else if (0 == + grpc_slice_str_cmp(s->call_details.method, + "Reflector/GetBeforeSvrCreation")) { + s->state = FLING_SERVER_SEND_STATUS_SNAPSHOT; + send_snapshot(s, &before_server_create); + } else if (0 == + grpc_slice_str_cmp(s->call_details.method, + "Reflector/GetAfterSvrCreation")) { + s->state = FLING_SERVER_SEND_STATUS_SNAPSHOT; + send_snapshot(s, &after_server_create); + } else if (0 == grpc_slice_str_cmp(s->call_details.method, + "Reflector/SimpleSnapshot")) { + s->state = FLING_SERVER_SEND_STATUS_SNAPSHOT; + current_snapshot = grpc_memory_counters_snapshot(); + send_snapshot(s, ¤t_snapshot); + } else if (0 == grpc_slice_str_cmp(s->call_details.method, + "Reflector/DestroyCalls")) { + s->state = FLING_SERVER_BATCH_SEND_STATUS_FLING_CALL; + current_snapshot = grpc_memory_counters_snapshot(); + send_snapshot(s, ¤t_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/credentials_test.c b/test/core/security/credentials_test.c index d4c755088d..c0933c64a6 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"; @@ -191,14 +196,16 @@ static void test_add_to_empty_md_store(void) { grpc_slice value = grpc_slice_from_copied_string(value_str); grpc_credentials_md_store_add(store, key, value); GPR_ASSERT(store->num_entries == 1); - GPR_ASSERT(grpc_slice_cmp(key, store->entries[0].key) == 0); - GPR_ASSERT(grpc_slice_cmp(value, store->entries[0].value) == 0); + GPR_ASSERT(grpc_slice_eq(key, store->entries[0].key)); + GPR_ASSERT(grpc_slice_eq(value, store->entries[0].value)); 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; } @@ -1028,9 +1065,8 @@ static void plugin_get_metadata_success(void *state, *s = PLUGIN_GET_METADATA_CALLED_STATE; for (i = 0; i < GPR_ARRAY_SIZE(plugin_md); i++) { memset(&md[i], 0, sizeof(grpc_metadata)); - md[i].key = plugin_md[i].key; - md[i].value = plugin_md[i].value; - md[i].value_length = strlen(plugin_md[i].value); + md[i].key = grpc_slice_from_copied_string(plugin_md[i].key); + md[i].value = grpc_slice_from_copied_string(plugin_md[i].value); } cb(user_data, md, GPR_ARRAY_SIZE(md), GRPC_STATUS_OK, NULL); } @@ -1142,6 +1178,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 +1187,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 9a21814adc..a9bd976a39 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -224,7 +224,8 @@ static void test_claims_success(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_json(claims) == json); GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), "https://foo.com") == 0); @@ -233,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) { @@ -245,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); @@ -258,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) { @@ -274,11 +280,13 @@ 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) { @@ -287,11 +295,13 @@ static void test_bad_subject_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://foo.com") == GRPC_JWT_VERIFIER_BAD_SUBJECT); - grpc_jwt_claims_destroy(claims); + grpc_jwt_claims_destroy(&exec_ctx, claims); + grpc_exec_ctx_finish(&exec_ctx); } static char *json_key_str(const char *last_part) { @@ -346,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) { @@ -390,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; } @@ -424,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; } @@ -439,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; } @@ -465,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); @@ -479,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; } @@ -535,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. */ @@ -546,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); @@ -587,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); 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/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.c index 2b74690bc3..ea136fbdcf 100644 --- a/test/core/security/print_google_default_creds_token.c +++ b/test/core/security/print_google_default_creds_token.c @@ -63,7 +63,7 @@ static void on_metadata_response(grpc_exec_ctx *exec_ctx, void *user_data, } else { char *token; GPR_ASSERT(num_md == 1); - token = grpc_dump_slice(md_elems[0].value, GPR_DUMP_ASCII); + token = grpc_slice_to_c_string(md_elems[0].value); printf("\nGot token: %s\n\n", token); gpr_free(token); } diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c index b5d95004fe..97e9c3d6db 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,20 +159,22 @@ 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); GPR_ASSERT(incoming.count == 1); - GPR_ASSERT(0 == grpc_slice_cmp(s, incoming.slices[0])); + GPR_ASSERT(grpc_slice_eq(s, incoming.slices[0])); - grpc_endpoint_shutdown(&exec_ctx, f.client_ep); - grpc_endpoint_shutdown(&exec_ctx, f.server_ep); + grpc_endpoint_shutdown(&exec_ctx, f.client_ep, + GRPC_ERROR_CREATE("test_leftover end")); + grpc_endpoint_shutdown(&exec_ctx, f.server_ep, + GRPC_ERROR_CREATE("test_leftover end")); 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 +194,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/security_connector_test.c b/test/core/security/security_connector_test.c index 8872cbe278..4219b134f2 100644 --- a/test/core/security/security_connector_test.c +++ b/test/core/security/security_connector_test.c @@ -370,7 +370,7 @@ static void test_default_ssl_roots(void) { gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); grpc_set_ssl_roots_override_callback(override_roots_success); grpc_slice roots = grpc_get_default_ssl_roots_for_testing(); - char *roots_contents = grpc_dump_slice(roots, GPR_DUMP_ASCII); + char *roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); GPR_ASSERT(strcmp(roots_contents, roots_for_override_api) == 0); gpr_free(roots_contents); @@ -379,7 +379,7 @@ static void test_default_ssl_roots(void) { instead. */ gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_env_var_file_path); roots = grpc_get_default_ssl_roots_for_testing(); - roots_contents = grpc_dump_slice(roots, GPR_DUMP_ASCII); + roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); GPR_ASSERT(strcmp(roots_contents, roots_for_env_var) == 0); gpr_free(roots_contents); @@ -388,7 +388,7 @@ static void test_default_ssl_roots(void) { the api. */ gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); roots = grpc_get_default_ssl_roots_for_testing(); - roots_contents = grpc_dump_slice(roots, GPR_DUMP_ASCII); + roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); GPR_ASSERT(strcmp(roots_contents, roots_for_override_api) == 0); gpr_free(roots_contents); diff --git a/test/core/security/ssl_server_fuzzer.c b/test/core/security/ssl_server_fuzzer.c index 8673225fef..f789278add 100644 --- a/test/core/security/ssl_server_fuzzer.c +++ b/test/core/security/ssl_server_fuzzer.c @@ -79,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, @@ -103,7 +103,7 @@ 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); gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(1, GPR_TIMESPAN)); @@ -121,14 +121,15 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { // server will wait for more data. Explicitly fail the server by shutting down // the endpoint. if (!state.done_callback_called) { - grpc_endpoint_shutdown(&exec_ctx, mock_endpoint); + grpc_endpoint_shutdown(&exec_ctx, mock_endpoint, + GRPC_ERROR_CREATE("Explicit close")); grpc_exec_ctx_flush(&exec_ctx); } GPR_ASSERT(state.done_callback_called); grpc_handshake_manager_destroy(&exec_ctx, handshake_mgr); - GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "test"); + 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 ccc85c9f32..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", diff --git a/test/core/slice/percent_encode_fuzzer.c b/test/core/slice/percent_encode_fuzzer.c index 9698e796b4..0d440c5bb2 100644 --- a/test/core/slice/percent_encode_fuzzer.c +++ b/test/core/slice/percent_encode_fuzzer.c @@ -55,8 +55,8 @@ static void test(const uint8_t *data, size_t size, const uint8_t *dict) { grpc_slice permissive_decoded_output = grpc_permissive_percent_decode_slice(output); // and decoded output must always match the input - GPR_ASSERT(grpc_slice_cmp(input, decoded_output) == 0); - GPR_ASSERT(grpc_slice_cmp(input, permissive_decoded_output) == 0); + GPR_ASSERT(grpc_slice_eq(input, decoded_output)); + GPR_ASSERT(grpc_slice_eq(input, permissive_decoded_output)); grpc_slice_unref(input); grpc_slice_unref(output); grpc_slice_unref(decoded_output); diff --git a/test/core/slice/percent_encoding_test.c b/test/core/slice/percent_encoding_test.c index d71c99f54c..222e695fd4 100644 --- a/test/core/slice/percent_encoding_test.c +++ b/test/core/slice/percent_encoding_test.c @@ -81,9 +81,9 @@ static void test_vector(const char *raw, size_t raw_length, const char *encoded, gpr_free(encoded2raw_msg); gpr_free(encoded2raw_permissive_msg); - GPR_ASSERT(0 == grpc_slice_cmp(raw_slice, encoded2raw_slice)); - GPR_ASSERT(0 == grpc_slice_cmp(raw_slice, encoded2raw_permissive_slice)); - GPR_ASSERT(0 == grpc_slice_cmp(encoded_slice, raw2encoded_slice)); + GPR_ASSERT(grpc_slice_eq(raw_slice, encoded2raw_slice)); + GPR_ASSERT(grpc_slice_eq(raw_slice, encoded2raw_permissive_slice)); + GPR_ASSERT(grpc_slice_eq(encoded_slice, raw2encoded_slice)); grpc_slice_unref(encoded2raw_slice); grpc_slice_unref(encoded2raw_permissive_slice); @@ -123,8 +123,8 @@ static void test_nonconformant_vector(const char *encoded, encoded2raw_permissive_msg); gpr_free(encoded2raw_permissive_msg); - GPR_ASSERT(0 == grpc_slice_cmp(permissive_unencoded_slice, - encoded2raw_permissive_slice)); + GPR_ASSERT( + grpc_slice_eq(permissive_unencoded_slice, encoded2raw_permissive_slice)); grpc_slice_unref(permissive_unencoded_slice); grpc_slice_unref(encoded2raw_permissive_slice); diff --git a/test/core/slice/slice_test.c b/test/core/slice/slice_test.c index ca44becfd0..f68a953261 100644 --- a/test/core/slice/slice_test.c +++ b/test/core/slice/slice_test.c @@ -35,8 +35,12 @@ #include <string.h> +#include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> + +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/transport/static_metadata.h" #include "test/core/util/test_config.h" #define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x); @@ -61,8 +65,10 @@ static void test_slice_malloc_returns_something_sensible(void) { GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == length); /* If the slice has a refcount, it must be destroyable. */ if (slice.refcount) { - GPR_ASSERT(slice.refcount->ref != NULL); - GPR_ASSERT(slice.refcount->unref != NULL); + GPR_ASSERT(slice.refcount->vtable != NULL); + GPR_ASSERT(slice.refcount->vtable->ref != NULL); + GPR_ASSERT(slice.refcount->vtable->unref != NULL); + GPR_ASSERT(slice.refcount->vtable->hash != NULL); } /* We must be able to write to every byte of the data */ for (i = 0; i < length; i++) { @@ -249,6 +255,55 @@ static void test_slice_from_copied_string_works(void) { grpc_slice_unref(slice); } +static void test_slice_interning(void) { + LOG_TEST_NAME("test_slice_interning"); + + grpc_init(); + grpc_slice src1 = grpc_slice_from_copied_string("hello123456789123456789"); + grpc_slice src2 = grpc_slice_from_copied_string("hello123456789123456789"); + GPR_ASSERT(GRPC_SLICE_START_PTR(src1) != GRPC_SLICE_START_PTR(src2)); + grpc_slice interned1 = grpc_slice_intern(src1); + grpc_slice interned2 = grpc_slice_intern(src2); + GPR_ASSERT(GRPC_SLICE_START_PTR(interned1) == + GRPC_SLICE_START_PTR(interned2)); + GPR_ASSERT(GRPC_SLICE_START_PTR(interned1) != GRPC_SLICE_START_PTR(src1)); + GPR_ASSERT(GRPC_SLICE_START_PTR(interned2) != GRPC_SLICE_START_PTR(src2)); + grpc_slice_unref(src1); + grpc_slice_unref(src2); + grpc_slice_unref(interned1); + grpc_slice_unref(interned2); + grpc_shutdown(); +} + +static void test_static_slice_interning(void) { + LOG_TEST_NAME("test_static_slice_interning"); + + // grpc_init/grpc_shutdown deliberately omitted: they should not be necessary + // to intern a static slice + + for (size_t i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) { + GPR_ASSERT(grpc_slice_is_equivalent( + grpc_static_slice_table[i], + grpc_slice_intern(grpc_static_slice_table[i]))); + } +} + +static void test_static_slice_copy_interning(void) { + LOG_TEST_NAME("test_static_slice_copy_interning"); + + grpc_init(); + + for (size_t i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) { + grpc_slice copy = grpc_slice_dup(grpc_static_slice_table[i]); + GPR_ASSERT(grpc_static_slice_table[i].refcount != copy.refcount); + GPR_ASSERT(grpc_static_slice_table[i].refcount == + grpc_slice_intern(copy).refcount); + grpc_slice_unref(copy); + } + + grpc_shutdown(); +} + int main(int argc, char **argv) { unsigned length; grpc_test_init(argc, argv); @@ -262,5 +317,8 @@ int main(int argc, char **argv) { test_slice_split_tail_works(length); } test_slice_from_copied_string_works(); + test_slice_interning(); + test_static_slice_interning(); + test_static_slice_copy_interning(); return 0; } diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c index 8646a2fdf1..0f96f014ea 100644 --- a/test/core/statistics/census_log_tests.c +++ b/test/core/statistics/census_log_tests.c @@ -199,7 +199,7 @@ static void writer_thread(void *arg) { This should never happen for circular logs. */ printf(" Writer stalled due to out-of-space: %d out of %d written\n", records_written, args->num_records); - gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10)); + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(10)); } } /* Done. Decrement count and signal. */ 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/cpu_test.c b/test/core/support/cpu_test.c index a5c52442ad..ca0fe0ccb5 100644 --- a/test/core/support/cpu_test.c +++ b/test/core/support/cpu_test.c @@ -81,9 +81,9 @@ static void worker_thread(void *arg) { uint32_t cpu; unsigned r = 12345678; unsigned i, j; - for (i = 0; i < 1000 / GRPC_TEST_SLOWDOWN_FACTOR; i++) { + for (i = 0; i < 1000 / grpc_test_slowdown_factor(); i++) { /* run for a bit - just calculate something random. */ - for (j = 0; j < 1000000 / GRPC_TEST_SLOWDOWN_FACTOR; j++) { + for (j = 0; j < 1000000 / grpc_test_slowdown_factor(); j++) { r = (r * 17) & ((r - i) | (r * i)); } cpu = gpr_cpu_current_cpu(); diff --git a/test/core/surface/alarm_test.c b/test/core/surface/alarm_test.c index 054c328389..4afe357c27 100644 --- a/test/core/surface/alarm_test.c +++ b/test/core/surface/alarm_test.c @@ -64,9 +64,9 @@ static void test_alarm(void) { grpc_event ev; void *tag = create_test_tag(); grpc_alarm *alarm = - grpc_alarm_create(cc, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), tag); + grpc_alarm_create(cc, grpc_timeout_seconds_to_deadline(1), tag); - ev = grpc_completion_queue_next(cc, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2), + ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(2), NULL); GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); GPR_ASSERT(ev.tag == tag); @@ -78,10 +78,10 @@ static void test_alarm(void) { grpc_event ev; void *tag = create_test_tag(); grpc_alarm *alarm = - grpc_alarm_create(cc, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2), tag); + grpc_alarm_create(cc, grpc_timeout_seconds_to_deadline(2), tag); grpc_alarm_cancel(alarm); - ev = grpc_completion_queue_next(cc, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), + ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(1), NULL); GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); GPR_ASSERT(ev.tag == tag); 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/completion_queue_test.c b/test/core/surface/completion_queue_test.c index 1486d2508f..b8ea90921a 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.c @@ -232,7 +232,7 @@ static void test_too_many_plucks(void) { } /* wait until all other threads are plucking */ - gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(1000)); + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1000)); ev = grpc_completion_queue_pluck(cc, create_test_tag(), gpr_inf_future(GPR_CLOCK_REALTIME), NULL); @@ -266,7 +266,7 @@ typedef struct test_thread_options { } test_thread_options; gpr_timespec ten_seconds_time(void) { - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10); + return grpc_timeout_seconds_to_deadline(10); } static void free_completion(grpc_exec_ctx *exec_ctx, void *arg, diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.c index 93a4794222..4f7a25ab93 100644 --- a/test/core/surface/concurrent_connectivity_test.c +++ b/test/core/surface/concurrent_connectivity_test.c @@ -70,11 +70,13 @@ void create_loop_destroy(void *addr) { grpc_channel *chan = grpc_insecure_channel_create((char *)addr, NULL, NULL); for (int j = 0; j < NUM_INNER_LOOPS; ++j) { - gpr_timespec later_time = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(DELAY_MILLIS); + gpr_timespec later_time = + grpc_timeout_milliseconds_to_deadline(DELAY_MILLIS); grpc_connectivity_state state = grpc_channel_check_connectivity_state(chan, 1); grpc_channel_watch_connectivity_state(chan, state, later_time, cq, NULL); - gpr_timespec poll_time = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(POLL_MILLIS); + gpr_timespec poll_time = + grpc_timeout_milliseconds_to_deadline(POLL_MILLIS); GPR_ASSERT(grpc_completion_queue_next(cq, poll_time, NULL).type == GRPC_OP_COMPLETE); } @@ -107,7 +109,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *vargs, grpc_endpoint *tcp, grpc_tcp_server_acceptor *acceptor) { gpr_free(acceptor); struct server_thread_args *args = (struct server_thread_args *)vargs; - grpc_endpoint_shutdown(exec_ctx, tcp); + grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE("Connected")); grpc_endpoint_destroy(exec_ctx, tcp); GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, NULL)); } @@ -229,9 +231,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..9deb50bb04 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); @@ -88,8 +90,7 @@ int main(int argc, char **argv) { grpc_metadata_array trailing_metadata_recv; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; char *peer; grpc_test_init(argc, argv); @@ -109,9 +110,10 @@ int main(int argc, char **argv) { cq = grpc_completion_queue_create(NULL); + grpc_slice host = grpc_slice_from_static_string("anywhere"); call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, - "/Foo", "anywhere", - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(100), NULL); + grpc_slice_from_static_string("/Foo"), &host, + grpc_timeout_seconds_to_deadline(100), NULL); GPR_ASSERT(call); cqv = cq_verifier_create(cq); @@ -123,7 +125,7 @@ int main(int argc, char **argv) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -140,7 +142,6 @@ int main(int argc, char **argv) { 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++; @@ -162,7 +163,7 @@ int main(int argc, char **argv) { grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); - gpr_free(details); + grpc_slice_unref(details); grpc_shutdown(); 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..567f8ae16e 100644 --- a/test/core/surface/secure_channel_create_test.c +++ b/test/core/surface/secure_channel_create_test.c @@ -43,43 +43,44 @@ #include "test/core/util/test_config.h" void test_unknown_scheme_target(void) { - grpc_channel *chan; - grpc_channel_credentials *creds; grpc_resolver_registry_shutdown(); grpc_resolver_registry_init(); - - 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_channel_credentials *creds = + grpc_fake_transport_security_credentials_create(); + grpc_channel *chan = + grpc_secure_channel_create(creds, "blah://blah", NULL, NULL); + 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 exec_ctx = GRPC_EXEC_CTX_INIT; + GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test"); + grpc_channel_credentials_unref(&exec_ctx, creds); + grpc_exec_ctx_finish(&exec_ctx); } void test_security_connector_already_in_arg(void) { - grpc_channel *chan; - grpc_channel_element *elem; - grpc_channel_args args; grpc_arg arg; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - arg.type = GRPC_ARG_POINTER; arg.value.pointer.p = NULL; - arg.key = GRPC_SECURITY_CONNECTOR_ARG; + arg.key = GRPC_ARG_SECURITY_CONNECTOR; + grpc_channel_args args; args.num_args = 1; args.args = &arg; - chan = grpc_secure_channel_create(NULL, NULL, &args, NULL); - elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0); + grpc_channel *chan = grpc_secure_channel_create(NULL, NULL, &args, NULL); + 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 exec_ctx = GRPC_EXEC_CTX_INIT; GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test"); grpc_exec_ctx_finish(&exec_ctx); } void test_null_creds(void) { - grpc_channel *chan; - grpc_channel_element *elem; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - chan = grpc_secure_channel_create(NULL, NULL, NULL, NULL); - elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0); + grpc_channel *chan = grpc_secure_channel_create(NULL, NULL, NULL, NULL); + 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 exec_ctx = GRPC_EXEC_CTX_INIT; GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test"); grpc_exec_ctx_finish(&exec_ctx); } diff --git a/test/core/surface/sequential_connectivity_test.c b/test/core/surface/sequential_connectivity_test.c index fe87f119f2..5f66f90037 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" @@ -90,7 +91,7 @@ static void run_test(const test_fixture *fixture) { for (size_t i = 0; i < NUM_CONNECTIONS; i++) { channels[i] = fixture->create_channel(addr); - gpr_timespec connect_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(30); + gpr_timespec connect_deadline = grpc_timeout_seconds_to_deadline(30); grpc_connectivity_state state; while ((state = grpc_channel_check_connectivity_state(channels[i], 1)) != GRPC_CHANNEL_READY) { @@ -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/transport/bdp_estimator_test.c b/test/core/transport/bdp_estimator_test.c new file mode 100644 index 0000000000..f55a3ca643 --- /dev/null +++ b/test/core/transport/bdp_estimator_test.c @@ -0,0 +1,153 @@ +/* + * + * 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 "src/core/lib/transport/bdp_estimator.h" + +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/string_util.h> +#include <grpc/support/useful.h> +#include <limits.h> +#include "src/core/lib/support/string.h" +#include "test/core/util/test_config.h" + +static void test_noop(void) { + gpr_log(GPR_INFO, "test_noop"); + grpc_bdp_estimator est; + grpc_bdp_estimator_init(&est, "test"); +} + +static void test_get_estimate_no_samples(void) { + gpr_log(GPR_INFO, "test_get_estimate_no_samples"); + grpc_bdp_estimator est; + grpc_bdp_estimator_init(&est, "test"); + int64_t estimate; + grpc_bdp_estimator_get_estimate(&est, &estimate); +} + +static void add_samples(grpc_bdp_estimator *estimator, int64_t *samples, + size_t n) { + GPR_ASSERT(grpc_bdp_estimator_add_incoming_bytes(estimator, 1234567) == true); + grpc_bdp_estimator_schedule_ping(estimator); + grpc_bdp_estimator_start_ping(estimator); + for (size_t i = 0; i < n; i++) { + GPR_ASSERT(grpc_bdp_estimator_add_incoming_bytes(estimator, samples[i]) == + false); + } + grpc_bdp_estimator_complete_ping(estimator); +} + +static void add_sample(grpc_bdp_estimator *estimator, int64_t sample) { + add_samples(estimator, &sample, 1); +} + +static void test_get_estimate_1_sample(void) { + gpr_log(GPR_INFO, "test_get_estimate_1_sample"); + grpc_bdp_estimator est; + grpc_bdp_estimator_init(&est, "test"); + add_sample(&est, 100); + int64_t estimate; + grpc_bdp_estimator_get_estimate(&est, &estimate); +} + +static void test_get_estimate_2_samples(void) { + gpr_log(GPR_INFO, "test_get_estimate_2_samples"); + grpc_bdp_estimator est; + grpc_bdp_estimator_init(&est, "test"); + add_sample(&est, 100); + add_sample(&est, 100); + int64_t estimate; + grpc_bdp_estimator_get_estimate(&est, &estimate); +} + +static int64_t get_estimate(grpc_bdp_estimator *estimator) { + int64_t out; + GPR_ASSERT(grpc_bdp_estimator_get_estimate(estimator, &out)); + return out; +} + +static void test_get_estimate_3_samples(void) { + gpr_log(GPR_INFO, "test_get_estimate_3_samples"); + grpc_bdp_estimator est; + grpc_bdp_estimator_init(&est, "test"); + add_sample(&est, 100); + add_sample(&est, 100); + add_sample(&est, 100); + int64_t estimate; + grpc_bdp_estimator_get_estimate(&est, &estimate); +} + +static int64_t next_pow_2(int64_t v) { + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v |= v >> 32; + v++; + return v; +} + +static void test_get_estimate_random_values(size_t n) { + gpr_log(GPR_INFO, "test_get_estimate_random_values(%" PRIdPTR ")", n); + grpc_bdp_estimator est; + grpc_bdp_estimator_init(&est, "test"); + int min = INT_MAX; + int max = 65535; // Windows rand() has limited range, make sure the ASSERT + // passes + for (size_t i = 0; i < n; i++) { + int sample = rand(); + if (sample < min) min = sample; + if (sample > max) max = sample; + add_sample(&est, sample); + if (i >= 3) { + gpr_log(GPR_DEBUG, "est:%" PRId64 " min:%d max:%d", get_estimate(&est), + min, max); + GPR_ASSERT(get_estimate(&est) <= 2 * next_pow_2(max)); + } + } +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + test_noop(); + test_get_estimate_no_samples(); + test_get_estimate_1_sample(); + test_get_estimate_2_samples(); + test_get_estimate_3_samples(); + for (size_t i = 3; i < 1000; i = i * 3 / 2) { + test_get_estimate_random_values(i); + } + return 0; +} 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..a8b0a75137 100644 --- a/test/core/transport/chttp2/bin_decoder_test.c +++ b/test/core/transport/chttp2/bin_decoder_test.c @@ -38,14 +38,15 @@ #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) { - if (0 != grpc_slice_cmp(slice, expected)) { +static void expect_slice_eq(grpc_exec_ctx *exec_ctx, grpc_slice expected, + grpc_slice slice, char *debug, int line) { + if (!grpc_slice_eq(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); gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs, @@ -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/bin_encoder_test.c b/test/core/transport/chttp2/bin_encoder_test.c index 53b55a301e..bd10a1e211 100644 --- a/test/core/transport/chttp2/bin_encoder_test.c +++ b/test/core/transport/chttp2/bin_encoder_test.c @@ -48,7 +48,7 @@ static int all_ok = 1; static void expect_slice_eq(grpc_slice expected, grpc_slice slice, char *debug, int line) { - if (0 != grpc_slice_cmp(slice, expected)) { + if (!grpc_slice_eq(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); gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs, @@ -84,8 +84,8 @@ static void expect_combined_equiv(const char *s, size_t len, int line) { grpc_slice input = grpc_slice_from_copied_buffer(s, len); grpc_slice base64 = grpc_chttp2_base64_encode(input); grpc_slice expect = grpc_chttp2_huffman_compress(base64); - grpc_slice got = grpc_chttp2_base64_encode_and_huffman_compress_impl(input); - if (0 != grpc_slice_cmp(expect, got)) { + grpc_slice got = grpc_chttp2_base64_encode_and_huffman_compress(input); + if (!grpc_slice_eq(expect, got)) { char *t = grpc_dump_slice(input, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *e = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *g = grpc_dump_slice(got, GPR_DUMP_HEX | GPR_DUMP_ASCII); @@ -106,7 +106,7 @@ static void expect_combined_equiv(const char *s, size_t len, int line) { expect_combined_equiv(x, sizeof(x) - 1, __LINE__) static void expect_binary_header(const char *hdr, int binary) { - if (grpc_is_binary_header(hdr, strlen(hdr)) != binary) { + if (grpc_is_binary_header(grpc_slice_from_static_string(hdr)) != binary) { gpr_log(GPR_ERROR, "FAILED: expected header '%s' to be %s", hdr, binary ? "binary" : "not binary"); all_ok = 0; diff --git a/test/core/transport/chttp2/hpack_encoder_test.c b/test/core/transport/chttp2/hpack_encoder_test.c index 91421e18f4..d572d79a7f 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,9 @@ 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_slices( + exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)), + grpc_slice_intern(grpc_slice_from_static_string(value))); } e[0].prev = NULL; e[nheaders - 1].next = NULL; @@ -87,6 +91,7 @@ static void verify(size_t window_available, int eof, size_t expect_window_used, b.list.head = &e[0]; b.list.tail = &e[nheaders - 1]; + b.list.count = nheaders; if (cap_to_delete == num_to_delete) { cap_to_delete = GPR_MAX(2 * cap_to_delete, 1000); @@ -98,13 +103,13 @@ 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)) { + if (!grpc_slice_eq(merged, expect)) { char *expect_str = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *got_str = grpc_dump_slice(merged, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_ERROR, "mismatched output for %s", expected); @@ -115,31 +120,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 +156,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 +179,26 @@ 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_slices( + exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)), + grpc_slice_intern(grpc_slice_from_static_string(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)); @@ -199,34 +209,37 @@ static void verify_table_size_change_match_elem_size(const char *key, e[0].next = NULL; b.list.head = &e[0]; b.list.tail = &e[0]; + b.list.count = 1; grpc_slice_buffer_init(&output); 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) { size_t i; - grpc_test_only_set_metadata_hash_seed(0); + grpc_test_only_set_slice_hash_seed(0); grpc_test_init(argc, argv); grpc_init(); TEST(test_basic_headers); diff --git a/test/core/transport/chttp2/hpack_parser_corpus/051268ade45dbed0aab896d7d9f4d10ba89d3b09 b/test/core/transport/chttp2/hpack_parser_corpus/051268ade45dbed0aab896d7d9f4d10ba89d3b09 new file mode 100644 index 0000000000..70967ff47f --- /dev/null +++ b/test/core/transport/chttp2/hpack_parser_corpus/051268ade45dbed0aab896d7d9f4d10ba89d3b09 @@ -0,0 +1 @@ +*¤¤¤ð¤-bin‹c[)(ð¤-bin-'bin !!?¤Ûð!ð{(-binð !\ !å7é;?Gí([(!!\ð*¤¤Ûð
\ No newline at end of file diff --git a/test/core/transport/chttp2/hpack_parser_corpus/5278e3581c069624157fd9176eddf52c0e58df67 b/test/core/transport/chttp2/hpack_parser_corpus/5278e3581c069624157fd9176eddf52c0e58df67 Binary files differnew file mode 100644 index 0000000000..8f3d4a9d34 --- /dev/null +++ b/test/core/transport/chttp2/hpack_parser_corpus/5278e3581c069624157fd9176eddf52c0e58df67 diff --git a/test/core/transport/chttp2/hpack_parser_corpus/bc4263a92952d56168b354f723eaa43a33cd0b35 b/test/core/transport/chttp2/hpack_parser_corpus/bc4263a92952d56168b354f723eaa43a33cd0b35 Binary files differnew file mode 100644 index 0000000000..d62e767643 --- /dev/null +++ b/test/core/transport/chttp2/hpack_parser_corpus/bc4263a92952d56168b354f723eaa43a33cd0b35 diff --git a/test/core/transport/chttp2/hpack_parser_corpus/crash-5ac3e1ea7764cfb6383629574262f82dc7b3cada b/test/core/transport/chttp2/hpack_parser_corpus/crash-5ac3e1ea7764cfb6383629574262f82dc7b3cada Binary files differnew file mode 100644 index 0000000000..44984f3362 --- /dev/null +++ b/test/core/transport/chttp2/hpack_parser_corpus/crash-5ac3e1ea7764cfb6383629574262f82dc7b3cada diff --git a/test/core/transport/chttp2/hpack_parser_corpus/d6d8b478e6d13945f7a6f7d27f424ff57ca12f7f b/test/core/transport/chttp2/hpack_parser_corpus/d6d8b478e6d13945f7a6f7d27f424ff57ca12f7f Binary files differnew file mode 100644 index 0000000000..ace84afe5b --- /dev/null +++ b/test/core/transport/chttp2/hpack_parser_corpus/d6d8b478e6d13945f7a6f7d27f424ff57ca12f7f diff --git a/test/core/transport/chttp2/hpack_parser_corpus/e67c79d0ed89ab2d5e8d81127df22876e636ac44 b/test/core/transport/chttp2/hpack_parser_corpus/e67c79d0ed89ab2d5e8d81127df22876e636ac44 Binary files differnew file mode 100644 index 0000000000..600b6cd000 --- /dev/null +++ b/test/core/transport/chttp2/hpack_parser_corpus/e67c79d0ed89ab2d5e8d81127df22876e636ac44 diff --git a/test/core/transport/chttp2/hpack_parser_corpus/f4b48c4f3f310ed767755267210f212dd62bd715 b/test/core/transport/chttp2/hpack_parser_corpus/f4b48c4f3f310ed767755267210f212dd62bd715 Binary files differnew file mode 100644 index 0000000000..49ea9081b8 --- /dev/null +++ b/test/core/transport/chttp2/hpack_parser_corpus/f4b48c4f3f310ed767755267210f212dd62bd715 diff --git a/test/core/transport/chttp2/hpack_parser_corpus/fcc06696e641a7743bfd2f3b7ecd88e7b727e00a b/test/core/transport/chttp2/hpack_parser_corpus/fcc06696e641a7743bfd2f3b7ecd88e7b727e00a new file mode 100644 index 0000000000..f79c824bd1 --- /dev/null +++ b/test/core/transport/chttp2/hpack_parser_corpus/fcc06696e641a7743bfd2f3b7ecd88e7b727e00a @@ -0,0 +1 @@ +;?'cð[(! ð[N!\ !åGý!acceptý.:¤cA)(!)í!¼ª)ågÝI)(Ù;)Š
\ No newline at end of file diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.c b/test/core/transport/chttp2/hpack_parser_fuzzer_test.c index 95acbf1a68..e9ac16df2d 100644 --- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.c +++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.c @@ -39,27 +39,28 @@ #include <grpc/support/log.h> #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" +#include "src/core/lib/slice/slice_internal.h" bool squelch = true; bool leak_check = true; -static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem *md) { - GRPC_MDELEM_UNREF(md); +static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem md) { + GRPC_MDELEM_UNREF(exec_ctx, md); } static void dont_log(gpr_log_func_args *args) {} int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - grpc_test_only_set_metadata_hash_seed(0); + grpc_test_only_set_slice_hash_seed(0); 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_ERROR_UNREF( - grpc_chttp2_hpack_parser_parse(&exec_ctx, &parser, data, data + size)); + grpc_chttp2_hpack_parser_init(&exec_ctx, &parser); + parser.on_header = onhdr; + GRPC_ERROR_UNREF(grpc_chttp2_hpack_parser_parse( + &exec_ctx, &parser, grpc_slice_from_static_buffer(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..01789c4fb4 100644 --- a/test/core/transport/chttp2/hpack_parser_test.c +++ b/test/core/transport/chttp2/hpack_parser_test.c @@ -45,16 +45,16 @@ typedef struct { va_list args; } test_checker; -static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem *md) { +static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem md) { const char *ekey, *evalue; test_checker *chk = ud; ekey = va_arg(chk->args, char *); GPR_ASSERT(ekey); evalue = va_arg(chk->args, char *); 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); + GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(md), ekey) == 0); + GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(md), evalue) == 0); + GRPC_MDELEM_UNREF(exec_ctx, md); } static void test_vector(grpc_chttp2_hpack_parser *parser, @@ -76,9 +76,8 @@ static void test_vector(grpc_chttp2_hpack_parser *parser, for (i = 0; i < nslices; i++) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GPR_ASSERT(grpc_chttp2_hpack_parser_parse( - &exec_ctx, parser, GRPC_SLICE_START_PTR(slices[i]), - GRPC_SLICE_END_PTR(slices[i])) == GRPC_ERROR_NONE); + GPR_ASSERT(grpc_chttp2_hpack_parser_parse(&exec_ctx, parser, slices[i]) == + GRPC_ERROR_NONE); grpc_exec_ctx_finish(&exec_ctx); } @@ -94,8 +93,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 +111,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 +131,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 +151,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 +185,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 +216,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..d2f6d5dc5b 100644 --- a/test/core/transport/chttp2/hpack_table_test.c +++ b/test/core/transport/chttp2/hpack_table_test.c @@ -46,22 +46,23 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) -static void assert_str(const grpc_chttp2_hptbl *tbl, grpc_mdstr *mdstr, +static void assert_str(const grpc_chttp2_hptbl *tbl, grpc_slice mdstr, const char *str) { - GPR_ASSERT(grpc_slice_str_cmp(mdstr->slice, str) == 0); + GPR_ASSERT(grpc_slice_str_cmp(mdstr, str) == 0); } static void assert_index(const grpc_chttp2_hptbl *tbl, uint32_t idx, const char *key, const char *value) { - grpc_mdelem *md = grpc_chttp2_hptbl_lookup(tbl, idx); - assert_str(tbl, md->key, key); - assert_str(tbl, md->value, value); + grpc_mdelem md = grpc_chttp2_hptbl_lookup(tbl, idx); + assert_str(tbl, GRPC_MDKEY(md), key); + assert_str(tbl, GRPC_MDVALUE(md), value); } 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,18 @@ 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; + 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_slices(&exec_ctx, grpc_slice_from_copied_string(key), + grpc_slice_from_copied_string(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,37 +163,48 @@ 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_slices(&exec_ctx, grpc_slice_from_copied_string(key), + grpc_slice_from_copied_string(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]; - grpc_mdelem *elem; + grpc_mdelem elem; grpc_chttp2_hptbl_find_result r; 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_slices(&exec_ctx, grpc_slice_from_static_string("abc"), + grpc_slice_from_static_string("xyz")); + GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE); + GRPC_MDELEM_UNREF(&exec_ctx, elem); + elem = + grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_static_string("abc"), + grpc_slice_from_static_string("123")); + GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE); + GRPC_MDELEM_UNREF(&exec_ctx, elem); + elem = grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_static_string("x"), + grpc_slice_from_static_string("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 +253,11 @@ 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_slices(&exec_ctx, + grpc_slice_from_static_string("test"), + grpc_slice_from_copied_string(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 +285,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/chttp2/varint_test.c b/test/core/transport/chttp2/varint_test.c index e29be4b056..f12c340a4b 100644 --- a/test/core/transport/chttp2/varint_test.c +++ b/test/core/transport/chttp2/varint_test.c @@ -49,7 +49,7 @@ static void test_varint(uint32_t value, uint32_t prefix_bits, uint8_t prefix_or, slice = grpc_slice_malloc(nbytes); GRPC_CHTTP2_WRITE_VARINT(value, prefix_bits, prefix_or, GRPC_SLICE_START_PTR(slice), nbytes); - GPR_ASSERT(grpc_slice_cmp(expect, slice) == 0); + GPR_ASSERT(grpc_slice_eq(expect, slice)); grpc_slice_unref(expect); grpc_slice_unref(slice); } 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..92e58f2375 100644 --- a/test/core/transport/metadata_test.c +++ b/test/core/transport/metadata_test.c @@ -42,114 +42,198 @@ #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" -#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) - /* a large number */ #define MANY 10000 static void test_no_op(void) { - LOG_TEST("test_no_op"); + gpr_log(GPR_INFO, "test_no_op"); grpc_init(); grpc_shutdown(); } -static void test_create_string(void) { - grpc_mdstr *s1, *s2, *s3; - - LOG_TEST("test_create_string"); +static grpc_slice maybe_intern(grpc_slice in, bool intern) { + grpc_slice out = intern ? grpc_slice_intern(in) : grpc_slice_ref(in); + grpc_slice_unref(in); + return out; +} - grpc_init(); - s1 = grpc_mdstr_from_string("hello"); - s2 = grpc_mdstr_from_string("hello"); - s3 = grpc_mdstr_from_string("very much not hello"); - GPR_ASSERT(s1 == s2); - 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_shutdown(); +static grpc_slice maybe_dup(grpc_slice in, bool dup) { + grpc_slice out = dup ? grpc_slice_dup(in) : grpc_slice_ref(in); + grpc_slice_unref(in); + return out; } -static void test_create_metadata(void) { - grpc_mdelem *m1, *m2, *m3; +static void test_create_metadata(bool intern_keys, bool intern_values) { + grpc_mdelem m1, m2, m3; - LOG_TEST("test_create_metadata"); + gpr_log(GPR_INFO, "test_create_metadata: intern_keys=%d intern_values=%d", + intern_keys, intern_values); grpc_init(); - m1 = grpc_mdelem_from_strings("a", "b"); - m2 = grpc_mdelem_from_strings("a", "b"); - m3 = grpc_mdelem_from_strings("a", "c"); - GPR_ASSERT(m1 == m2); - GPR_ASSERT(m3 != m1); - GPR_ASSERT(m3->key == m1->key); - GPR_ASSERT(m3->value != m1->value); - 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_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + m1 = grpc_mdelem_from_slices( + &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys), + maybe_intern(grpc_slice_from_static_string("b"), intern_values)); + m2 = grpc_mdelem_from_slices( + &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys), + maybe_intern(grpc_slice_from_static_string("b"), intern_values)); + m3 = grpc_mdelem_from_slices( + &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys), + maybe_intern(grpc_slice_from_static_string("c"), intern_values)); + GPR_ASSERT(grpc_mdelem_eq(m1, m2)); + GPR_ASSERT(!grpc_mdelem_eq(m3, m1)); + GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(m3), GRPC_MDKEY(m1))); + GPR_ASSERT(!grpc_slice_eq(GRPC_MDVALUE(m3), GRPC_MDVALUE(m1))); + GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(m1), "a") == 0); + GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(m1), "b") == 0); + GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(m3), "c") == 0); + 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(); } -static void test_create_many_ephemeral_metadata(void) { +static void test_create_many_ephemeral_metadata(bool intern_keys, + bool intern_values) { char buffer[GPR_LTOA_MIN_BUFSIZE]; long i; - LOG_TEST("test_create_many_ephemeral_metadata"); + gpr_log( + GPR_INFO, + "test_create_many_ephemeral_metadata: intern_keys=%d intern_values=%d", + intern_keys, intern_values); 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_slices( + &exec_ctx, + maybe_intern(grpc_slice_from_static_string("a"), intern_keys), + maybe_intern(grpc_slice_from_copied_string(buffer), + intern_values))); } + grpc_exec_ctx_finish(&exec_ctx); grpc_shutdown(); } static void test_create_many_persistant_metadata(void) { char buffer[GPR_LTOA_MIN_BUFSIZE]; long i; - grpc_mdelem **created = gpr_malloc(sizeof(grpc_mdelem *) * MANY); - grpc_mdelem *md; + grpc_mdelem *created = gpr_malloc(sizeof(grpc_mdelem) * MANY); + grpc_mdelem md; - LOG_TEST("test_create_many_persistant_metadata"); + gpr_log(GPR_INFO, "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_slices( + &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("a")), + grpc_slice_intern(grpc_slice_from_static_string(buffer))); } /* verify phase */ for (i = 0; i < MANY; i++) { gpr_ltoa(i, buffer); - md = grpc_mdelem_from_strings("a", buffer); - GPR_ASSERT(md == created[i]); - GRPC_MDELEM_UNREF(md); + md = grpc_mdelem_from_slices( + &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("a")), + grpc_slice_intern(grpc_slice_from_static_string(buffer))); + GPR_ASSERT(grpc_mdelem_eq(md, created[i])); + 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); } -static void test_spin_creating_the_same_thing(void) { - LOG_TEST("test_spin_creating_the_same_thing"); +static void test_spin_creating_the_same_thing(bool intern_keys, + bool intern_values) { + gpr_log(GPR_INFO, + "test_spin_creating_the_same_thing: intern_keys=%d intern_values=%d", + intern_keys, intern_values); + + grpc_init(); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_mdelem a, b, c; + GRPC_MDELEM_UNREF( + &exec_ctx, + a = grpc_mdelem_from_slices( + &exec_ctx, + maybe_intern(grpc_slice_from_static_string("a"), intern_keys), + maybe_intern(grpc_slice_from_static_string("b"), intern_values))); + GRPC_MDELEM_UNREF( + &exec_ctx, + b = grpc_mdelem_from_slices( + &exec_ctx, + maybe_intern(grpc_slice_from_static_string("a"), intern_keys), + maybe_intern(grpc_slice_from_static_string("b"), intern_values))); + GRPC_MDELEM_UNREF( + &exec_ctx, + c = grpc_mdelem_from_slices( + &exec_ctx, + maybe_intern(grpc_slice_from_static_string("a"), intern_keys), + maybe_intern(grpc_slice_from_static_string("b"), intern_values))); + if (intern_keys && intern_values) { + GPR_ASSERT(a.payload == b.payload); + GPR_ASSERT(a.payload == c.payload); + } + grpc_exec_ctx_finish(&exec_ctx); + grpc_shutdown(); +} + +static void test_identity_laws(bool intern_keys, bool intern_values) { + gpr_log(GPR_INFO, "test_identity_laws: intern_keys=%d intern_values=%d", + intern_keys, intern_values); 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 a, b, c; + a = grpc_mdelem_from_slices( + &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys), + maybe_intern(grpc_slice_from_static_string("b"), intern_values)); + b = grpc_mdelem_from_slices( + &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys), + maybe_intern(grpc_slice_from_static_string("b"), intern_values)); + c = grpc_mdelem_from_slices( + &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys), + maybe_intern(grpc_slice_from_static_string("b"), intern_values)); + GPR_ASSERT(grpc_mdelem_eq(a, a)); + GPR_ASSERT(grpc_mdelem_eq(b, b)); + GPR_ASSERT(grpc_mdelem_eq(c, c)); + GPR_ASSERT(grpc_mdelem_eq(a, b)); + GPR_ASSERT(grpc_mdelem_eq(b, c)); + GPR_ASSERT(grpc_mdelem_eq(a, c)); + GPR_ASSERT(grpc_mdelem_eq(b, a)); + GPR_ASSERT(grpc_mdelem_eq(c, b)); + GPR_ASSERT(grpc_mdelem_eq(c, a)); + if (intern_keys && intern_values) { + GPR_ASSERT(a.payload == b.payload); + GPR_ASSERT(a.payload == c.payload); + } else { + GPR_ASSERT(a.payload != b.payload); + GPR_ASSERT(a.payload != c.payload); + GPR_ASSERT(b.payload != c.payload); + } + GRPC_MDELEM_UNREF(&exec_ctx, a); + GRPC_MDELEM_UNREF(&exec_ctx, b); + GRPC_MDELEM_UNREF(&exec_ctx, c); + grpc_exec_ctx_finish(&exec_ctx); grpc_shutdown(); } @@ -157,24 +241,25 @@ static void test_things_stick_around(void) { size_t i, j; char *buffer; size_t nstrs = 1000; - grpc_mdstr **strs = gpr_malloc(sizeof(grpc_mdstr *) * nstrs); + grpc_slice *strs = gpr_malloc(sizeof(grpc_slice) * nstrs); size_t *shuf = gpr_malloc(sizeof(size_t) * nstrs); - grpc_mdstr *test; + grpc_slice test; - LOG_TEST("test_things_stick_around"); + gpr_log(GPR_INFO, "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); - strs[i] = grpc_mdstr_from_string(buffer); + strs[i] = grpc_slice_intern(grpc_slice_from_static_string(buffer)); shuf[i] = i; gpr_free(buffer); } for (i = 0; i < nstrs; i++) { - GRPC_MDSTR_REF(strs[i]); - GRPC_MDSTR_UNREF(strs[i]); + grpc_slice_ref_internal(strs[i]); + grpc_slice_unref_internal(&exec_ctx, strs[i]); } for (i = 0; i < nstrs; i++) { @@ -186,143 +271,147 @@ static void test_things_stick_around(void) { } for (i = 0; i < nstrs; i++) { - GRPC_MDSTR_UNREF(strs[shuf[i]]); + grpc_slice_unref_internal(&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); + test = grpc_slice_intern(grpc_slice_from_static_string(buffer)); + GPR_ASSERT(grpc_slice_is_equivalent(test, strs[shuf[j]])); + grpc_slice_unref_internal(&exec_ctx, test); gpr_free(buffer); } } + grpc_exec_ctx_finish(&exec_ctx); grpc_shutdown(); gpr_free(strs); gpr_free(shuf); } -static void test_slices_work(void) { - /* ensure no memory leaks when switching representation from mdstr to slice */ - grpc_mdstr *str; - grpc_slice slice; - - LOG_TEST("test_slices_work"); - - grpc_init(); - - str = grpc_mdstr_from_string( - "123456789012345678901234567890123456789012345678901234567890"); - slice = grpc_slice_ref(str->slice); - GRPC_MDSTR_UNREF(str); - grpc_slice_unref(slice); - - str = grpc_mdstr_from_string( - "123456789012345678901234567890123456789012345678901234567890"); - slice = grpc_slice_ref(str->slice); - grpc_slice_unref(slice); - GRPC_MDSTR_UNREF(str); - - grpc_shutdown(); -} - -static void test_base64_and_huffman_works(void) { - grpc_mdstr *str; - grpc_slice slice1; - grpc_slice slice2; - - LOG_TEST("test_base64_and_huffman_works"); - - grpc_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_shutdown(); -} - static void test_user_data_works(void) { int *ud1; int *ud2; - grpc_mdelem *md; - LOG_TEST("test_user_data_works"); + grpc_mdelem md; + gpr_log(GPR_INFO, "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_slices( + &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")), + grpc_slice_intern(grpc_slice_from_static_string("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, bool intern_key, + bool intern_value) { + grpc_mdelem elem = grpc_mdelem_from_slices( + exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key), + maybe_intern(grpc_slice_from_static_string(value), intern_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); - GPR_ASSERT(grpc_is_binary_header(key, strlen(key))); +static void verify_binary_header_size(grpc_exec_ctx *exec_ctx, const char *key, + const uint8_t *value, size_t value_len, + bool intern_key, bool intern_value) { + grpc_mdelem elem = grpc_mdelem_from_slices( + exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key), + maybe_intern(grpc_slice_from_static_buffer(value, value_len), + intern_value)); + GPR_ASSERT(grpc_is_binary_header(GRPC_MDKEY(elem))); size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem); grpc_slice value_slice = grpc_slice_from_copied_buffer((const char *)value, value_len); 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"); +static void test_mdelem_sizes_in_hpack(bool intern_key, bool intern_value) { + gpr_log(GPR_INFO, "test_mdelem_size: intern_key=%d intern_value=%d", + intern_key, intern_value); 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", intern_key, + intern_value); + verify_ascii_header_size(&exec_ctx, "hello", + "worldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", intern_key, + intern_value); + verify_ascii_header_size(&exec_ctx, ":scheme", "http", intern_key, + intern_value); 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, + intern_key, intern_value); } - 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)); + grpc_exec_ctx_finish(&exec_ctx); + grpc_shutdown(); +} +static void test_copied_static_metadata(bool dup_key, bool dup_value) { + gpr_log(GPR_INFO, "test_static_metadata: dup_key=%d dup_value=%d", dup_key, + dup_value); + grpc_init(); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + + for (size_t i = 0; i < GRPC_STATIC_MDELEM_COUNT; i++) { + grpc_mdelem p = GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[i], + GRPC_MDELEM_STORAGE_STATIC); + grpc_mdelem q = + grpc_mdelem_from_slices(&exec_ctx, maybe_dup(GRPC_MDKEY(p), dup_key), + maybe_dup(GRPC_MDVALUE(p), dup_value)); + GPR_ASSERT(grpc_mdelem_eq(p, q)); + if (dup_key || dup_value) { + GPR_ASSERT(p.payload != q.payload); + } else { + GPR_ASSERT(p.payload == q.payload); + } + GRPC_MDELEM_UNREF(&exec_ctx, p); + GRPC_MDELEM_UNREF(&exec_ctx, q); + } + + grpc_exec_ctx_finish(&exec_ctx); grpc_shutdown(); } int main(int argc, char **argv) { grpc_test_init(argc, argv); test_no_op(); - test_create_string(); - test_create_metadata(); - test_create_many_ephemeral_metadata(); + for (int k = 0; k <= 1; k++) { + for (int v = 0; v <= 1; v++) { + test_create_metadata(k, v); + test_create_many_ephemeral_metadata(k, v); + test_identity_laws(k, v); + test_spin_creating_the_same_thing(k, v); + test_mdelem_sizes_in_hpack(k, v); + test_copied_static_metadata(k, v); + } + } test_create_many_persistant_metadata(); - test_spin_creating_the_same_thing(); test_things_stick_around(); - test_slices_work(); - test_base64_and_huffman_works(); test_user_data_works(); - test_mdelem_sizes_in_hpack(); return 0; } diff --git a/test/core/transport/pid_controller_test.c b/test/core/transport/pid_controller_test.c index 9614983b00..831343c815 100644 --- a/test/core/transport/pid_controller_test.c +++ b/test/core/transport/pid_controller_test.c @@ -33,6 +33,7 @@ #include "src/core/lib/transport/pid_controller.h" +#include <float.h> #include <math.h> #include <grpc/support/alloc.h> @@ -45,7 +46,14 @@ static void test_noop(void) { gpr_log(GPR_INFO, "test_noop"); grpc_pid_controller pid; - grpc_pid_controller_init(&pid, 1, 1, 1); + grpc_pid_controller_init( + &pid, (grpc_pid_controller_args){.gain_p = 1, + .gain_i = 1, + .gain_d = 1, + .initial_control_value = 1, + .min_control_value = DBL_MIN, + .max_control_value = DBL_MAX, + .integral_range = DBL_MAX}); } static void test_simple_convergence(double gain_p, double gain_i, double gain_d, @@ -55,16 +63,24 @@ static void test_simple_convergence(double gain_p, double gain_i, double gain_d, "start=%lf", gain_p, gain_i, gain_d, dt, set_point, start); grpc_pid_controller pid; - grpc_pid_controller_init(&pid, 0.2, 0.1, 0.1); + grpc_pid_controller_init( + &pid, (grpc_pid_controller_args){.gain_p = gain_p, + .gain_i = gain_i, + .gain_d = gain_d, + .initial_control_value = start, + .min_control_value = DBL_MIN, + .max_control_value = DBL_MAX, + .integral_range = DBL_MAX}); - double current = start; - - for (int i = 0; i < 1000; i++) { - current += grpc_pid_controller_update(&pid, set_point - current, 1); + for (int i = 0; i < 100000; i++) { + grpc_pid_controller_update(&pid, set_point - grpc_pid_controller_last(&pid), + 1); } - GPR_ASSERT(fabs(set_point - current) < 0.1); - GPR_ASSERT(fabs(pid.error_integral) < 0.1); + GPR_ASSERT(fabs(set_point - grpc_pid_controller_last(&pid)) < 0.1); + if (gain_i > 0) { + GPR_ASSERT(fabs(pid.error_integral) < 0.1); + } } int main(int argc, char **argv) { diff --git a/test/core/transport/chttp2/status_conversion_test.c b/test/core/transport/status_conversion_test.c index f5a5cd1395..65f840b1e2 100644 --- a/test/core/transport/chttp2/status_conversion_test.c +++ b/test/core/transport/status_conversion_test.c @@ -31,50 +31,50 @@ * */ -#include "src/core/ext/transport/chttp2/transport/status_conversion.h" +#include "src/core/lib/transport/status_conversion.h" #include <grpc/support/log.h> #include "test/core/util/test_config.h" #define GRPC_STATUS_TO_HTTP2_ERROR(a, b) \ - GPR_ASSERT(grpc_chttp2_grpc_status_to_http2_error(a) == (b)) + GPR_ASSERT(grpc_status_to_http2_error(a) == (b)) #define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \ - GPR_ASSERT(grpc_chttp2_http2_error_to_grpc_status(a, deadline) == (b)) + GPR_ASSERT(grpc_http2_error_to_grpc_status(a, deadline) == (b)) #define GRPC_STATUS_TO_HTTP2_STATUS(a, b) \ - GPR_ASSERT(grpc_chttp2_grpc_status_to_http2_status(a) == (b)) + GPR_ASSERT(grpc_status_to_http2_status(a) == (b)) #define HTTP2_STATUS_TO_GRPC_STATUS(a, b) \ - GPR_ASSERT(grpc_chttp2_http2_status_to_grpc_status(a) == (b)) + GPR_ASSERT(grpc_http2_status_to_grpc_status(a) == (b)) int main(int argc, char **argv) { int i; grpc_test_init(argc, argv); - GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_OK, GRPC_CHTTP2_NO_ERROR); - GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_CANCELLED, GRPC_CHTTP2_CANCEL); - GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNKNOWN, GRPC_CHTTP2_INTERNAL_ERROR); + GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_OK, GRPC_HTTP2_NO_ERROR); + GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_CANCELLED, GRPC_HTTP2_CANCEL); + GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNKNOWN, GRPC_HTTP2_INTERNAL_ERROR); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_INVALID_ARGUMENT, - GRPC_CHTTP2_INTERNAL_ERROR); - GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DEADLINE_EXCEEDED, GRPC_CHTTP2_CANCEL); - GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_NOT_FOUND, GRPC_CHTTP2_INTERNAL_ERROR); + GRPC_HTTP2_INTERNAL_ERROR); + GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DEADLINE_EXCEEDED, GRPC_HTTP2_CANCEL); + GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_NOT_FOUND, GRPC_HTTP2_INTERNAL_ERROR); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_ALREADY_EXISTS, - GRPC_CHTTP2_INTERNAL_ERROR); + GRPC_HTTP2_INTERNAL_ERROR); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_PERMISSION_DENIED, - GRPC_CHTTP2_INADEQUATE_SECURITY); + GRPC_HTTP2_INADEQUATE_SECURITY); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNAUTHENTICATED, - GRPC_CHTTP2_INTERNAL_ERROR); + GRPC_HTTP2_INTERNAL_ERROR); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_RESOURCE_EXHAUSTED, - GRPC_CHTTP2_ENHANCE_YOUR_CALM); + GRPC_HTTP2_ENHANCE_YOUR_CALM); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_FAILED_PRECONDITION, - GRPC_CHTTP2_INTERNAL_ERROR); - GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_ABORTED, GRPC_CHTTP2_INTERNAL_ERROR); + GRPC_HTTP2_INTERNAL_ERROR); + GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_ABORTED, GRPC_HTTP2_INTERNAL_ERROR); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_OUT_OF_RANGE, - GRPC_CHTTP2_INTERNAL_ERROR); + GRPC_HTTP2_INTERNAL_ERROR); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNIMPLEMENTED, - GRPC_CHTTP2_INTERNAL_ERROR); - GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_INTERNAL, GRPC_CHTTP2_INTERNAL_ERROR); + GRPC_HTTP2_INTERNAL_ERROR); + GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_INTERNAL, GRPC_HTTP2_INTERNAL_ERROR); GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNAVAILABLE, - GRPC_CHTTP2_REFUSED_STREAM); - GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DATA_LOSS, GRPC_CHTTP2_INTERNAL_ERROR); + GRPC_HTTP2_REFUSED_STREAM); + GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DATA_LOSS, GRPC_HTTP2_INTERNAL_ERROR); GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_OK, 200); GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_CANCELLED, 200); @@ -95,59 +95,59 @@ int main(int argc, char **argv) { GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_DATA_LOSS, 200); const gpr_timespec before_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_NO_ERROR, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, before_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_PROTOCOL_ERROR, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_PROTOCOL_ERROR, before_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_INTERNAL_ERROR, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INTERNAL_ERROR, before_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_FLOW_CONTROL_ERROR, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_FLOW_CONTROL_ERROR, before_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_SETTINGS_TIMEOUT, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_SETTINGS_TIMEOUT, before_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_STREAM_CLOSED, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_STREAM_CLOSED, before_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_FRAME_SIZE_ERROR, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_FRAME_SIZE_ERROR, before_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_REFUSED_STREAM, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_REFUSED_STREAM, before_deadline, GRPC_STATUS_UNAVAILABLE); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_CANCEL, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_CANCEL, before_deadline, GRPC_STATUS_CANCELLED); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_COMPRESSION_ERROR, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_COMPRESSION_ERROR, before_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_CONNECT_ERROR, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_CONNECT_ERROR, before_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_ENHANCE_YOUR_CALM, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_ENHANCE_YOUR_CALM, before_deadline, GRPC_STATUS_RESOURCE_EXHAUSTED); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_INADEQUATE_SECURITY, before_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INADEQUATE_SECURITY, before_deadline, GRPC_STATUS_PERMISSION_DENIED); const gpr_timespec after_deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_NO_ERROR, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, after_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_PROTOCOL_ERROR, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_PROTOCOL_ERROR, after_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_INTERNAL_ERROR, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INTERNAL_ERROR, after_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_FLOW_CONTROL_ERROR, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_FLOW_CONTROL_ERROR, after_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_SETTINGS_TIMEOUT, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_SETTINGS_TIMEOUT, after_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_STREAM_CLOSED, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_STREAM_CLOSED, after_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_FRAME_SIZE_ERROR, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_FRAME_SIZE_ERROR, after_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_REFUSED_STREAM, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_REFUSED_STREAM, after_deadline, GRPC_STATUS_UNAVAILABLE); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_CANCEL, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_CANCEL, after_deadline, GRPC_STATUS_DEADLINE_EXCEEDED); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_COMPRESSION_ERROR, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_COMPRESSION_ERROR, after_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_CONNECT_ERROR, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_CONNECT_ERROR, after_deadline, GRPC_STATUS_INTERNAL); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_ENHANCE_YOUR_CALM, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_ENHANCE_YOUR_CALM, after_deadline, GRPC_STATUS_RESOURCE_EXHAUSTED); - HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_INADEQUATE_SECURITY, after_deadline, + HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INADEQUATE_SECURITY, after_deadline, GRPC_STATUS_PERMISSION_DENIED); HTTP2_STATUS_TO_GRPC_STATUS(200, GRPC_STATUS_OK); @@ -165,7 +165,7 @@ int main(int argc, char **argv) { /* check all status values can be converted */ for (i = 0; i <= 999; i++) { - grpc_chttp2_http2_status_to_grpc_status(i); + grpc_http2_status_to_grpc_status(i); } return 0; diff --git a/test/core/transport/timeout_encoding_test.c b/test/core/transport/timeout_encoding_test.c index b6004af7b4..10e1804995 100644 --- a/test/core/transport/timeout_encoding_test.c +++ b/test/core/transport/timeout_encoding_test.c @@ -88,7 +88,8 @@ void test_encoding(void) { static void assert_decodes_as(const char *buffer, gpr_timespec expected) { gpr_timespec got; gpr_log(GPR_INFO, "check decoding '%s'", buffer); - GPR_ASSERT(1 == grpc_http2_decode_timeout(buffer, &got)); + GPR_ASSERT(1 == grpc_http2_decode_timeout( + grpc_slice_from_static_string(buffer), &got)); GPR_ASSERT(0 == gpr_time_cmp(got, expected)); } @@ -134,18 +135,23 @@ void test_decoding(void) { assert_decodes_as("9999999999S", gpr_inf_future(GPR_TIMESPAN)); } -void test_decoding_fails(void) { +static void assert_decoding_fails(const char *s) { gpr_timespec x; + GPR_ASSERT(0 == + grpc_http2_decode_timeout(grpc_slice_from_static_string(s), &x)); +} + +void test_decoding_fails(void) { LOG_TEST("test_decoding_fails"); - GPR_ASSERT(0 == grpc_http2_decode_timeout("", &x)); - GPR_ASSERT(0 == grpc_http2_decode_timeout(" ", &x)); - GPR_ASSERT(0 == grpc_http2_decode_timeout("x", &x)); - GPR_ASSERT(0 == grpc_http2_decode_timeout("1", &x)); - GPR_ASSERT(0 == grpc_http2_decode_timeout("1x", &x)); - GPR_ASSERT(0 == grpc_http2_decode_timeout("1ux", &x)); - GPR_ASSERT(0 == grpc_http2_decode_timeout("!", &x)); - GPR_ASSERT(0 == grpc_http2_decode_timeout("n1", &x)); - GPR_ASSERT(0 == grpc_http2_decode_timeout("-1u", &x)); + assert_decoding_fails(""); + assert_decoding_fails(" "); + assert_decoding_fails("x"); + assert_decoding_fails("1"); + assert_decoding_fails("1x"); + assert_decoding_fails("1ux"); + assert_decoding_fails("!"); + assert_decoding_fails("n1"); + assert_decoding_fails("-1u"); } int main(int argc, char **argv) { diff --git a/test/core/util/BUILD b/test/core/util/BUILD new file mode 100644 index 0000000000..5c90f1db44 --- /dev/null +++ b/test/core/util/BUILD @@ -0,0 +1,89 @@ +# 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 = [ + "debugger_macros.c", + "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 = [ + "debugger_macros.h", + "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/debugger_macros.c b/test/core/util/debugger_macros.c new file mode 100644 index 0000000000..de6a2f38a7 --- /dev/null +++ b/test/core/util/debugger_macros.c @@ -0,0 +1,71 @@ +/* + * + * 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. + * + */ + +/* + * A collection of 'macros' that help navigating the grpc object hierarchy + * Not intended to be robust for main-line code, often cuts across abstraction + * boundaries. + */ + +#include <stdio.h> + +#include "src/core/ext/client_channel/client_channel.h" +#include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/surface/call.h" + +void grpc_summon_debugger_macros() {} + +grpc_stream *grpc_transport_stream_from_call(grpc_call *call) { + grpc_call_stack *cs = grpc_call_get_call_stack(call); + for (;;) { + grpc_call_element *el = grpc_call_stack_element(cs, cs->count - 1); + if (el->filter == &grpc_client_channel_filter) { + grpc_subchannel_call *scc = grpc_client_channel_get_subchannel_call(el); + if (scc == NULL) { + fprintf(stderr, "No subchannel-call"); + return NULL; + } + cs = grpc_subchannel_call_get_call_stack(scc); + } else if (el->filter == &grpc_connected_filter) { + return grpc_connected_channel_get_stream(el); + } else { + fprintf(stderr, "Unrecognized filter: %s", el->filter->name); + return NULL; + } + } +} + +grpc_chttp2_stream *grpc_chttp2_stream_from_call(grpc_call *call) { + return (grpc_chttp2_stream *)grpc_transport_stream_from_call(call); +} diff --git a/test/cpp/qps/limit_cores.h b/test/core/util/debugger_macros.h index 5482904a3c..6369ca6c97 100644 --- a/test/cpp/qps/limit_cores.h +++ b/test/core/util/debugger_macros.h @@ -31,19 +31,9 @@ * */ -#ifndef TEST_QPS_LIMIT_CORES_H -#define TEST_QPS_LIMIT_CORES_H +#ifndef GRPC_TEST_CORE_UTIL_DEBUGGER_MACROS_H +#define GRPC_TEST_CORE_UTIL_DEBUGGER_MACROS_H -namespace grpc { -namespace testing { -/// LimitCores: allow this worker to only run on the cores specified in the -/// array \a cores, which is of length \a cores_size. -/// -/// LimitCores takes array and size arguments (instead of vector) for direct -/// conversion from repeated field of protobuf. Use a cores_size of 0 to remove -/// existing limits (from an empty repeated field) -int LimitCores(const int *cores, int cores_size); -} // namespace testing -} // namespace grpc +void grpc_summon_debugger_macros(); -#endif // TEST_QPS_LIMIT_CORES_H +#endif /* GRPC_TEST_CORE_UTIL_DEBUGGER_MACROS_H */ 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..d531ec6031 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, @@ -78,16 +78,18 @@ static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, static void me_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, grpc_pollset_set *pollset) {} -static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { +static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, + grpc_error *why) { 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_REFERENCING( + "Endpoint Shutdown", &why, 1)); m->on_read = NULL; } gpr_mu_unlock(&m->mu); grpc_resource_user_shutdown(exec_ctx, m->resource_user); + GRPC_ERROR_UNREF(why); } static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { @@ -144,7 +146,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..1e82c737c6 100644 --- a/test/core/util/passthru_endpoint.c +++ b/test/core/util/passthru_endpoint.c @@ -34,11 +34,14 @@ #include "test/core/util/passthru_endpoint.h" #include <inttypes.h> +#include <string.h> #include <grpc/support/alloc.h> #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 { @@ -53,6 +56,9 @@ typedef struct { struct passthru_endpoint { gpr_mu mu; int halves; + grpc_passthru_endpoint_stats *stats; + grpc_passthru_endpoint_stats + dummy_stats; // used if constructor stats == NULL bool shutdown; half client; half server; @@ -63,11 +69,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; @@ -85,13 +90,14 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, half *m = other_half((half *)ep); gpr_mu_lock(&m->parent->mu); grpc_error *error = GRPC_ERROR_NONE; + m->parent->stats->num_writes++; if (m->parent->shutdown) { error = GRPC_ERROR_CREATE("Endpoint already shutdown"); } else if (m->on_read != NULL) { 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 +105,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, @@ -108,23 +114,25 @@ static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, static void me_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, grpc_pollset_set *pollset) {} -static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { +static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, + grpc_error *why) { half *m = (half *)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_REFERENCING("Shutdown", &why, 1)); 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_REFERENCING("Shutdown", &why, 1)); m->on_read = NULL; } gpr_mu_unlock(&m->parent->mu); grpc_resource_user_shutdown(exec_ctx, m->resource_user); + GRPC_ERROR_UNREF(why); } static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { @@ -133,8 +141,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); @@ -144,7 +152,9 @@ static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { } static char *me_get_peer(grpc_endpoint *ep) { - return gpr_strdup("fake:mock_endpoint"); + passthru_endpoint *p = ((half *)ep)->parent; + return ((half *)ep) == &p->client ? gpr_strdup("fake:mock_client_endpoint") + : gpr_strdup("fake:mock_server_endpoint"); } static int me_get_fd(grpc_endpoint *ep) { return -1; } @@ -185,10 +195,13 @@ static void half_init(half *m, passthru_endpoint *parent, void grpc_passthru_endpoint_create(grpc_endpoint **client, grpc_endpoint **server, - grpc_resource_quota *resource_quota) { + grpc_resource_quota *resource_quota, + grpc_passthru_endpoint_stats *stats) { passthru_endpoint *m = gpr_malloc(sizeof(*m)); m->halves = 2; m->shutdown = 0; + m->stats = stats == NULL ? &m->dummy_stats : stats; + memset(m->stats, 0, sizeof(*m->stats)); half_init(&m->client, m, resource_quota, "client"); half_init(&m->server, m, resource_quota, "server"); gpr_mu_init(&m->mu); diff --git a/test/core/util/passthru_endpoint.h b/test/core/util/passthru_endpoint.h index b81ac5571c..9199925aa0 100644 --- a/test/core/util/passthru_endpoint.h +++ b/test/core/util/passthru_endpoint.h @@ -36,8 +36,11 @@ #include "src/core/lib/iomgr/endpoint.h" +typedef struct { int num_writes; } grpc_passthru_endpoint_stats; + void grpc_passthru_endpoint_create(grpc_endpoint **client, grpc_endpoint **server, - grpc_resource_quota *resource_quota); + grpc_resource_quota *resource_quota, + grpc_passthru_endpoint_stats *stats); #endif diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c index b2342feeb4..6d722ffc88 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); @@ -102,9 +103,11 @@ void grpc_free_port_using_server(char *server, int port) { grpc_resource_quota *resource_quota = 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_timeout_seconds_to_deadline(10), + 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; @@ -112,7 +115,7 @@ void grpc_free_port_using_server(char *server, int port) { "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), &worker, gpr_now(GPR_CLOCK_MONOTONIC), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1)))) { + grpc_timeout_seconds_to_deadline(1)))) { pr.done = 1; } } @@ -149,7 +152,7 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, failed = 1; const char *msg = grpc_error_string(error); gpr_log(GPR_DEBUG, "failed port pick from server: retrying [%s]", msg); - grpc_error_free_string(msg); + } else if (response->status != 200) { failed = 1; gpr_log(GPR_DEBUG, "failed port pick from server: status=%d", @@ -173,10 +176,11 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, grpc_resource_quota *resource_quota = 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_timeout_seconds_to_deadline(10), + 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) { @@ -232,7 +238,7 @@ int grpc_pick_port_using_server(char *server) { "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), &worker, gpr_now(GPR_CLOCK_MONOTONIC), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1)))) { + grpc_timeout_seconds_to_deadline(1)))) { pr.port = 0; } } diff --git a/test/core/util/reconnect_server.c b/test/core/util/reconnect_server.c index 7bf83a74a1..7fbd0ca6aa 100644 --- a/test/core/util/reconnect_server.c +++ b/test/core/util/reconnect_server.c @@ -80,7 +80,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); timestamp_list *new_tail; peer = grpc_endpoint_get_peer(tcp); - grpc_endpoint_shutdown(exec_ctx, tcp); + grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE("Connected")); grpc_endpoint_destroy(exec_ctx, tcp); if (peer) { last_colon = strrchr(peer, ':'); diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index d86ed94637..94aab27253 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -45,8 +45,8 @@ #include "src/core/lib/support/env.h" #include "src/core/lib/support/string.h" -double g_fixture_slowdown_factor = 1.0; -double g_poller_slowdown_factor = 1.0; +int64_t g_fixture_slowdown_factor = 1; +int64_t g_poller_slowdown_factor = 1; #if GPR_GETPID_IN_UNISTD_H #include <unistd.h> @@ -278,19 +278,109 @@ static void install_crash_handler() { static void install_crash_handler() {} #endif +bool BuiltUnderValgrind() { +#ifdef RUNNING_ON_VALGRIND + return true; +#else + return false; +#endif +} + +bool BuiltUnderTsan() { +#if defined(__has_feature) +#if __has_feature(thread_sanitizer) + return true; +#else + return false; +#endif +#else +#ifdef THREAD_SANITIZER + return true; +#else + return false; +#endif +#endif +} + +bool BuiltUnderAsan() { +#if defined(__has_feature) +#if __has_feature(address_sanitizer) + return true; +#else + return false; +#endif +#else +#ifdef ADDRESS_SANITIZER + return true; +#else + return false; +#endif +#endif +} + +bool BuiltUnderMsan() { +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) + return true; +#else + return false; +#endif +#else +#ifdef MEMORY_SANITIZER + return true; +#else + return false; +#endif +#endif +} + +int64_t grpc_test_sanitizer_slowdown_factor() { + int64_t sanitizer_multiplier = 1; + if (BuiltUnderValgrind()) { + sanitizer_multiplier = 20; + } else if (BuiltUnderTsan()) { + sanitizer_multiplier = 5; + } else if (BuiltUnderAsan()) { + sanitizer_multiplier = 3; + } else if (BuiltUnderMsan()) { + sanitizer_multiplier = 4; + } + return sanitizer_multiplier; +} + +int64_t grpc_test_slowdown_factor() { + return grpc_test_sanitizer_slowdown_factor() * g_fixture_slowdown_factor * + g_poller_slowdown_factor; +} + +gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s) { + return gpr_time_add( + gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_millis(grpc_test_slowdown_factor() * (int64_t)1e3 * time_s, + GPR_TIMESPAN)); +} + +gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms) { + return gpr_time_add( + gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_micros(grpc_test_slowdown_factor() * (int64_t)1e3 * time_ms, + GPR_TIMESPAN)); +} + void grpc_test_init(int argc, char **argv) { install_crash_handler(); { /* poll-cv poll strategy runs much more slowly than anything else */ char *s = gpr_getenv("GRPC_POLL_STRATEGY"); if (s != NULL && 0 == strcmp(s, "poll-cv")) { - g_poller_slowdown_factor = 5.0; + g_poller_slowdown_factor = 5; } gpr_free(s); } - gpr_log(GPR_DEBUG, "test slowdown: machine=%f build=%f poll=%f total=%f", - (double)GRPC_TEST_SLOWDOWN_MACHINE_FACTOR, - (double)GRPC_TEST_SLOWDOWN_BUILD_FACTOR, g_poller_slowdown_factor, - (double)GRPC_TEST_SLOWDOWN_FACTOR); + gpr_log(GPR_DEBUG, + "test slowdown factor: sanitizer=%" PRId64 ", fixture=%" PRId64 + ", poller=%" PRId64 ", total=%" PRId64, + grpc_test_sanitizer_slowdown_factor(), g_fixture_slowdown_factor, + g_poller_slowdown_factor, grpc_test_slowdown_factor()); /* seed rng with pid, so we don't end up with the same random numbers as a concurrently running test binary */ srand(seed()); diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index c13fe86a64..491f011fc8 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -40,32 +40,17 @@ extern "C" { #endif /* __cplusplus */ -#ifndef GRPC_TEST_SLOWDOWN_BUILD_FACTOR -#define GRPC_TEST_SLOWDOWN_BUILD_FACTOR 1.0 -#endif - -#ifndef GRPC_TEST_SLOWDOWN_MACHINE_FACTOR -#define GRPC_TEST_SLOWDOWN_MACHINE_FACTOR 1.0 -#endif - -extern double g_fixture_slowdown_factor; -extern double g_poller_slowdown_factor; +extern int64_t g_fixture_slowdown_factor; +extern int64_t g_poller_slowdown_factor; -#define GRPC_TEST_SLOWDOWN_FACTOR \ - (GRPC_TEST_SLOWDOWN_BUILD_FACTOR * GRPC_TEST_SLOWDOWN_MACHINE_FACTOR * \ - g_fixture_slowdown_factor * g_poller_slowdown_factor) +/* Returns an appropriate scaling factor for timeouts. */ +int64_t grpc_test_slowdown_factor(); -#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \ - gpr_time_add( \ - gpr_now(GPR_CLOCK_MONOTONIC), \ - gpr_time_from_millis((int64_t)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ - GPR_TIMESPAN)) +/* Converts a given timeout (in seconds) to a deadline. */ +gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s); -#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \ - gpr_time_add( \ - gpr_now(GPR_CLOCK_MONOTONIC), \ - gpr_time_from_micros((int64_t)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ - GPR_TIMESPAN)) +/* Converts a given timeout (in milliseconds) to a deadline. */ +gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms); #ifndef GRPC_TEST_CUSTOM_PICK_PORT #define GRPC_TEST_PICK_PORT 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 && diff --git a/test/cpp/codegen/codegen_test_full.cc b/test/cpp/codegen/codegen_test_full.cc index d6e2416b55..bc19fc9669 100644 --- a/test/cpp/codegen/codegen_test_full.cc +++ b/test/cpp/codegen/codegen_test_full.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2016, Google Inc. + * Copyright 2017, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/test/cpp/codegen/proto_utils_test.cc b/test/cpp/codegen/proto_utils_test.cc new file mode 100644 index 0000000000..1daa142b50 --- /dev/null +++ b/test/cpp/codegen/proto_utils_test.cc @@ -0,0 +1,93 @@ +/* + * + * 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 <grpc++/impl/codegen/proto_utils.h> +#include <grpc++/impl/grpc_library.h> +#include <gtest/gtest.h> + +namespace grpc { +namespace internal { + +static GrpcLibraryInitializer g_gli_initializer; + +// Provide access to GrpcBufferWriter internals. +class GrpcBufferWriterPeer { + public: + explicit GrpcBufferWriterPeer(internal::GrpcBufferWriter* writer) + : writer_(writer) {} + bool have_backup() const { return writer_->have_backup_; } + const grpc_slice& backup_slice() const { return writer_->backup_slice_; } + const grpc_slice& slice() const { return writer_->slice_; } + + private: + GrpcBufferWriter* writer_; +}; + +class ProtoUtilsTest : public ::testing::Test {}; + +// Regression test for a memory corruption bug where a series of +// GrpcBufferWriter Next()/Backup() invocations could result in a dangling +// pointer returned by Next() due to the interaction between grpc_slice inlining +// and GRPC_SLICE_START_PTR. +TEST_F(ProtoUtilsTest, BackupNext) { + // Ensure the GrpcBufferWriter internals are initialized. + g_gli_initializer.summon(); + + grpc_byte_buffer* bp; + GrpcBufferWriter writer(&bp, 8192); + GrpcBufferWriterPeer peer(&writer); + + void* data; + int size; + // Allocate a slice. + ASSERT_TRUE(writer.Next(&data, &size)); + EXPECT_EQ(8192, size); + // Return a single byte. Before the fix that this test acts as a regression + // for, this would have resulted in an inlined backup slice. + writer.BackUp(1); + EXPECT_TRUE(!peer.have_backup()); + // On the next allocation, the slice is non-inlined. + ASSERT_TRUE(writer.Next(&data, &size)); + EXPECT_TRUE(peer.slice().refcount != NULL); + + // Cleanup. + g_core_codegen_interface->grpc_byte_buffer_destroy(bp); +} + +} // namespace internal +} // namespace grpc + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/cpp/common/alarm_cpp_test.cc b/test/cpp/common/alarm_cpp_test.cc index a05ac30b1c..41085174a4 100644 --- a/test/cpp/common/alarm_cpp_test.cc +++ b/test/cpp/common/alarm_cpp_test.cc @@ -43,12 +43,12 @@ namespace { TEST(AlarmTest, RegularExpiry) { CompletionQueue cq; void* junk = reinterpret_cast<void*>(1618033); - Alarm alarm(&cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), junk); + Alarm alarm(&cq, grpc_timeout_seconds_to_deadline(1), junk); void* output_tag; bool ok; const CompletionQueue::NextStatus status = cq.AsyncNext( - (void**)&output_tag, &ok, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2)); + (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2)); EXPECT_EQ(status, CompletionQueue::GOT_EVENT); EXPECT_TRUE(ok); @@ -65,7 +65,7 @@ TEST(AlarmTest, RegularExpiryChrono) { void* output_tag; bool ok; const CompletionQueue::NextStatus status = cq.AsyncNext( - (void**)&output_tag, &ok, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2)); + (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2)); EXPECT_EQ(status, CompletionQueue::GOT_EVENT); EXPECT_TRUE(ok); @@ -75,12 +75,12 @@ TEST(AlarmTest, RegularExpiryChrono) { TEST(AlarmTest, ZeroExpiry) { CompletionQueue cq; void* junk = reinterpret_cast<void*>(1618033); - Alarm alarm(&cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(0), junk); + Alarm alarm(&cq, grpc_timeout_seconds_to_deadline(0), junk); void* output_tag; bool ok; const CompletionQueue::NextStatus status = cq.AsyncNext( - (void**)&output_tag, &ok, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(0)); + (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(0)); EXPECT_EQ(status, CompletionQueue::GOT_EVENT); EXPECT_TRUE(ok); @@ -90,12 +90,12 @@ TEST(AlarmTest, ZeroExpiry) { TEST(AlarmTest, NegativeExpiry) { CompletionQueue cq; void* junk = reinterpret_cast<void*>(1618033); - Alarm alarm(&cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(-1), junk); + Alarm alarm(&cq, grpc_timeout_seconds_to_deadline(-1), junk); void* output_tag; bool ok; const CompletionQueue::NextStatus status = cq.AsyncNext( - (void**)&output_tag, &ok, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(0)); + (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(0)); EXPECT_EQ(status, CompletionQueue::GOT_EVENT); EXPECT_TRUE(ok); @@ -105,13 +105,13 @@ TEST(AlarmTest, NegativeExpiry) { TEST(AlarmTest, Cancellation) { CompletionQueue cq; void* junk = reinterpret_cast<void*>(1618033); - Alarm alarm(&cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2), junk); + Alarm alarm(&cq, grpc_timeout_seconds_to_deadline(2), junk); alarm.Cancel(); void* output_tag; bool ok; const CompletionQueue::NextStatus status = cq.AsyncNext( - (void**)&output_tag, &ok, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1)); + (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1)); EXPECT_EQ(status, CompletionQueue::GOT_EVENT); EXPECT_FALSE(ok); diff --git a/test/cpp/common/channel_arguments_test.cc b/test/cpp/common/channel_arguments_test.cc index 60d3215265..190d32ce06 100644 --- a/test/cpp/common/channel_arguments_test.cc +++ b/test/cpp/common/channel_arguments_test.cc @@ -37,7 +37,11 @@ #include <grpc/grpc.h> #include <grpc/support/useful.h> #include <gtest/gtest.h> + +extern "C" { +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/socket_mutator.h" +} namespace grpc { namespace testing { @@ -228,7 +232,11 @@ TEST_F(ChannelArgumentsTest, SetSocketMutator) { EXPECT_FALSE(HasArg(arg0)); // arg0 is destroyed by grpc_socket_mutator_to_arg(mutator1) - arg1.value.pointer.vtable->destroy(arg1.value.pointer.p); + { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + arg1.value.pointer.vtable->destroy(&exec_ctx, arg1.value.pointer.p); + grpc_exec_ctx_finish(&exec_ctx); + } } TEST_F(ChannelArgumentsTest, SetUserAgentPrefix) { diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 8e385d100c..32e8a41795 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -42,6 +42,7 @@ #include <grpc++/server_builder.h> #include <grpc++/server_context.h> #include <grpc/grpc.h> +#include <grpc/support/log.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> #include <grpc/support/tls.h> @@ -228,12 +229,7 @@ class TestScenario { : disable_blocking(non_block), credentials_type(creds_type), message_content(content) {} - void Log() const { - gpr_log( - GPR_INFO, - "Scenario: disable_blocking %d, credentials %s, message size %" PRIuPTR, - disable_blocking, credentials_type.c_str(), message_content.size()); - } + void Log() const; bool disable_blocking; // Although the below grpc::string's are logically const, we can't declare // them const because of a limitation in the way old compilers (e.g., gcc-4.4) @@ -242,6 +238,20 @@ class TestScenario { grpc::string message_content; }; +static std::ostream& operator<<(std::ostream& out, + const TestScenario& scenario) { + return out << "TestScenario{disable_blocking=" + << (scenario.disable_blocking ? "true" : "false") + << ", credentials='" << scenario.credentials_type + << "', message_size=" << scenario.message_content.size() << "}"; +} + +void TestScenario::Log() const { + std::ostringstream out; + out << *this; + gpr_log(GPR_DEBUG, "%s", out.str().c_str()); +} + class AsyncEnd2endTest : public ::testing::TestWithParam<TestScenario> { protected: AsyncEnd2endTest() { GetParam().Log(); } @@ -254,7 +264,8 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<TestScenario> { // Setup server ServerBuilder builder; - auto server_creds = GetServerCredentials(GetParam().credentials_type); + auto server_creds = GetCredentialsProvider()->GetServerCredentials( + GetParam().credentials_type); builder.AddListeningPort(server_address_.str(), server_creds); builder.RegisterService(&service_); cq_ = builder.AddCompletionQueue(); @@ -283,8 +294,8 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<TestScenario> { void ResetStub() { ChannelArguments args; - auto channel_creds = - GetChannelCredentials(GetParam().credentials_type, &args); + auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( + GetParam().credentials_type, &args); std::shared_ptr<Channel> channel = CreateCustomChannel(server_address_.str(), channel_creds, args); stub_ = grpc::testing::EchoTestService::NewStub(channel); @@ -892,8 +903,8 @@ TEST_P(AsyncEnd2endTest, ServerCheckDone) { TEST_P(AsyncEnd2endTest, UnimplementedRpc) { ChannelArguments args; - auto channel_creds = - GetChannelCredentials(GetParam().credentials_type, &args); + auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( + GetParam().credentials_type, &args); std::shared_ptr<Channel> channel = CreateCustomChannel(server_address_.str(), channel_creds, args); std::unique_ptr<grpc::testing::UnimplementedEchoService::Stub> stub; @@ -1404,11 +1415,15 @@ std::vector<TestScenario> CreateTestScenarios(bool test_disable_blocking, std::vector<grpc::string> credentials_types; std::vector<grpc::string> messages; - credentials_types.push_back(kInsecureCredentialsType); - auto sec_list = GetSecureCredentialsTypeList(); + if (GetCredentialsProvider()->GetChannelCredentials(kInsecureCredentialsType, + nullptr) != nullptr) { + credentials_types.push_back(kInsecureCredentialsType); + } + auto sec_list = GetCredentialsProvider()->GetSecureCredentialsTypeList(); for (auto sec = sec_list.begin(); sec != sec_list.end(); sec++) { credentials_types.push_back(*sec); } + GPR_ASSERT(!credentials_types.empty()); messages.push_back("Hello"); for (int sz = 1; sz < test_big_limit; sz *= 2) { diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 9bb892c694..47e5c5bd77 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -209,10 +209,7 @@ class TestScenario { public: TestScenario(bool proxy, const grpc::string& creds_type) : use_proxy(proxy), credentials_type(creds_type) {} - void Log() const { - gpr_log(GPR_INFO, "Scenario: proxy %d, credentials %s", use_proxy, - credentials_type.c_str()); - } + void Log() const; bool use_proxy; // Although the below grpc::string is logically const, we can't declare // them const because of a limitation in the way old compilers (e.g., gcc-4.4) @@ -220,6 +217,19 @@ class TestScenario { grpc::string credentials_type; }; +static std::ostream& operator<<(std::ostream& out, + const TestScenario& scenario) { + return out << "TestScenario{use_proxy=" + << (scenario.use_proxy ? "true" : "false") << ", credentials='" + << scenario.credentials_type << "'}"; +} + +void TestScenario::Log() const { + std::ostringstream out; + out << *this; + gpr_log(GPR_DEBUG, "%s", out.str().c_str()); +} + class End2endTest : public ::testing::TestWithParam<TestScenario> { protected: End2endTest() @@ -242,7 +252,8 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> { // Setup server ServerBuilder builder; ConfigureServerBuilder(&builder); - auto server_creds = GetServerCredentials(GetParam().credentials_type); + auto server_creds = GetCredentialsProvider()->GetServerCredentials( + GetParam().credentials_type); if (GetParam().credentials_type != kInsecureCredentialsType) { server_creds->SetAuthMetadataProcessor(processor); } @@ -270,8 +281,8 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> { } EXPECT_TRUE(is_server_started_); ChannelArguments args; - auto channel_creds = - GetChannelCredentials(GetParam().credentials_type, &args); + auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( + GetParam().credentials_type, &args); if (!user_agent_prefix_.empty()) { args.SetUserAgentPrefix(user_agent_prefix_); } @@ -635,7 +646,7 @@ TEST_P(End2endServerTryCancelTest, BidiStreamServerCancelAfter) { TestBidiStreamServerCancel(CANCEL_AFTER_PROCESSING, 5); } -TEST_P(End2endTest, SimpleRpcWithCustomeUserAgentPrefix) { +TEST_P(End2endTest, SimpleRpcWithCustomUserAgentPrefix) { user_agent_prefix_ = "custom_prefix"; ResetStub(); EchoRequest request; @@ -890,6 +901,8 @@ TEST_P(End2endTest, RpcMaxMessageSize) { EchoRequest request; EchoResponse response; request.set_message(string(kMaxMessageSize_ * 2, 'a')); + // cancelled is not guaranteed to appear before the end of the service handler + request.mutable_param()->set_skip_cancelled_check(true); ClientContext context; Status s = stub_->Echo(&context, request, &response); @@ -1292,6 +1305,7 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginAndProcessorFailure) { EXPECT_FALSE(s.ok()); EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED); } + TEST_P(SecureEnd2endTest, SetPerCallCredentials) { ResetStub(); EchoRequest request; @@ -1520,11 +1534,18 @@ std::vector<TestScenario> CreateTestScenarios(bool use_proxy, std::vector<TestScenario> scenarios; std::vector<grpc::string> credentials_types; if (test_secure) { - credentials_types = GetSecureCredentialsTypeList(); + credentials_types = + GetCredentialsProvider()->GetSecureCredentialsTypeList(); } if (test_insecure) { - credentials_types.push_back(kInsecureCredentialsType); + // Only add insecure credentials type when it is registered with the + // provider. User may create providers that do not have insecure. + if (GetCredentialsProvider()->GetChannelCredentials( + kInsecureCredentialsType, nullptr) != nullptr) { + credentials_types.push_back(kInsecureCredentialsType); + } } + GPR_ASSERT(!credentials_types.empty()); for (auto it = credentials_types.begin(); it != credentials_types.end(); ++it) { scenarios.emplace_back(false, *it); @@ -1541,7 +1562,7 @@ INSTANTIATE_TEST_CASE_P(End2end, End2endTest, INSTANTIATE_TEST_CASE_P(End2endServerTryCancel, End2endServerTryCancelTest, ::testing::ValuesIn(CreateTestScenarios(false, true, - false))); + true))); INSTANTIATE_TEST_CASE_P(ProxyEnd2end, ProxyEnd2endTest, ::testing::ValuesIn(CreateTestScenarios(true, true, diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc index 5b52b1fc1a..bd68e851d3 100644 --- a/test/cpp/end2end/shutdown_test.cc +++ b/test/cpp/end2end/shutdown_test.cc @@ -49,6 +49,7 @@ #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" +#include "test/cpp/util/test_credentials_provider.h" using grpc::testing::EchoRequest; using grpc::testing::EchoResponse; @@ -72,7 +73,7 @@ class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { gpr_event* ev_; }; -class ShutdownTest : public ::testing::Test { +class ShutdownTest : public ::testing::TestWithParam<string> { public: ShutdownTest() : shutdown_(false), service_(&ev_) { gpr_event_init(&ev_); } @@ -85,7 +86,9 @@ class ShutdownTest : public ::testing::Test { grpc::string server_address = "localhost:" + to_string(port); ServerBuilder builder; - builder.AddListeningPort(server_address, InsecureServerCredentials()); + auto server_creds = + GetCredentialsProvider()->GetServerCredentials(GetParam()); + builder.AddListeningPort(server_address, server_creds); builder.RegisterService(&service_); std::unique_ptr<Server> server = builder.BuildAndStart(); return server; @@ -95,7 +98,10 @@ class ShutdownTest : public ::testing::Test { void ResetStub() { string target = "dns:localhost:" + to_string(port_); - channel_ = CreateChannel(target, InsecureChannelCredentials()); + ChannelArguments args; + auto channel_creds = + GetCredentialsProvider()->GetChannelCredentials(GetParam(), &args); + channel_ = CreateCustomChannel(target, channel_creds, args); stub_ = grpc::testing::EchoTestService::NewStub(channel_); } @@ -125,8 +131,31 @@ class ShutdownTest : public ::testing::Test { TestServiceImpl service_; }; +std::vector<string> GetAllCredentialsTypeList() { + std::vector<grpc::string> credentials_types; + if (GetCredentialsProvider()->GetChannelCredentials(kInsecureCredentialsType, + nullptr) != nullptr) { + credentials_types.push_back(kInsecureCredentialsType); + } + auto sec_list = GetCredentialsProvider()->GetSecureCredentialsTypeList(); + for (auto sec = sec_list.begin(); sec != sec_list.end(); sec++) { + credentials_types.push_back(*sec); + } + GPR_ASSERT(!credentials_types.empty()); + + std::string credentials_type_list("credentials types:"); + for (const string& type : credentials_types) { + credentials_type_list.append(" " + type); + } + gpr_log(GPR_INFO, "%s", credentials_type_list.c_str()); + return credentials_types; +} + +INSTANTIATE_TEST_CASE_P(End2EndShutdown, ShutdownTest, + ::testing::ValuesIn(GetAllCredentialsTypeList())); + // TODO(ctiller): leaked objects in this test -TEST_F(ShutdownTest, ShutdownTest) { +TEST_P(ShutdownTest, ShutdownTest) { ResetStub(); // send the request in a background thread diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc index 191d729a9e..82ccf436f8 100644 --- a/test/cpp/grpclb/grpclb_api_test.cc +++ b/test/cpp/grpclb/grpclb_api_test.cc @@ -63,7 +63,7 @@ grpc::string PackedStringToIp(const grpc_grpclb_ip_address& pb_ip) { } else { abort(); } - GPR_ASSERT(inet_ntop(af, pb_ip.bytes, ip_str, 46) != NULL); + GPR_ASSERT(inet_ntop(af, (void*)pb_ip.bytes, ip_str, 46) != NULL); return ip_str; } diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index de304b9f89..89ed9249ad 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -52,8 +52,10 @@ #include <grpc++/impl/codegen/config.h> extern "C" { #include "src/core/ext/client_channel/client_channel.h" +#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/iomgr/sockaddr.h" +#include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "src/core/lib/support/string.h" #include "src/core/lib/support/tmpfile.h" #include "src/core/lib/surface/channel.h" @@ -110,6 +112,7 @@ typedef struct server_fixture { grpc_call *server_call; grpc_completion_queue *cq; char *servers_hostport; + const char *balancer_name; int port; const char *lb_token_prefix; gpr_thd_id tid; @@ -170,7 +173,7 @@ static grpc_slice build_response_payload_slice( static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; do { - ev = grpc_completion_queue_next(cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), + ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } @@ -201,10 +204,12 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports, &request_metadata_recv, sf->cq, sf->cq, tag(200)); GPR_ASSERT(GRPC_CALL_OK == error); - gpr_log(GPR_INFO, "LB Server[%s] up", sf->servers_hostport); + gpr_log(GPR_INFO, "LB Server[%s](%s) up", sf->servers_hostport, + sf->balancer_name); CQ_EXPECT_COMPLETION(cqv, tag(200), 1); cq_verify(cqv); - gpr_log(GPR_INFO, "LB Server[%s] after tag 200", sf->servers_hostport); + gpr_log(GPR_INFO, "LB Server[%s](%s) after tag 200", sf->servers_hostport, + sf->balancer_name); // make sure we've received the initial metadata from the grpclb request. GPR_ASSERT(request_metadata_recv.count > 0); @@ -213,7 +218,7 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports, // receive request for backends op = ops; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -221,7 +226,8 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports, GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(202), 1); cq_verify(cqv); - gpr_log(GPR_INFO, "LB Server[%s] after RECV_MSG", sf->servers_hostport); + gpr_log(GPR_INFO, "LB Server[%s](%s) after RECV_MSG", sf->servers_hostport, + sf->balancer_name); // validate initial request. grpc_byte_buffer_reader bbr; @@ -250,7 +256,8 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports, op++; error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(201), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - gpr_log(GPR_INFO, "LB Server[%s] after tag 201", sf->servers_hostport); + gpr_log(GPR_INFO, "LB Server[%s](%s) after tag 201", sf->servers_hostport, + sf->balancer_name); for (int i = 0; i < 2; i++) { if (i == 0) { @@ -268,7 +275,7 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports, response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); op = ops; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; op->flags = 0; op->reserved = NULL; op++; @@ -276,19 +283,21 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports, GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(203), 1); cq_verify(cqv); - gpr_log(GPR_INFO, "LB Server[%s] after SEND_MESSAGE, iter %d", - sf->servers_hostport, i); + gpr_log(GPR_INFO, "LB Server[%s](%s) after SEND_MESSAGE, iter %d", + sf->servers_hostport, sf->balancer_name, i); grpc_byte_buffer_destroy(response_payload); grpc_slice_unref(response_payload_slice); } - gpr_log(GPR_INFO, "LB Server[%s] shutting down", sf->servers_hostport); + gpr_log(GPR_INFO, "LB Server[%s](%s) shutting down", sf->servers_hostport, + sf->balancer_name); op = ops; 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"; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -298,8 +307,8 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports, CQ_EXPECT_COMPLETION(cqv, tag(201), 1); CQ_EXPECT_COMPLETION(cqv, tag(204), 1); cq_verify(cqv); - gpr_log(GPR_INFO, "LB Server[%s] after tag 204. All done. LB server out", - sf->servers_hostport); + gpr_log(GPR_INFO, "LB Server[%s](%s) after tag 204. All done. LB server out", + sf->servers_hostport, sf->balancer_name); grpc_call_destroy(s); @@ -335,7 +344,7 @@ static void start_backend_server(server_fixture *sf) { GPR_ASSERT(GRPC_CALL_OK == error); gpr_log(GPR_INFO, "Server[%s] up", sf->servers_hostport); ev = grpc_completion_queue_next(sf->cq, - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(60), NULL); + grpc_timeout_seconds_to_deadline(60), NULL); if (!ev.success) { gpr_log(GPR_INFO, "Server[%s] being torn down", sf->servers_hostport); cq_verifier_destroy(cqv); @@ -372,14 +381,14 @@ static void start_backend_server(server_fixture *sf) { while (!exit) { op = ops; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; op->reserved = NULL; op++; error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); GPR_ASSERT(GRPC_CALL_OK == error); ev = grpc_completion_queue_next( - sf->cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), NULL); + sf->cq, grpc_timeout_seconds_to_deadline(3), NULL); if (ev.type == GRPC_OP_COMPLETE && ev.success) { GPR_ASSERT(ev.tag = tag(102)); if (request_payload_recv == NULL) { @@ -401,7 +410,7 @@ static void start_backend_server(server_fixture *sf) { grpc_raw_byte_buffer_create(&response_payload_slice, 1); op = ops; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; + op->data.send_message.send_message = response_payload; op->flags = 0; op->reserved = NULL; op++; @@ -409,7 +418,7 @@ static void start_backend_server(server_fixture *sf) { grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); ev = grpc_completion_queue_next( - sf->cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), NULL); + sf->cq, grpc_timeout_seconds_to_deadline(3), NULL); if (ev.type == GRPC_OP_COMPLETE && ev.success) { GPR_ASSERT(ev.tag = tag(103)); } else { @@ -433,7 +442,9 @@ static void start_backend_server(server_fixture *sf) { 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 = "Backend server out a-ok"; + grpc_slice status_details = + grpc_slice_from_static_string("Backend server out a-ok"); + op->data.send_status_from_server.status_details = &status_details; op->flags = 0; op->reserved = NULL; op++; @@ -462,8 +473,7 @@ static void perform_request(client_fixture *cf) { grpc_metadata_array trailing_metadata_recv; grpc_status_code status; grpc_call_error error; - char *details = NULL; - size_t details_capacity = 0; + grpc_slice details; grpc_byte_buffer *request_payload; grpc_byte_buffer *response_payload_recv; int i; @@ -472,9 +482,11 @@ static void perform_request(client_fixture *cf) { grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr:1234"); c = grpc_channel_create_call(cf->client, NULL, GRPC_PROPAGATE_DEFAULTS, - cf->cq, "/foo", "foo.test.google.fr:1234", - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL); + cf->cq, grpc_slice_from_static_string("/foo"), + &host, grpc_timeout_seconds_to_deadline(5), + NULL); gpr_log(GPR_INFO, "Call 0x%" PRIxPTR " created", (intptr_t)c); GPR_ASSERT(c); char *peer; @@ -489,7 +501,7 @@ static void perform_request(client_fixture *cf) { op->reserved = NULL; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; @@ -497,7 +509,6 @@ static void perform_request(client_fixture *cf) { 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++; @@ -509,12 +520,12 @@ static void perform_request(client_fixture *cf) { op = ops; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; + op->data.send_message.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; + op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; op->reserved = NULL; op++; @@ -553,15 +564,43 @@ static void perform_request(client_fixture *cf) { grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); - gpr_free(details); + grpc_slice_unref(details); gpr_log(GPR_INFO, "Client call (peer %s) DESTROYED.", peer); gpr_free(peer); } -static void setup_client(const char *server_hostport, client_fixture *cf) { +#define BALANCERS_NAME "lb.name" +static void setup_client(const server_fixture *lb_server, + const server_fixture *backends, client_fixture *cf) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + char *lb_uri; + // The grpclb LB policy will be automatically selected by virtue of + // the fact that the returned addresses are balancer addresses. + gpr_asprintf(&lb_uri, "test:///%s?lb_enabled=1&balancer_names=%s", + lb_server->servers_hostport, lb_server->balancer_name); + + grpc_arg expected_target_arg; + expected_target_arg.type = GRPC_ARG_STRING; + expected_target_arg.key = + const_cast<char *>(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS); + + char *expected_target_names = NULL; + const char *backends_name = lb_server->servers_hostport; + gpr_asprintf(&expected_target_names, "%s;%s", backends_name, BALANCERS_NAME); + + expected_target_arg.value.string = const_cast<char *>(expected_target_names); + grpc_channel_args *args = + grpc_channel_args_copy_and_add(NULL, &expected_target_arg, 1); + gpr_free(expected_target_names); + cf->cq = grpc_completion_queue_create(NULL); - cf->server_uri = gpr_strdup(server_hostport); - cf->client = grpc_insecure_channel_create(cf->server_uri, NULL, NULL); + cf->server_uri = lb_uri; + grpc_channel_credentials *fake_creds = + grpc_fake_transport_security_credentials_create(); + cf->client = + grpc_secure_channel_create(fake_creds, cf->server_uri, args, NULL); + grpc_channel_credentials_unref(&exec_ctx, fake_creds); + grpc_channel_args_destroy(&exec_ctx, args); } static void teardown_client(client_fixture *cf) { @@ -588,10 +627,14 @@ static void setup_server(const char *host, server_fixture *sf) { gpr_join_host_port(&sf->servers_hostport, host, sf->port); } + grpc_server_credentials *server_creds = + grpc_fake_transport_security_server_credentials_create(); + sf->server = grpc_server_create(NULL, NULL); grpc_server_register_completion_queue(sf->server, sf->cq, NULL); - GPR_ASSERT((assigned_port = grpc_server_add_insecure_http2_port( - sf->server, sf->servers_hostport)) > 0); + GPR_ASSERT((assigned_port = grpc_server_add_secure_http2_port( + sf->server, sf->servers_hostport, server_creds)) > 0); + grpc_server_credentials_release(server_creds); GPR_ASSERT(sf->port == assigned_port); grpc_server_start(sf->server); } @@ -602,7 +645,7 @@ static void teardown_server(server_fixture *sf) { gpr_log(GPR_INFO, "Server[%s] shutting down", sf->servers_hostport); grpc_server_shutdown_and_notify(sf->server, sf->cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck( - sf->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + sf->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(sf->server); gpr_thd_join(sf->tid); @@ -653,17 +696,10 @@ static test_fixture setup_test_fixture(int lb_server_update_delay_ms) { } tf.lb_server.lb_token_prefix = LB_TOKEN_PREFIX; + tf.lb_server.balancer_name = BALANCERS_NAME; setup_server("127.0.0.1", &tf.lb_server); gpr_thd_new(&tf.lb_server.tid, fork_lb_server, &tf.lb_server, &options); - - char *server_uri; - // The grpclb LB policy will be automatically selected by virtue of - // the fact that the returned addresses are balancer addresses. - gpr_asprintf(&server_uri, "test:///%s?lb_enabled=1", - tf.lb_server.servers_hostport); - setup_client(server_uri, &tf.client); - gpr_free(server_uri); - + setup_client(&tf.lb_server, tf.lb_backends, &tf.client); return tf; } @@ -708,8 +744,9 @@ TEST(GrpclbTest, Updates) { // batch 1. All subsequent picks will come from the second half of the // backends, those coming in the LB update. tf_result = grpc::test_update(800); - GPR_ASSERT(tf_result.lb_backends[0].num_calls_serviced == 1); - GPR_ASSERT(tf_result.lb_backends[1].num_calls_serviced == 0); + GPR_ASSERT(tf_result.lb_backends[0].num_calls_serviced + + tf_result.lb_backends[1].num_calls_serviced == + 1); GPR_ASSERT(tf_result.lb_backends[2].num_calls_serviced + tf_result.lb_backends[3].num_calls_serviced > 0); @@ -725,8 +762,9 @@ TEST(GrpclbTest, Updates) { // update. In any case, the total number of serviced calls must again be equal // to four across all the backends. tf_result = grpc::test_update(2500); - GPR_ASSERT(tf_result.lb_backends[0].num_calls_serviced >= 1); - GPR_ASSERT(tf_result.lb_backends[1].num_calls_serviced == 1); + GPR_ASSERT(tf_result.lb_backends[0].num_calls_serviced + + tf_result.lb_backends[1].num_calls_serviced >= + 2); GPR_ASSERT(tf_result.lb_backends[2].num_calls_serviced + tf_result.lb_backends[3].num_calls_serviced > 0); diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index c58910abc3..8a00b61cef 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -32,8 +32,7 @@ */ #include <memory> - -#include <unistd.h> +#include <unordered_map> #include <gflags/gflags.h> #include <grpc++/channel.h> @@ -49,6 +48,7 @@ #include "test/cpp/util/test_config.h" DEFINE_bool(use_tls, false, "Whether to use tls."); +DEFINE_string(custom_credentials_type, "", "User provided credentials type."); DEFINE_bool(use_test_ca, false, "False to use SSL roots for google"); DEFINE_int32(server_port, 0, "Server port."); DEFINE_string(server_host, "127.0.0.1", "Server host to connect to"); @@ -107,119 +107,78 @@ int main(int argc, char** argv) { grpc::testing::InteropClient client(CreateChannelForTestCase(FLAGS_test_case), true, FLAGS_do_not_abort_on_transient_failures); - if (FLAGS_test_case == "empty_unary") { - client.DoEmpty(); - } else if (FLAGS_test_case == "large_unary") { - client.DoLargeUnary(); - } else if (FLAGS_test_case == "server_compressed_unary") { - client.DoServerCompressedUnary(); - } else if (FLAGS_test_case == "client_compressed_unary") { - client.DoClientCompressedUnary(); - } else if (FLAGS_test_case == "client_streaming") { - client.DoRequestStreaming(); - } else if (FLAGS_test_case == "server_streaming") { - client.DoResponseStreaming(); - } else if (FLAGS_test_case == "server_compressed_streaming") { - client.DoServerCompressedStreaming(); - } else if (FLAGS_test_case == "client_compressed_streaming") { - client.DoClientCompressedStreaming(); - } else if (FLAGS_test_case == "slow_consumer") { - client.DoResponseStreamingWithSlowConsumer(); - } else if (FLAGS_test_case == "half_duplex") { - client.DoHalfDuplex(); - } else if (FLAGS_test_case == "ping_pong") { - client.DoPingPong(); - } else if (FLAGS_test_case == "cancel_after_begin") { - client.DoCancelAfterBegin(); - } else if (FLAGS_test_case == "cancel_after_first_response") { - client.DoCancelAfterFirstResponse(); - } else if (FLAGS_test_case == "timeout_on_sleeping_server") { - client.DoTimeoutOnSleepingServer(); - } else if (FLAGS_test_case == "empty_stream") { - client.DoEmptyStream(); - } else if (FLAGS_test_case == "compute_engine_creds") { - client.DoComputeEngineCreds(FLAGS_default_service_account, - FLAGS_oauth_scope); - } else if (FLAGS_test_case == "jwt_token_creds") { - grpc::string json_key = GetServiceAccountJsonKey(); - client.DoJwtTokenCreds(json_key); - } else if (FLAGS_test_case == "oauth2_auth_token") { - client.DoOauth2AuthToken(FLAGS_default_service_account, FLAGS_oauth_scope); - } else if (FLAGS_test_case == "per_rpc_creds") { - grpc::string json_key = GetServiceAccountJsonKey(); - client.DoPerRpcCreds(json_key); - } else if (FLAGS_test_case == "status_code_and_message") { - client.DoStatusWithMessage(); - } else if (FLAGS_test_case == "custom_metadata") { - client.DoCustomMetadata(); - } else if (FLAGS_test_case == "unimplemented_method") { - client.DoUnimplementedMethod(); - } else if (FLAGS_test_case == "unimplemented_service") { - client.DoUnimplementedService(); - } else if (FLAGS_test_case == "cacheable_unary") { - client.DoCacheableUnary(); - } else if (FLAGS_test_case == "all") { - client.DoEmpty(); - client.DoLargeUnary(); - client.DoClientCompressedUnary(); - client.DoServerCompressedUnary(); - client.DoRequestStreaming(); - client.DoResponseStreaming(); - client.DoClientCompressedStreaming(); - client.DoServerCompressedStreaming(); - client.DoHalfDuplex(); - client.DoPingPong(); - client.DoCancelAfterBegin(); - client.DoCancelAfterFirstResponse(); - client.DoTimeoutOnSleepingServer(); - client.DoEmptyStream(); - client.DoStatusWithMessage(); - client.DoCustomMetadata(); - client.DoUnimplementedMethod(); - client.DoUnimplementedService(); - client.DoCacheableUnary(); - // service_account_creds and jwt_token_creds can only run with ssl. - if (FLAGS_use_tls) { - grpc::string json_key = GetServiceAccountJsonKey(); - client.DoJwtTokenCreds(json_key); - client.DoOauth2AuthToken(FLAGS_default_service_account, - FLAGS_oauth_scope); - client.DoPerRpcCreds(json_key); + + std::unordered_map<grpc::string, std::function<bool()>> actions; + actions["empty_unary"] = + std::bind(&grpc::testing::InteropClient::DoEmpty, &client); + actions["large_unary"] = + std::bind(&grpc::testing::InteropClient::DoLargeUnary, &client); + actions["server_compressed_unary"] = std::bind( + &grpc::testing::InteropClient::DoServerCompressedUnary, &client); + actions["client_compressed_unary"] = std::bind( + &grpc::testing::InteropClient::DoClientCompressedUnary, &client); + actions["client_streaming"] = + std::bind(&grpc::testing::InteropClient::DoRequestStreaming, &client); + actions["server_streaming"] = + std::bind(&grpc::testing::InteropClient::DoResponseStreaming, &client); + actions["server_compressed_streaming"] = std::bind( + &grpc::testing::InteropClient::DoServerCompressedStreaming, &client); + actions["client_compressed_streaming"] = std::bind( + &grpc::testing::InteropClient::DoClientCompressedStreaming, &client); + actions["slow_consumer"] = std::bind( + &grpc::testing::InteropClient::DoResponseStreamingWithSlowConsumer, + &client); + actions["half_duplex"] = + std::bind(&grpc::testing::InteropClient::DoHalfDuplex, &client); + actions["ping_pong"] = + std::bind(&grpc::testing::InteropClient::DoPingPong, &client); + actions["cancel_after_begin"] = + std::bind(&grpc::testing::InteropClient::DoCancelAfterBegin, &client); + actions["cancel_after_first_response"] = std::bind( + &grpc::testing::InteropClient::DoCancelAfterFirstResponse, &client); + actions["timeout_on_sleeping_server"] = std::bind( + &grpc::testing::InteropClient::DoTimeoutOnSleepingServer, &client); + actions["empty_stream"] = + std::bind(&grpc::testing::InteropClient::DoEmptyStream, &client); + if (FLAGS_use_tls) { + actions["compute_engine_creds"] = + std::bind(&grpc::testing::InteropClient::DoComputeEngineCreds, &client, + FLAGS_default_service_account, FLAGS_oauth_scope); + actions["jwt_token_creds"] = + std::bind(&grpc::testing::InteropClient::DoJwtTokenCreds, &client, + GetServiceAccountJsonKey()); + actions["oauth2_auth_token"] = + std::bind(&grpc::testing::InteropClient::DoOauth2AuthToken, &client, + FLAGS_default_service_account, FLAGS_oauth_scope); + actions["per_rpc_creds"] = + std::bind(&grpc::testing::InteropClient::DoPerRpcCreds, &client, + GetServiceAccountJsonKey()); + } + actions["status_code_and_message"] = + std::bind(&grpc::testing::InteropClient::DoStatusWithMessage, &client); + actions["custom_metadata"] = + std::bind(&grpc::testing::InteropClient::DoCustomMetadata, &client); + actions["unimplemented_method"] = + std::bind(&grpc::testing::InteropClient::DoUnimplementedMethod, &client); + actions["unimplemented_service"] = + std::bind(&grpc::testing::InteropClient::DoUnimplementedService, &client); + // actions["cacheable_unary"] = + // std::bind(&grpc::testing::InteropClient::DoCacheableUnary, &client); + + if (FLAGS_test_case == "all") { + for (const auto& action : actions) { + action.second(); } - // compute_engine_creds only runs in GCE. + } else if (actions.find(FLAGS_test_case) != actions.end()) { + actions.find(FLAGS_test_case)->second(); } else { - const char* testcases[] = {"all", - "cacheable_unary", - "cancel_after_begin", - "cancel_after_first_response", - "client_compressed_streaming", - "client_compressed_unary", - "client_streaming", - "compute_engine_creds", - "custom_metadata", - "empty_stream", - "empty_unary", - "half_duplex", - "jwt_token_creds", - "large_unary", - "oauth2_auth_token", - "oauth2_auth_token", - "per_rpc_creds", - "per_rpc_creds", - "ping_pong", - "server_compressed_streaming", - "server_compressed_unary", - "server_streaming", - "status_code_and_message", - "timeout_on_sleeping_server", - "unimplemented_method", - "unimplemented_service"}; - char* joined_testcases = - gpr_strjoin_sep(testcases, GPR_ARRAY_SIZE(testcases), "\n", NULL); - + grpc::string test_cases; + for (const auto& action : actions) { + if (!test_cases.empty()) test_cases += "\n"; + test_cases += action.first; + } gpr_log(GPR_ERROR, "Unsupported test case %s. Valid options are\n%s", - FLAGS_test_case.c_str(), joined_testcases); - gpr_free(joined_testcases); + FLAGS_test_case.c_str(), test_cases.c_str()); ret = 1; } diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index c171969e14..d3192ad0c9 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -33,8 +33,6 @@ #include "test/cpp/interop/client_helper.h" -#include <unistd.h> - #include <fstream> #include <memory> #include <sstream> @@ -50,8 +48,10 @@ #include "src/cpp/client/secure_credentials.h" #include "test/core/security/oauth2_utils.h" #include "test/cpp/util/create_test_channel.h" +#include "test/cpp/util/test_credentials_provider.h" DECLARE_bool(use_tls); +DECLARE_string(custom_credentials_type); DECLARE_bool(use_test_ca); DECLARE_int32(server_port); DECLARE_string(server_host); @@ -114,8 +114,12 @@ std::shared_ptr<Channel> CreateChannelForTestCase( creds = AccessTokenCredentials(raw_token); GPR_ASSERT(creds); } - return CreateTestChannel(host_port, FLAGS_server_host_override, FLAGS_use_tls, - !FLAGS_use_test_ca, creds); + if (FLAGS_custom_credentials_type.empty()) { + return CreateTestChannel(host_port, FLAGS_server_host_override, + FLAGS_use_tls, !FLAGS_use_test_ca, creds); + } else { + return CreateTestChannel(host_port, FLAGS_custom_credentials_type, creds); + } } } // namespace testing diff --git a/test/cpp/interop/http2_client.cc b/test/cpp/interop/http2_client.cc new file mode 100644 index 0000000000..38aee43b26 --- /dev/null +++ b/test/cpp/interop/http2_client.cc @@ -0,0 +1,272 @@ +/* + * + * 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 <thread> + +#include <gflags/gflags.h> +#include <grpc++/channel.h> +#include <grpc++/client_context.h> +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/useful.h> + +#include "src/core/lib/transport/byte_stream.h" +#include "src/proto/grpc/testing/messages.grpc.pb.h" +#include "src/proto/grpc/testing/test.grpc.pb.h" +#include "test/cpp/interop/http2_client.h" + +#include "src/core/lib/support/string.h" +#include "test/cpp/util/create_test_channel.h" +#include "test/cpp/util/test_config.h" + +namespace grpc { +namespace testing { + +namespace { +const int kLargeRequestSize = 271828; +const int kLargeResponseSize = 314159; +} // namespace + +Http2Client::ServiceStub::ServiceStub(std::shared_ptr<Channel> channel) + : channel_(channel) { + stub_ = TestService::NewStub(channel); +} + +TestService::Stub* Http2Client::ServiceStub::Get() { return stub_.get(); } + +Http2Client::Http2Client(std::shared_ptr<Channel> channel) + : serviceStub_(channel), channel_(channel) {} + +bool Http2Client::AssertStatusCode(const Status& s, StatusCode expected_code) { + if (s.error_code() == expected_code) { + return true; + } + + gpr_log(GPR_ERROR, "Error status code: %d (expected: %d), message: %s", + s.error_code(), expected_code, s.error_message().c_str()); + abort(); +} + +bool Http2Client::DoRstAfterHeader() { + gpr_log(GPR_DEBUG, "Sending RPC and expecting reset stream after header"); + + ClientContext context; + SimpleRequest request; + SimpleResponse response; + request.set_response_size(kLargeResponseSize); + grpc::string payload(kLargeRequestSize, '\0'); + request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); + + Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); + AssertStatusCode(s, grpc::StatusCode::UNKNOWN); + GPR_ASSERT(!response.has_payload()); // no data should be received + + gpr_log(GPR_DEBUG, "Done testing reset stream after header"); + return true; +} + +bool Http2Client::DoRstAfterData() { + gpr_log(GPR_DEBUG, "Sending RPC and expecting reset stream after data"); + + ClientContext context; + SimpleRequest request; + SimpleResponse response; + request.set_response_size(kLargeResponseSize); + grpc::string payload(kLargeRequestSize, '\0'); + request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); + + Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); + AssertStatusCode(s, grpc::StatusCode::UNKNOWN); + GPR_ASSERT(response.has_payload()); // data should be received + + gpr_log(GPR_DEBUG, "Done testing reset stream after data"); + return true; +} + +bool Http2Client::DoRstDuringData() { + gpr_log(GPR_DEBUG, "Sending RPC and expecting reset stream during data"); + + ClientContext context; + SimpleRequest request; + SimpleResponse response; + request.set_response_size(kLargeResponseSize); + grpc::string payload(kLargeRequestSize, '\0'); + request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); + + Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); + AssertStatusCode(s, grpc::StatusCode::UNKNOWN); + GPR_ASSERT(!response.has_payload()); // no data should be received + + gpr_log(GPR_DEBUG, "Done testing reset stream during data"); + return true; +} + +bool Http2Client::DoGoaway() { + gpr_log(GPR_DEBUG, "Sending two RPCs and expecting goaway"); + + int numCalls = 2; + for (int i = 0; i < numCalls; i++) { + ClientContext context; + SimpleRequest request; + SimpleResponse response; + request.set_response_size(kLargeResponseSize); + grpc::string payload(kLargeRequestSize, '\0'); + request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); + + Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); + AssertStatusCode(s, grpc::StatusCode::OK); + GPR_ASSERT(response.payload().body() == + grpc::string(kLargeResponseSize, '\0')); + } + + gpr_log(GPR_DEBUG, "Done testing goaway"); + return true; +} + +bool Http2Client::DoPing() { + gpr_log(GPR_DEBUG, "Sending RPC and expecting ping"); + + ClientContext context; + SimpleRequest request; + SimpleResponse response; + request.set_response_size(kLargeResponseSize); + grpc::string payload(kLargeRequestSize, '\0'); + request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); + + Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); + AssertStatusCode(s, grpc::StatusCode::OK); + GPR_ASSERT(response.payload().body() == + grpc::string(kLargeResponseSize, '\0')); + + gpr_log(GPR_DEBUG, "Done testing ping"); + return true; +} + +void Http2Client::MaxStreamsWorker(std::shared_ptr<grpc::Channel> channel) { + ClientContext context; + SimpleRequest request; + SimpleResponse response; + request.set_response_size(kLargeResponseSize); + grpc::string payload(kLargeRequestSize, '\0'); + request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); + + Status s = + TestService::NewStub(channel)->UnaryCall(&context, request, &response); + AssertStatusCode(s, grpc::StatusCode::OK); + GPR_ASSERT(response.payload().body() == + grpc::string(kLargeResponseSize, '\0')); +} + +bool Http2Client::DoMaxStreams() { + gpr_log(GPR_DEBUG, "Testing max streams"); + + // Make an initial call on the channel to ensure the server's max streams + // setting is received + ClientContext context; + SimpleRequest request; + SimpleResponse response; + request.set_response_size(kLargeResponseSize); + grpc::string payload(kLargeRequestSize, '\0'); + request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); + Status s = + TestService::NewStub(channel_)->UnaryCall(&context, request, &response); + AssertStatusCode(s, grpc::StatusCode::OK); + GPR_ASSERT(response.payload().body() == + grpc::string(kLargeResponseSize, '\0')); + + std::vector<std::thread> test_threads; + + for (int i = 0; i < 10; i++) { + test_threads.emplace_back( + std::thread(&Http2Client::MaxStreamsWorker, this, channel_)); + } + + for (auto it = test_threads.begin(); it != test_threads.end(); it++) { + it->join(); + } + + gpr_log(GPR_DEBUG, "Done testing max streams"); + return true; +} + +} // namespace testing +} // namespace grpc + +DEFINE_int32(server_port, 0, "Server port."); +DEFINE_string(server_host, "127.0.0.1", "Server host to connect to"); +DEFINE_string(test_case, "rst_after_header", + "Configure different test cases. Valid options are:\n\n" + "goaway\n" + "max_streams\n" + "ping\n" + "rst_after_data\n" + "rst_after_header\n" + "rst_during_data\n"); + +int main(int argc, char** argv) { + grpc::testing::InitTest(&argc, &argv, true); + GPR_ASSERT(FLAGS_server_port); + const int host_port_buf_size = 1024; + char host_port[host_port_buf_size]; + snprintf(host_port, host_port_buf_size, "%s:%d", FLAGS_server_host.c_str(), + FLAGS_server_port); + grpc::testing::Http2Client client(grpc::CreateTestChannel(host_port, false)); + gpr_log(GPR_INFO, "Testing case: %s", FLAGS_test_case.c_str()); + int ret = 0; + if (FLAGS_test_case == "rst_after_header") { + client.DoRstAfterHeader(); + } else if (FLAGS_test_case == "rst_after_data") { + client.DoRstAfterData(); + } else if (FLAGS_test_case == "rst_during_data") { + client.DoRstDuringData(); + } else if (FLAGS_test_case == "goaway") { + client.DoGoaway(); + } else if (FLAGS_test_case == "ping") { + client.DoPing(); + } else if (FLAGS_test_case == "max_streams") { + client.DoMaxStreams(); + } else { + const char* testcases[] = { + "goaway", "max_streams", "ping", + "rst_after_data", "rst_after_header", "rst_during_data"}; + char* joined_testcases = + gpr_strjoin_sep(testcases, GPR_ARRAY_SIZE(testcases), "\n", NULL); + + gpr_log(GPR_ERROR, "Unsupported test case %s. Valid options are\n%s", + FLAGS_test_case.c_str(), joined_testcases); + gpr_free(joined_testcases); + ret = 1; + } + + return ret; +} diff --git a/test/cpp/qps/limit_cores.cc b/test/cpp/interop/http2_client.h index b5c222542b..6a315f5abb 100644 --- a/test/cpp/qps/limit_cores.cc +++ b/test/cpp/interop/http2_client.h @@ -31,57 +31,50 @@ * */ -#include "test/cpp/qps/limit_cores.h" +#ifndef GRPC_TEST_CPP_INTEROP_HTTP2_CLIENT_H +#define GRPC_TEST_CPP_INTEROP_HTTP2_CLIENT_H -#include <grpc/support/cpu.h> -#include <grpc/support/log.h> -#include <grpc/support/port_platform.h> +#include <memory> -#ifdef GPR_CPU_LINUX -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include <sched.h> +#include <grpc++/channel.h> +#include <grpc/grpc.h> +#include "src/proto/grpc/testing/messages.grpc.pb.h" +#include "src/proto/grpc/testing/test.grpc.pb.h" namespace grpc { namespace testing { -int LimitCores(const int* cores, int cores_size) { - const int num_cores = gpr_cpu_num_cores(); - int cores_set = 0; +class Http2Client { + public: + explicit Http2Client(std::shared_ptr<Channel> channel); + ~Http2Client() {} - cpu_set_t* cpup = CPU_ALLOC(num_cores); - GPR_ASSERT(cpup); - const size_t size = CPU_ALLOC_SIZE(num_cores); - CPU_ZERO_S(size, cpup); + bool DoRstAfterHeader(); + bool DoRstAfterData(); + bool DoRstDuringData(); + bool DoGoaway(); + bool DoPing(); + bool DoMaxStreams(); - if (cores_size > 0) { - for (int i = 0; i < cores_size; i++) { - if (cores[i] < num_cores) { - CPU_SET_S(cores[i], size, cpup); - cores_set++; - } - } - } else { - for (int i = 0; i < num_cores; i++) { - CPU_SET_S(i, size, cpup); - cores_set++; - } - } - bool affinity_set = (sched_setaffinity(0, size, cpup) == 0); - CPU_FREE(cpup); - return affinity_set ? cores_set : num_cores; -} + private: + class ServiceStub { + public: + ServiceStub(std::shared_ptr<Channel> channel); -} // namespace testing -} // namespace grpc -#else -namespace grpc { -namespace testing { + TestService::Stub* Get(); + + private: + std::unique_ptr<TestService::Stub> stub_; + std::shared_ptr<Channel> channel_; + }; -// LimitCores is not currently supported for non-Linux platforms -int LimitCores(const int*, int) { return gpr_cpu_num_cores(); } + void MaxStreamsWorker(std::shared_ptr<grpc::Channel> channel); + bool AssertStatusCode(const Status& s, StatusCode expected_code); + ServiceStub serviceStub_; + std::shared_ptr<Channel> channel_; +}; } // namespace testing } // namespace grpc -#endif + +#endif // GRPC_TEST_CPP_INTEROP_HTTP2_CLIENT_H diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index d1242627ef..b7f2723c39 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -31,7 +31,6 @@ * */ -#include <unistd.h> #include <cinttypes> #include <fstream> #include <memory> @@ -43,6 +42,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> +#include <grpc/support/time.h> #include <grpc/support/useful.h> #include "src/core/lib/transport/byte_stream.h" @@ -109,7 +109,10 @@ TestService::Stub* InteropClient::ServiceStub::Get() { UnimplementedService::Stub* InteropClient::ServiceStub::GetUnimplementedServiceStub() { - return UnimplementedService::NewStub(channel_).get(); + if (unimplemented_service_stub_ == nullptr) { + unimplemented_service_stub_ = UnimplementedService::NewStub(channel_); + } + return unimplemented_service_stub_.get(); } void InteropClient::ServiceStub::Reset(std::shared_ptr<Channel> channel) { @@ -615,7 +618,9 @@ bool InteropClient::DoResponseStreamingWithSlowConsumer() { GPR_ASSERT(response.payload().body() == grpc::string(kResponseMessageSize, '\0')); gpr_log(GPR_DEBUG, "received message %d", i); - usleep(kReceiveDelayMilliSeconds * 1000); + gpr_sleep_until(gpr_time_add( + gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_millis(kReceiveDelayMilliSeconds, GPR_TIMESPAN))); ++i; } @@ -943,7 +948,7 @@ bool InteropClient::DoCustomMetadata() { const auto& server_initial_metadata = context.GetServerInitialMetadata(); auto iter = server_initial_metadata.find(kEchoInitialMetadataKey); GPR_ASSERT(iter != server_initial_metadata.end()); - GPR_ASSERT(iter->second.data() == kInitialMetadataValue); + GPR_ASSERT(iter->second == kInitialMetadataValue); const auto& server_trailing_metadata = context.GetServerTrailingMetadata(); iter = server_trailing_metadata.find(kEchoTrailingBinMetadataKey); GPR_ASSERT(iter != server_trailing_metadata.end()); @@ -994,7 +999,7 @@ bool InteropClient::DoCustomMetadata() { const auto& server_initial_metadata = context.GetServerInitialMetadata(); auto iter = server_initial_metadata.find(kEchoInitialMetadataKey); GPR_ASSERT(iter != server_initial_metadata.end()); - GPR_ASSERT(iter->second.data() == kInitialMetadataValue); + GPR_ASSERT(iter->second == kInitialMetadataValue); const auto& server_trailing_metadata = context.GetServerTrailingMetadata(); iter = server_trailing_metadata.find(kEchoTrailingBinMetadataKey); GPR_ASSERT(iter != server_trailing_metadata.end()); diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 7ec7ebee20..74f4db6b78 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -107,6 +107,7 @@ class InteropClient { private: std::unique_ptr<TestService::Stub> stub_; + std::unique_ptr<UnimplementedService::Stub> unimplemented_service_stub_; std::shared_ptr<Channel> channel_; bool new_stub_every_call_; // If true, a new stub is returned by every // Get() call diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index 67456ce18b..5a810b45ef 100644 --- a/test/cpp/interop/interop_server.cc +++ b/test/cpp/interop/interop_server.cc @@ -31,8 +31,6 @@ * */ -#include <unistd.h> - #include <fstream> #include <memory> #include <sstream> @@ -45,6 +43,7 @@ #include <grpc++/server_context.h> #include <grpc/grpc.h> #include <grpc/support/log.h> +#include <grpc/support/time.h> #include <grpc/support/useful.h> #include "src/core/lib/support/string.h" @@ -56,6 +55,7 @@ #include "test/cpp/util/test_config.h" DEFINE_bool(use_tls, false, "Whether to use tls."); +DEFINE_string(custom_credentials_type, "", "User provided credentials type."); DEFINE_int32(port, 0, "Server port."); DEFINE_int32(max_send_message_size, -1, "The maximum send message size."); @@ -90,7 +90,9 @@ void MaybeEchoMetadata(ServerContext* context) { auto iter = client_metadata.find(kEchoInitialMetadataKey); if (iter != client_metadata.end()) { - context->AddInitialMetadata(kEchoInitialMetadataKey, iter->second.data()); + context->AddInitialMetadata( + kEchoInitialMetadataKey, + grpc::string(iter->second.begin(), iter->second.end())); } iter = client_metadata.find(kEchoTrailingBinMetadataKey); if (iter != client_metadata.end()) { @@ -104,7 +106,9 @@ void MaybeEchoMetadata(ServerContext* context) { if (iter != client_metadata.end()) { iter = client_metadata.find("user-agent"); if (iter != client_metadata.end()) { - context->AddInitialMetadata(kEchoUserAgentKey, iter->second.data()); + context->AddInitialMetadata( + kEchoUserAgentKey, + grpc::string(iter->second.begin(), iter->second.end())); } } } @@ -345,6 +349,7 @@ void grpc::testing::interop::RunServer( std::unique_ptr<Server> server(builder.BuildAndStart()); gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str()); while (!gpr_atm_no_barrier_load(&g_got_sigint)) { - sleep(5); + gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_seconds(5, GPR_TIMESPAN))); } } diff --git a/test/cpp/interop/interop_server_bootstrap.cc b/test/cpp/interop/interop_server_bootstrap.cc index 99518c6943..7cbf221a03 100644 --- a/test/cpp/interop/interop_server_bootstrap.cc +++ b/test/cpp/interop/interop_server_bootstrap.cc @@ -32,7 +32,6 @@ */ #include <signal.h> -#include <unistd.h> #include "test/cpp/interop/server_helper.h" #include "test/cpp/util/test_config.h" diff --git a/test/cpp/interop/reconnect_interop_server.cc b/test/cpp/interop/reconnect_interop_server.cc index 53d51e80e7..634d0a90fc 100644 --- a/test/cpp/interop/reconnect_interop_server.cc +++ b/test/cpp/interop/reconnect_interop_server.cc @@ -34,7 +34,6 @@ // Test description at doc/connection-backoff-interop-test-description.md #include <signal.h> -#include <unistd.h> #include <condition_variable> #include <memory> diff --git a/test/cpp/interop/server_helper.cc b/test/cpp/interop/server_helper.cc index 8b0b511bcb..d395f50fa5 100644 --- a/test/cpp/interop/server_helper.cc +++ b/test/cpp/interop/server_helper.cc @@ -39,23 +39,23 @@ #include <grpc++/security/server_credentials.h> #include "src/core/lib/surface/call_test_only.h" -#include "test/core/end2end/data/ssl_test_data.h" +#include "test/cpp/util/test_credentials_provider.h" DECLARE_bool(use_tls); +DECLARE_string(custom_credentials_type); namespace grpc { namespace testing { std::shared_ptr<ServerCredentials> CreateInteropServerCredentials() { - if (FLAGS_use_tls) { - SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key, - test_server1_cert}; - SslServerCredentialsOptions ssl_opts; - ssl_opts.pem_root_certs = ""; - ssl_opts.pem_key_cert_pairs.push_back(pkcp); - return SslServerCredentials(ssl_opts); + if (!FLAGS_custom_credentials_type.empty()) { + return GetCredentialsProvider()->GetServerCredentials( + FLAGS_custom_credentials_type); + } else if (FLAGS_use_tls) { + return GetCredentialsProvider()->GetServerCredentials(kTlsCredentialsType); } else { - return InsecureServerCredentials(); + return GetCredentialsProvider()->GetServerCredentials( + kInsecureCredentialsType); } } diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc index 97e658869f..fdc0a613f3 100644 --- a/test/cpp/interop/stress_test.cc +++ b/test/cpp/interop/stress_test.cc @@ -45,9 +45,9 @@ #include "src/proto/grpc/testing/metrics.grpc.pb.h" #include "src/proto/grpc/testing/metrics.pb.h" -#include "test/cpp/interop/client_helper.h" #include "test/cpp/interop/interop_client.h" #include "test/cpp/interop/stress_interop_client.h" +#include "test/cpp/util/create_test_channel.h" #include "test/cpp/util/metrics_server.h" #include "test/cpp/util/test_config.h" @@ -67,9 +67,7 @@ DEFINE_int32(test_duration_secs, -1, " forcefully terminated."); DEFINE_string(server_addresses, "localhost:8080", - "The list of server" - "addresses. This option is ignored if either\n" - "server_port or server_host is specified. The format is: \n" + "The list of server addresses. The format is: \n" " \"<name_1>:<port_1>,<name_2>:<port_1>...<name_N>:<port_N>\"\n" " Note: <name> can be servername or IP address."); @@ -80,34 +78,6 @@ DEFINE_int32(num_stubs_per_channel, 1, "indicates the max number of parallel RPC calls on each channel " "at any given time."); -DEFINE_string(test_case, "", - "Configure different test cases. Valid options are:\n\n" - "all : all test cases;\n" - "cancel_after_begin : cancel stream after starting it;\n" - "cancel_after_first_response: cancel on first response;\n" - "client_compressed_streaming : compressed request streaming with " - "client_compressed_unary : single compressed request;\n" - "client_streaming : request streaming with single response;\n" - "compute_engine_creds: large_unary with compute engine auth;\n" - "custom_metadata: server will echo custom metadata;\n" - "empty_stream : bi-di stream with no request/response;\n" - "empty_unary : empty (zero bytes) request and response;\n" - "half_duplex : half-duplex streaming;\n" - "jwt_token_creds: large_unary with JWT token auth;\n" - "large_unary : single request and (large) response;\n" - "oauth2_auth_token: raw oauth2 access token auth;\n" - "per_rpc_creds: raw oauth2 access token on a single rpc;\n" - "ping_pong : full-duplex streaming;\n" - "response streaming;\n" - "server_compressed_streaming : single request with compressed " - "server_compressed_unary : single compressed response;\n" - "server_streaming : single request with response streaming;\n" - "slow_consumer : single request with response streaming with " - "slow client consumer;\n" - "status_code_and_message: verify status code & message;\n" - "timeout_on_sleeping_server: deadline exceeds on stream;\n" - "unimplemented_method: client calls an unimplemented_method;\n"); - // TODO(sreek): Add more test cases here in future DEFINE_string(test_cases, "", "List of test cases to call along with the" @@ -148,12 +118,8 @@ DEFINE_bool(do_not_abort_on_transient_failures, true, // TODO(sreek): Consolidate overlapping options DEFINE_bool(use_tls, false, "Whether to use tls."); DEFINE_bool(use_test_ca, false, "False to use SSL roots for google"); -DEFINE_int32(server_port, 0, "Server port."); -DEFINE_string(server_host, "127.0.0.1", "Server host to connect to"); DEFINE_string(server_host_override, "foo.test.google.fr", "Override the server host which is sent in HTTP header"); -DEFINE_string(service_account_key_file, "", - "Path to service account json key file."); using grpc::testing::kTestCaseList; using grpc::testing::MetricsService; @@ -240,8 +206,6 @@ bool ParseTestCasesString(const grpc::string& test_cases, void LogParameterInfo(const std::vector<grpc::string>& addresses, const std::vector<std::pair<TestCaseType, int>>& tests) { gpr_log(GPR_INFO, "server_addresses: %s", FLAGS_server_addresses.c_str()); - gpr_log(GPR_INFO, "server_host: %s", FLAGS_server_host.c_str()); - gpr_log(GPR_INFO, "server_port: %d", FLAGS_server_port); gpr_log(GPR_INFO, "test_cases : %s", FLAGS_test_cases.c_str()); gpr_log(GPR_INFO, "sleep_duration_ms: %d", FLAGS_sleep_duration_ms); gpr_log(GPR_INFO, "test_duration_secs: %d", FLAGS_test_duration_secs); @@ -285,24 +249,11 @@ int main(int argc, char** argv) { // Parse the server addresses std::vector<grpc::string> server_addresses; - if (FLAGS_server_port != 0) { - // We are using interop_client style cmdline options. - const int host_port_buf_size = 1024; - char host_port[host_port_buf_size]; - snprintf(host_port, host_port_buf_size, "%s:%d", FLAGS_server_host.c_str(), - FLAGS_server_port); - std::string host_port_str(host_port); - ParseCommaDelimitedString(host_port_str, server_addresses); - } else { - ParseCommaDelimitedString(FLAGS_server_addresses, server_addresses); - } + ParseCommaDelimitedString(FLAGS_server_addresses, server_addresses); // Parse test cases and weights if (FLAGS_test_cases.length() == 0) { - // We are using interop_client style test_case option - FLAGS_test_cases = FLAGS_test_case + ":100"; - } else if (FLAGS_test_case != "") { - gpr_log(GPR_ERROR, "specify --test_case or --test_cases but not both."); + gpr_log(GPR_ERROR, "No test cases supplied"); return 1; } @@ -340,12 +291,8 @@ int main(int argc, char** argv) { channel_idx++) { gpr_log(GPR_INFO, "Starting test with %s channel_idx=%d..", it->c_str(), channel_idx); - std::shared_ptr<grpc::Channel> channel; - if (FLAGS_use_tls) { - channel = grpc::testing::CreateChannelForTestCase(FLAGS_test_case); - } else { - channel = grpc::CreateChannel(*it, grpc::InsecureChannelCredentials()); - } + std::shared_ptr<grpc::Channel> channel = grpc::CreateTestChannel( + *it, FLAGS_server_host_override, FLAGS_use_tls, !FLAGS_use_test_ca); // Create stub(s) for each channel for (int stub_idx = 0; stub_idx < FLAGS_num_stubs_per_channel; diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc index 6c0bf80488..9d883e68d7 100644 --- a/test/cpp/microbenchmarks/bm_fullstack.cc +++ b/test/cpp/microbenchmarks/bm_fullstack.cc @@ -54,9 +54,11 @@ extern "C" { #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/completion_queue.h" #include "src/core/lib/surface/server.h" +#include "test/core/util/memory_counters.h" #include "test/core/util/passthru_endpoint.h" #include "test/core/util/port.h" } +#include "src/core/lib/profiling/timers.h" #include "src/cpp/client/create_channel_internal.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "third_party/benchmark/include/benchmark/benchmark.h" @@ -67,6 +69,7 @@ namespace testing { static class InitializeStuff { public: InitializeStuff() { + grpc_memory_counters_init(); init_lib_.init(); rq_ = grpc_resource_quota_create("bm"); } @@ -84,15 +87,63 @@ static class InitializeStuff { * FIXTURES */ -class FullstackFixture { +static void ApplyCommonServerBuilderConfig(ServerBuilder* b) { + b->SetMaxReceiveMessageSize(INT_MAX); + b->SetMaxSendMessageSize(INT_MAX); +} + +static void ApplyCommonChannelArguments(ChannelArguments* c) { + c->SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, INT_MAX); + c->SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, INT_MAX); +} + +#ifdef GPR_MU_COUNTERS +extern "C" gpr_atm grpc_mu_locks; +#endif + +class BaseFixture { + public: + void Finish(benchmark::State& s) { + std::ostringstream out; + this->AddToLabel(out, s); +#ifdef GPR_MU_COUNTERS + out << " locks/iter:" << ((double)(gpr_atm_no_barrier_load(&grpc_mu_locks) - + mu_locks_at_start_) / + (double)s.iterations()); +#endif + grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot(); + out << " allocs/iter:" + << ((double)(counters_at_end.total_allocs_absolute - + counters_at_start_.total_allocs_absolute) / + (double)s.iterations()); + auto label = out.str(); + if (label.length() && label[0] == ' ') { + label = label.substr(1); + } + s.SetLabel(label); + } + + virtual void AddToLabel(std::ostream& out, benchmark::State& s) = 0; + + private: +#ifdef GPR_MU_COUNTERS + const size_t mu_locks_at_start_ = gpr_atm_no_barrier_load(&grpc_mu_locks); +#endif + grpc_memory_counters counters_at_start_ = grpc_memory_counters_snapshot(); +}; + +class FullstackFixture : public BaseFixture { public: FullstackFixture(Service* service, const grpc::string& address) { ServerBuilder b; b.AddListeningPort(address, InsecureServerCredentials()); cq_ = b.AddCompletionQueue(true); b.RegisterService(service); + ApplyCommonServerBuilderConfig(&b); server_ = b.BuildAndStart(); - channel_ = CreateChannel(address, InsecureChannelCredentials()); + ChannelArguments args; + ApplyCommonChannelArguments(&args); + channel_ = CreateCustomChannel(address, InsecureChannelCredentials(), args); } virtual ~FullstackFixture() { @@ -117,6 +168,8 @@ class TCP : public FullstackFixture { public: TCP(Service* service) : FullstackFixture(service, MakeAddress()) {} + void AddToLabel(std::ostream& out, benchmark::State& state) {} + private: static grpc::string MakeAddress() { int port = grpc_pick_unused_port_or_die(); @@ -130,6 +183,8 @@ class UDS : public FullstackFixture { public: UDS(Service* service) : FullstackFixture(service, MakeAddress()) {} + void AddToLabel(std::ostream& out, benchmark::State& state) override {} + private: static grpc::string MakeAddress() { int port = grpc_pick_unused_port_or_die(); // just for a unique id - not a @@ -140,12 +195,13 @@ class UDS : public FullstackFixture { } }; -class EndpointPairFixture { +class EndpointPairFixture : public BaseFixture { public: EndpointPairFixture(Service* service, grpc_endpoint_pair endpoints) { ServerBuilder b; cq_ = b.AddCompletionQueue(true); b.RegisterService(service); + ApplyCommonServerBuilderConfig(&b); server_ = b.BuildAndStart(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -174,6 +230,7 @@ class EndpointPairFixture { { ChannelArguments args; args.SetString(GRPC_ARG_DEFAULT_AUTHORITY, "test.authority"); + ApplyCommonChannelArguments(&args); grpc_channel_args c_args = args.c_channel_args(); grpc_transport* transport = @@ -213,6 +270,8 @@ class SockPair : public EndpointPairFixture { : EndpointPairFixture(service, grpc_iomgr_create_endpoint_pair( "test", initialize_stuff.rq(), 8192)) { } + + void AddToLabel(std::ostream& out, benchmark::State& state) {} }; class InProcessCHTTP2 : public EndpointPairFixture { @@ -220,10 +279,18 @@ class InProcessCHTTP2 : public EndpointPairFixture { InProcessCHTTP2(Service* service) : EndpointPairFixture(service, MakeEndpoints()) {} + void AddToLabel(std::ostream& out, benchmark::State& state) { + out << " writes/iter:" + << ((double)stats_.num_writes / (double)state.iterations()); + } + private: + grpc_passthru_endpoint_stats stats_; + grpc_endpoint_pair MakeEndpoints() { grpc_endpoint_pair p; - grpc_passthru_endpoint_create(&p.client, &p.server, initialize_stuff.rq()); + grpc_passthru_endpoint_create(&p.client, &p.server, initialize_stuff.rq(), + &stats_); return p; } }; @@ -343,6 +410,12 @@ static void BM_UnaryPingPong(benchmark::State& state) { EchoRequest send_request; EchoResponse send_response; EchoResponse recv_response; + if (state.range(0) > 0) { + send_request.set_message(std::string(state.range(0), 'a')); + } + if (state.range(1) > 0) { + send_response.set_message(std::string(state.range(1), 'a')); + } Status recv_status; struct ServerEnv { ServerContext ctx; @@ -365,6 +438,8 @@ static void BM_UnaryPingPong(benchmark::State& state) { std::unique_ptr<EchoTestService::Stub> stub( EchoTestService::NewStub(fixture->channel())); while (state.KeepRunning()) { + GPR_TIMER_SCOPE("BenchmarkCycle", 0); + recv_response.Clear(); ClientContext cli_ctx; ClientContextMutator cli_ctx_mut(&cli_ctx); std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( @@ -393,56 +468,429 @@ static void BM_UnaryPingPong(benchmark::State& state) { service.RequestEcho(&senv->ctx, &senv->recv_request, &senv->response_writer, fixture->cq(), fixture->cq(), tag(slot)); } + fixture->Finish(state); fixture.reset(); server_env[0]->~ServerEnv(); server_env[1]->~ServerEnv(); + state.SetBytesProcessed(state.range(0) * state.iterations() + + state.range(1) * state.iterations()); +} + +// Repeatedly makes Streaming Bidi calls (exchanging a configurable number of +// messages in each call) in a loop on a single channel +// +// First parmeter (i.e state.range(0)): Message size (in bytes) to use +// Second parameter (i.e state.range(1)): Number of ping pong messages. +// Note: One ping-pong means two messages (one from client to server and +// the other from server to client): +template <class Fixture, class ClientContextMutator, class ServerContextMutator> +static void BM_StreamingPingPong(benchmark::State& state) { + const int msg_size = state.range(0); + const int max_ping_pongs = state.range(1); + + EchoTestService::AsyncService service; + std::unique_ptr<Fixture> fixture(new Fixture(&service)); + { + EchoResponse send_response; + EchoResponse recv_response; + EchoRequest send_request; + EchoRequest recv_request; + + if (msg_size > 0) { + send_request.set_message(std::string(msg_size, 'a')); + send_response.set_message(std::string(msg_size, 'b')); + } + + std::unique_ptr<EchoTestService::Stub> stub( + EchoTestService::NewStub(fixture->channel())); + + while (state.KeepRunning()) { + ServerContext svr_ctx; + ServerContextMutator svr_ctx_mut(&svr_ctx); + ServerAsyncReaderWriter<EchoResponse, EchoRequest> response_rw(&svr_ctx); + service.RequestBidiStream(&svr_ctx, &response_rw, fixture->cq(), + fixture->cq(), tag(0)); + + ClientContext cli_ctx; + ClientContextMutator cli_ctx_mut(&cli_ctx); + auto request_rw = stub->AsyncBidiStream(&cli_ctx, fixture->cq(), tag(1)); + + // Establish async stream between client side and server side + void* t; + bool ok; + int need_tags = (1 << 0) | (1 << 1); + while (need_tags) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + GPR_ASSERT(ok); + int i = (int)(intptr_t)t; + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); + } + + // Send 'max_ping_pongs' number of ping pong messages + int ping_pong_cnt = 0; + while (ping_pong_cnt < max_ping_pongs) { + request_rw->Write(send_request, tag(0)); // Start client send + response_rw.Read(&recv_request, tag(1)); // Start server recv + request_rw->Read(&recv_response, tag(2)); // Start client recv + + need_tags = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3); + while (need_tags) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + GPR_ASSERT(ok); + int i = (int)(intptr_t)t; + + // If server recv is complete, start the server send operation + if (i == 1) { + response_rw.Write(send_response, tag(3)); + } + + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); + } + + ping_pong_cnt++; + } + + request_rw->WritesDone(tag(0)); + response_rw.Finish(Status::OK, tag(1)); + + Status recv_status; + request_rw->Finish(&recv_status, tag(2)); + + need_tags = (1 << 0) | (1 << 1) | (1 << 2); + while (need_tags) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + int i = (int)(intptr_t)t; + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); + } + + GPR_ASSERT(recv_status.ok()); + } + } + + fixture->Finish(state); + fixture.reset(); + state.SetBytesProcessed(msg_size * state.iterations() * max_ping_pongs * 2); +} + +// Repeatedly sends ping pong messages in a single streaming Bidi call in a loop +// First parmeter (i.e state.range(0)): Message size (in bytes) to use +template <class Fixture, class ClientContextMutator, class ServerContextMutator> +static void BM_StreamingPingPongMsgs(benchmark::State& state) { + const int msg_size = state.range(0); + + EchoTestService::AsyncService service; + std::unique_ptr<Fixture> fixture(new Fixture(&service)); + { + EchoResponse send_response; + EchoResponse recv_response; + EchoRequest send_request; + EchoRequest recv_request; + + if (msg_size > 0) { + send_request.set_message(std::string(msg_size, 'a')); + send_response.set_message(std::string(msg_size, 'b')); + } + + std::unique_ptr<EchoTestService::Stub> stub( + EchoTestService::NewStub(fixture->channel())); + + ServerContext svr_ctx; + ServerContextMutator svr_ctx_mut(&svr_ctx); + ServerAsyncReaderWriter<EchoResponse, EchoRequest> response_rw(&svr_ctx); + service.RequestBidiStream(&svr_ctx, &response_rw, fixture->cq(), + fixture->cq(), tag(0)); + + ClientContext cli_ctx; + ClientContextMutator cli_ctx_mut(&cli_ctx); + auto request_rw = stub->AsyncBidiStream(&cli_ctx, fixture->cq(), tag(1)); + + // Establish async stream between client side and server side + void* t; + bool ok; + int need_tags = (1 << 0) | (1 << 1); + while (need_tags) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + GPR_ASSERT(ok); + int i = (int)(intptr_t)t; + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); + } + + while (state.KeepRunning()) { + request_rw->Write(send_request, tag(0)); // Start client send + response_rw.Read(&recv_request, tag(1)); // Start server recv + request_rw->Read(&recv_response, tag(2)); // Start client recv + + need_tags = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3); + while (need_tags) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + GPR_ASSERT(ok); + int i = (int)(intptr_t)t; + + // If server recv is complete, start the server send operation + if (i == 1) { + response_rw.Write(send_response, tag(3)); + } + + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); + } + } + + request_rw->WritesDone(tag(0)); + response_rw.Finish(Status::OK, tag(1)); + Status recv_status; + request_rw->Finish(&recv_status, tag(2)); + + need_tags = (1 << 0) | (1 << 1) | (1 << 2); + while (need_tags) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + int i = (int)(intptr_t)t; + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); + } + + GPR_ASSERT(recv_status.ok()); + } + + fixture->Finish(state); + fixture.reset(); + state.SetBytesProcessed(msg_size * state.iterations() * 2); +} + +template <class Fixture> +static void BM_PumpStreamClientToServer(benchmark::State& state) { + EchoTestService::AsyncService service; + std::unique_ptr<Fixture> fixture(new Fixture(&service)); + { + EchoRequest send_request; + EchoRequest recv_request; + if (state.range(0) > 0) { + send_request.set_message(std::string(state.range(0), 'a')); + } + Status recv_status; + ServerContext svr_ctx; + ServerAsyncReaderWriter<EchoResponse, EchoRequest> response_rw(&svr_ctx); + service.RequestBidiStream(&svr_ctx, &response_rw, fixture->cq(), + fixture->cq(), tag(0)); + std::unique_ptr<EchoTestService::Stub> stub( + EchoTestService::NewStub(fixture->channel())); + ClientContext cli_ctx; + auto request_rw = stub->AsyncBidiStream(&cli_ctx, fixture->cq(), tag(1)); + int need_tags = (1 << 0) | (1 << 1); + void* t; + bool ok; + while (need_tags) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + GPR_ASSERT(ok); + int i = (int)(intptr_t)t; + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); + } + response_rw.Read(&recv_request, tag(0)); + while (state.KeepRunning()) { + GPR_TIMER_SCOPE("BenchmarkCycle", 0); + request_rw->Write(send_request, tag(1)); + while (true) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + if (t == tag(0)) { + response_rw.Read(&recv_request, tag(0)); + } else if (t == tag(1)) { + break; + } else { + GPR_ASSERT(false); + } + } + } + request_rw->WritesDone(tag(1)); + need_tags = (1 << 0) | (1 << 1); + while (need_tags) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + int i = (int)(intptr_t)t; + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); + } + } + fixture->Finish(state); + fixture.reset(); + state.SetBytesProcessed(state.range(0) * state.iterations()); +} + +template <class Fixture> +static void BM_PumpStreamServerToClient(benchmark::State& state) { + EchoTestService::AsyncService service; + std::unique_ptr<Fixture> fixture(new Fixture(&service)); + { + EchoResponse send_response; + EchoResponse recv_response; + if (state.range(0) > 0) { + send_response.set_message(std::string(state.range(0), 'a')); + } + Status recv_status; + ServerContext svr_ctx; + ServerAsyncReaderWriter<EchoResponse, EchoRequest> response_rw(&svr_ctx); + service.RequestBidiStream(&svr_ctx, &response_rw, fixture->cq(), + fixture->cq(), tag(0)); + std::unique_ptr<EchoTestService::Stub> stub( + EchoTestService::NewStub(fixture->channel())); + ClientContext cli_ctx; + auto request_rw = stub->AsyncBidiStream(&cli_ctx, fixture->cq(), tag(1)); + int need_tags = (1 << 0) | (1 << 1); + void* t; + bool ok; + while (need_tags) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + GPR_ASSERT(ok); + int i = (int)(intptr_t)t; + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); + } + request_rw->Read(&recv_response, tag(0)); + while (state.KeepRunning()) { + GPR_TIMER_SCOPE("BenchmarkCycle", 0); + response_rw.Write(send_response, tag(1)); + while (true) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + if (t == tag(0)) { + request_rw->Read(&recv_response, tag(0)); + } else if (t == tag(1)) { + break; + } else { + GPR_ASSERT(false); + } + } + } + response_rw.Finish(Status::OK, tag(1)); + need_tags = (1 << 0) | (1 << 1); + while (need_tags) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + int i = (int)(intptr_t)t; + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); + } + } + fixture->Finish(state); + fixture.reset(); + state.SetBytesProcessed(state.range(0) * state.iterations()); } /******************************************************************************* * CONFIGURATIONS */ -BENCHMARK_TEMPLATE(BM_UnaryPingPong, TCP, NoOpMutator, NoOpMutator); -BENCHMARK_TEMPLATE(BM_UnaryPingPong, UDS, NoOpMutator, NoOpMutator); -BENCHMARK_TEMPLATE(BM_UnaryPingPong, SockPair, NoOpMutator, NoOpMutator); -BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, NoOpMutator); +static void SweepSizesArgs(benchmark::internal::Benchmark* b) { + b->Args({0, 0}); + for (int i = 1; i <= 128 * 1024 * 1024; i *= 8) { + b->Args({i, 0}); + b->Args({0, i}); + b->Args({i, i}); + } +} + +BENCHMARK_TEMPLATE(BM_UnaryPingPong, TCP, NoOpMutator, NoOpMutator) + ->Apply(SweepSizesArgs); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, UDS, NoOpMutator, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, SockPair, NoOpMutator, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, NoOpMutator) + ->Apply(SweepSizesArgs); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, - Client_AddMetadata<RandomBinaryMetadata<10>, 1>, - NoOpMutator); + Client_AddMetadata<RandomBinaryMetadata<10>, 1>, NoOpMutator) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, - Client_AddMetadata<RandomBinaryMetadata<31>, 1>, - NoOpMutator); + Client_AddMetadata<RandomBinaryMetadata<31>, 1>, NoOpMutator) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, Client_AddMetadata<RandomBinaryMetadata<100>, 1>, - NoOpMutator); + NoOpMutator) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, - Client_AddMetadata<RandomBinaryMetadata<10>, 2>, - NoOpMutator); + Client_AddMetadata<RandomBinaryMetadata<10>, 2>, NoOpMutator) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, - Client_AddMetadata<RandomBinaryMetadata<31>, 2>, - NoOpMutator); + Client_AddMetadata<RandomBinaryMetadata<31>, 2>, NoOpMutator) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, Client_AddMetadata<RandomBinaryMetadata<100>, 2>, - NoOpMutator); + NoOpMutator) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>); + Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>); + Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>); + Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, - Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator); + Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, - Client_AddMetadata<RandomAsciiMetadata<31>, 1>, NoOpMutator); + Client_AddMetadata<RandomAsciiMetadata<31>, 1>, NoOpMutator) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, - Client_AddMetadata<RandomAsciiMetadata<100>, 1>, - NoOpMutator); + Client_AddMetadata<RandomAsciiMetadata<100>, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>); + Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>); + Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>); + Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>) + ->Args({0, 0}); + +BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, TCP) + ->Range(0, 128 * 1024 * 1024); +BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, UDS) + ->Range(0, 128 * 1024 * 1024); +BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, SockPair) + ->Range(0, 128 * 1024 * 1024); +BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, InProcessCHTTP2) + ->Range(0, 128 * 1024 * 1024); +BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, TCP) + ->Range(0, 128 * 1024 * 1024); +BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, UDS) + ->Range(0, 128 * 1024 * 1024); +BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, SockPair) + ->Range(0, 128 * 1024 * 1024); +BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, InProcessCHTTP2) + ->Range(0, 128 * 1024 * 1024); + +// Generate Args for StreamingPingPong benchmarks. Currently generates args for +// only "small streams" (i.e streams with 0, 1 or 2 messages) +static void StreamingPingPongArgs(benchmark::internal::Benchmark* b) { + int msg_size = 0; + + b->Args({0, 0}); // spl case: 0 ping-pong msgs (msg_size doesn't matter here) + + for (msg_size = 0; msg_size <= 128 * 1024 * 1024; + msg_size == 0 ? msg_size++ : msg_size *= 8) { + b->Args({msg_size, 1}); + b->Args({msg_size, 2}); + } +} + +BENCHMARK_TEMPLATE(BM_StreamingPingPong, InProcessCHTTP2, NoOpMutator, + NoOpMutator) + ->Apply(StreamingPingPongArgs); +BENCHMARK_TEMPLATE(BM_StreamingPingPong, TCP, NoOpMutator, NoOpMutator) + ->Apply(StreamingPingPongArgs); + +BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, InProcessCHTTP2, NoOpMutator, + NoOpMutator) + ->Range(0, 128 * 1024 * 1024); +BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, TCP, NoOpMutator, NoOpMutator) + ->Range(0, 128 * 1024 * 1024); } // namespace testing } // namespace grpc diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc new file mode 100644 index 0000000000..7a914c1547 --- /dev/null +++ b/test/cpp/performance/writes_per_rpc_test.cc @@ -0,0 +1,268 @@ +/* + * + * 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 <grpc++/channel.h> +#include <grpc++/create_channel.h> +#include <grpc++/impl/grpc_library.h> +#include <grpc++/security/credentials.h> +#include <grpc++/security/server_credentials.h> +#include <grpc++/server.h> +#include <grpc++/server_builder.h> +#include <grpc/support/log.h> +#include <gtest/gtest.h> + +extern "C" { +#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/endpoint_pair.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/tcp_posix.h" +#include "src/core/lib/surface/channel.h" +#include "src/core/lib/surface/completion_queue.h" +#include "src/core/lib/surface/server.h" +#include "test/core/util/passthru_endpoint.h" +#include "test/core/util/port.h" +} +#include "src/cpp/client/create_channel_internal.h" +#include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/core/util/test_config.h" + +namespace grpc { +namespace testing { + +static void* tag(intptr_t x) { return reinterpret_cast<void*>(x); } + +static void ApplyCommonServerBuilderConfig(ServerBuilder* b) { + b->SetMaxReceiveMessageSize(INT_MAX); + b->SetMaxSendMessageSize(INT_MAX); +} + +static void ApplyCommonChannelArguments(ChannelArguments* c) { + c->SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, INT_MAX); + c->SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, INT_MAX); +} + +static class InitializeStuff { + public: + InitializeStuff() { + init_lib_.init(); + rq_ = grpc_resource_quota_create("bm"); + } + + ~InitializeStuff() { init_lib_.shutdown(); } + + grpc_resource_quota* rq() { return rq_; } + + private: + internal::GrpcLibrary init_lib_; + grpc_resource_quota* rq_; +} initialize_stuff; + +class EndpointPairFixture { + public: + EndpointPairFixture(Service* service, grpc_endpoint_pair endpoints) { + ServerBuilder b; + cq_ = b.AddCompletionQueue(true); + b.RegisterService(service); + ApplyCommonServerBuilderConfig(&b); + server_ = b.BuildAndStart(); + + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + + /* add server endpoint to server_ */ + { + const grpc_channel_args* server_args = + grpc_server_get_channel_args(server_->c_server()); + grpc_transport* transport = grpc_create_chttp2_transport( + &exec_ctx, server_args, endpoints.server, 0 /* is_client */); + + grpc_pollset** pollsets; + size_t num_pollsets = 0; + grpc_server_get_pollsets(server_->c_server(), &pollsets, &num_pollsets); + + for (size_t i = 0; i < num_pollsets; i++) { + grpc_endpoint_add_to_pollset(&exec_ctx, endpoints.server, pollsets[i]); + } + + grpc_server_setup_transport(&exec_ctx, server_->c_server(), transport, + NULL, server_args); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); + } + + /* create channel */ + { + ChannelArguments args; + args.SetString(GRPC_ARG_DEFAULT_AUTHORITY, "test.authority"); + ApplyCommonChannelArguments(&args); + + grpc_channel_args c_args = args.c_channel_args(); + grpc_transport* transport = + grpc_create_chttp2_transport(&exec_ctx, &c_args, endpoints.client, 1); + GPR_ASSERT(transport); + grpc_channel* channel = grpc_channel_create( + &exec_ctx, "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); + + channel_ = CreateChannelInternal("", channel); + } + + grpc_exec_ctx_finish(&exec_ctx); + } + + virtual ~EndpointPairFixture() { + server_->Shutdown(); + cq_->Shutdown(); + void* tag; + bool ok; + while (cq_->Next(&tag, &ok)) { + } + } + + ServerCompletionQueue* cq() { return cq_.get(); } + std::shared_ptr<Channel> channel() { return channel_; } + + private: + std::unique_ptr<Server> server_; + std::unique_ptr<ServerCompletionQueue> cq_; + std::shared_ptr<Channel> channel_; +}; + +class InProcessCHTTP2 : public EndpointPairFixture { + public: + InProcessCHTTP2(Service* service) + : EndpointPairFixture(service, MakeEndpoints()) {} + + int writes_performed() const { return stats_.num_writes; } + + private: + grpc_passthru_endpoint_stats stats_; + + grpc_endpoint_pair MakeEndpoints() { + grpc_endpoint_pair p; + grpc_passthru_endpoint_create(&p.client, &p.server, initialize_stuff.rq(), + &stats_); + return p; + } +}; + +static double UnaryPingPong(int request_size, int response_size) { + const int kIterations = 10000; + + EchoTestService::AsyncService service; + std::unique_ptr<InProcessCHTTP2> fixture(new InProcessCHTTP2(&service)); + EchoRequest send_request; + EchoResponse send_response; + EchoResponse recv_response; + if (request_size > 0) { + send_request.set_message(std::string(request_size, 'a')); + } + if (response_size > 0) { + send_response.set_message(std::string(response_size, 'a')); + } + Status recv_status; + struct ServerEnv { + ServerContext ctx; + EchoRequest recv_request; + grpc::ServerAsyncResponseWriter<EchoResponse> response_writer; + ServerEnv() : response_writer(&ctx) {} + }; + uint8_t server_env_buffer[2 * sizeof(ServerEnv)]; + ServerEnv* server_env[2] = { + reinterpret_cast<ServerEnv*>(server_env_buffer), + reinterpret_cast<ServerEnv*>(server_env_buffer + sizeof(ServerEnv))}; + new (server_env[0]) ServerEnv; + new (server_env[1]) ServerEnv; + service.RequestEcho(&server_env[0]->ctx, &server_env[0]->recv_request, + &server_env[0]->response_writer, fixture->cq(), + fixture->cq(), tag(0)); + service.RequestEcho(&server_env[1]->ctx, &server_env[1]->recv_request, + &server_env[1]->response_writer, fixture->cq(), + fixture->cq(), tag(1)); + std::unique_ptr<EchoTestService::Stub> stub( + EchoTestService::NewStub(fixture->channel())); + for (int iteration = 0; iteration < kIterations; iteration++) { + recv_response.Clear(); + ClientContext cli_ctx; + std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( + stub->AsyncEcho(&cli_ctx, send_request, fixture->cq())); + void* t; + bool ok; + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + GPR_ASSERT(ok); + GPR_ASSERT(t == tag(0) || t == tag(1)); + intptr_t slot = reinterpret_cast<intptr_t>(t); + ServerEnv* senv = server_env[slot]; + senv->response_writer.Finish(send_response, Status::OK, tag(3)); + response_reader->Finish(&recv_response, &recv_status, tag(4)); + for (int i = (1 << 3) | (1 << 4); i != 0;) { + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + GPR_ASSERT(ok); + int tagnum = (int)reinterpret_cast<intptr_t>(t); + GPR_ASSERT(i & (1 << tagnum)); + i -= 1 << tagnum; + } + GPR_ASSERT(recv_status.ok()); + + senv->~ServerEnv(); + senv = new (senv) ServerEnv(); + service.RequestEcho(&senv->ctx, &senv->recv_request, &senv->response_writer, + fixture->cq(), fixture->cq(), tag(slot)); + } + + double writes_per_iteration = + (double)fixture->writes_performed() / (double)kIterations; + + fixture.reset(); + server_env[0]->~ServerEnv(); + server_env[1]->~ServerEnv(); + + return writes_per_iteration; +} + +TEST(WritesPerRpcTest, UnaryPingPong) { + EXPECT_LT(UnaryPingPong(0, 0), 2.05); + EXPECT_LT(UnaryPingPong(1, 0), 2.05); + EXPECT_LT(UnaryPingPong(0, 1), 2.05); + EXPECT_LT(UnaryPingPong(4096, 0), 2.2); + EXPECT_LT(UnaryPingPong(0, 4096), 2.2); +} + +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index fdd78ebb89..baa9304cc2 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -51,7 +51,6 @@ #include "test/cpp/qps/histogram.h" #include "test/cpp/qps/interarrival.h" -#include "test/cpp/qps/limit_cores.h" #include "test/cpp/qps/usage_timer.h" #include "test/cpp/util/create_test_channel.h" @@ -374,7 +373,7 @@ class ClientImpl : public Client { ClientImpl(const ClientConfig& config, std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)> create_stub) - : cores_(LimitCores(config.core_list().data(), config.core_list_size())), + : cores_(gpr_cpu_num_cores()), channels_(config.client_channels()), create_stub_(create_stub) { for (int i = 0; i < config.client_channels(); i++) { @@ -409,6 +408,7 @@ class ClientImpl : public Client { // old compilers happy with using this in std::vector ChannelArguments args; args.SetInt("shard_to_ensure_no_subchannel_merges", shard); + set_channel_args(config, &args); channel_ = CreateTestChannel( target, config.security_params().server_host_override(), config.has_security_params(), !config.security_params().use_test_ca(), @@ -423,6 +423,18 @@ class ClientImpl : public Client { StubType* get_stub() { return stub_.get(); } private: + void set_channel_args(const ClientConfig& config, ChannelArguments* args) { + for (auto channel_arg : config.channel_args()) { + if (channel_arg.value_case() == ChannelArg::kStrValue) { + args->SetString(channel_arg.name(), channel_arg.str_value()); + } else if (channel_arg.value_case() == ChannelArg::kIntValue) { + args->SetInt(channel_arg.name(), channel_arg.int_value()); + } else { + gpr_log(GPR_ERROR, "Empty channel arg value."); + } + } + } + std::shared_ptr<Channel> channel_; std::unique_ptr<StubType> stub_; }; diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index b1e61865e7..498416c64a 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -153,7 +153,6 @@ class SynchronousStreamingClient final : public SynchronousClient { if (*stream) { (*stream)->WritesDone(); Status s = (*stream)->Finish(); - EXPECT_TRUE(s.ok()); if (!s.ok()) { gpr_log(GPR_ERROR, "Stream %zu received an error %s", i, s.error_message().c_str()); @@ -173,7 +172,11 @@ class SynchronousStreamingClient final : public SynchronousClient { entry->set_value((UsageTimer::Now() - start) * 1e9); return true; } - return false; + auto* stub = channels_[thread_idx % channels_.size()].get_stub(); + context_[thread_idx].~ClientContext(); + new (&context_[thread_idx]) ClientContext(); + stream_[thread_idx] = stub->StreamingCall(&context_[thread_idx]); + return true; } private: diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 93ef32db77..74fe3662c1 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -76,30 +76,6 @@ static std::string get_host(const std::string& worker) { return s; } -static std::unordered_map<string, std::deque<int>> get_hosts_and_cores( - const deque<string>& workers) { - std::unordered_map<string, std::deque<int>> hosts; - for (auto it = workers.begin(); it != workers.end(); it++) { - const string host = get_host(*it); - if (hosts.find(host) == hosts.end()) { - auto stub = WorkerService::NewStub( - CreateChannel(*it, InsecureChannelCredentials())); - grpc::ClientContext ctx; - ctx.set_wait_for_ready(true); - CoreRequest dummy; - CoreResponse cores; - grpc::Status s = stub->CoreCount(&ctx, dummy, &cores); - GPR_ASSERT(s.ok()); - std::deque<int> dq; - for (int i = 0; i < cores.cores(); i++) { - dq.push_back(i); - } - hosts[host] = dq; - } - } - return hosts; -} - static deque<string> get_workers(const string& env_name) { char* env = gpr_getenv(env_name.c_str()); if (!env) { @@ -210,7 +186,7 @@ std::unique_ptr<ScenarioResult> RunScenario( const ClientConfig& initial_client_config, size_t num_clients, const ServerConfig& initial_server_config, size_t num_servers, int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count, - const char* qps_server_target_override, bool configure_core_lists) { + const char* qps_server_target_override) { // Log everything from the driver gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG); @@ -279,9 +255,6 @@ std::unique_ptr<ScenarioResult> RunScenario( std::vector<ServerData> servers(num_servers); std::unordered_map<string, std::deque<int>> hosts_cores; - if (configure_core_lists) { - hosts_cores = get_hosts_and_cores(workers); - } for (size_t i = 0; i < num_servers; i++) { gpr_log(GPR_INFO, "Starting server on %s (worker #%" PRIuPTR ")", workers[i].c_str(), i); @@ -289,37 +262,9 @@ std::unique_ptr<ScenarioResult> RunScenario( CreateChannel(workers[i], InsecureChannelCredentials())); ServerConfig server_config = initial_server_config; - int server_core_limit = initial_server_config.core_limit(); - int client_core_limit = initial_client_config.core_limit(); - - if (configure_core_lists) { - string host_str(get_host(workers[i])); - if (server_core_limit == 0 && client_core_limit > 0) { - // In this case, limit the server cores if it matches the - // same host as one or more clients - const auto& dq = hosts_cores.at(host_str); - bool match = false; - int limit = dq.size(); - for (size_t cli = 0; cli < num_clients; cli++) { - if (host_str == get_host(workers[cli + num_servers])) { - limit -= client_core_limit; - match = true; - } - } - if (match) { - GPR_ASSERT(limit > 0); - server_core_limit = limit; - } - } - if (server_core_limit > 0) { - auto& dq = hosts_cores.at(host_str); - GPR_ASSERT(dq.size() >= static_cast<size_t>(server_core_limit)); - gpr_log(GPR_INFO, "Setting server core_list"); - for (int core = 0; core < server_core_limit; core++) { - server_config.add_core_list(dq.front()); - dq.pop_front(); - } - } + if (server_config.core_limit() != 0) { + gpr_log(GPR_ERROR, + "server config core limit is set but ignored by driver"); } ServerArgs args; @@ -364,33 +309,8 @@ std::unique_ptr<ScenarioResult> RunScenario( CreateChannel(worker, InsecureChannelCredentials())); ClientConfig per_client_config = client_config; - int server_core_limit = initial_server_config.core_limit(); - int client_core_limit = initial_client_config.core_limit(); - if (configure_core_lists && - ((server_core_limit > 0) || (client_core_limit > 0))) { - auto& dq = hosts_cores.at(get_host(worker)); - if (client_core_limit == 0) { - // limit client cores if it matches a server host - bool match = false; - int limit = dq.size(); - for (size_t srv = 0; srv < num_servers; srv++) { - if (get_host(worker) == get_host(workers[srv])) { - match = true; - } - } - if (match) { - GPR_ASSERT(limit > 0); - client_core_limit = limit; - } - } - if (client_core_limit > 0) { - GPR_ASSERT(dq.size() >= static_cast<size_t>(client_core_limit)); - gpr_log(GPR_INFO, "Setting client core_list"); - for (int core = 0; core < client_core_limit; core++) { - per_client_config.add_core_list(dq.front()); - dq.pop_front(); - } - } + if (initial_client_config.core_limit() != 0) { + gpr_log(GPR_ERROR, "client config core limit set but ignored"); } // Reduce channel count so that total channels specified is held regardless diff --git a/test/cpp/qps/driver.h b/test/cpp/qps/driver.h index b5c8152e1b..e72d30a4ef 100644 --- a/test/cpp/qps/driver.h +++ b/test/cpp/qps/driver.h @@ -46,8 +46,7 @@ std::unique_ptr<ScenarioResult> RunScenario( const grpc::testing::ClientConfig& client_config, size_t num_clients, const grpc::testing::ServerConfig& server_config, size_t num_servers, int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count, - const char* qps_server_target_override = "", - bool configure_core_lists = true); + const char* qps_server_target_override = ""); bool RunQuit(); } // namespace testing diff --git a/test/cpp/qps/gen_build_yaml.py b/test/cpp/qps/gen_build_yaml.py index 188d6196e5..2f035abedd 100755 --- a/test/cpp/qps/gen_build_yaml.py +++ b/test/cpp/qps/gen_build_yaml.py @@ -92,7 +92,8 @@ print yaml.dump({ 'defaults': 'boringssl', 'cpu_cost': guess_cpu(scenario_json, False), 'exclude_configs': ['tsan', 'asan'], - 'timeout_seconds': 6*60 + 'timeout_seconds': 6*60, + 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []) } for scenario_json in scenario_config.CXXLanguage().scenarios() if 'scalable' in scenario_json.get('CATEGORIES', []) @@ -109,8 +110,9 @@ print yaml.dump({ 'defaults': 'boringssl', 'cpu_cost': guess_cpu(scenario_json, True), 'exclude_configs': sorted(c for c in configs_from_yaml if c not in ('tsan', 'asan')), - 'timeout_seconds': 6*60 - } + 'timeout_seconds': 6*60, + 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []) + } for scenario_json in scenario_config.CXXLanguage().scenarios() if 'scalable' in scenario_json.get('CATEGORIES', []) ] diff --git a/test/cpp/qps/qps_json_driver.cc b/test/cpp/qps/qps_json_driver.cc index da835b995a..ddaaa7ca75 100644 --- a/test/cpp/qps/qps_json_driver.cc +++ b/test/cpp/qps/qps_json_driver.cc @@ -70,9 +70,6 @@ DEFINE_double(error_tolerance, 0.01, DEFINE_string(qps_server_target_override, "", "Override QPS server target to configure in client configs." "Only applicable if there is a single benchmark server."); -DEFINE_bool(configure_core_lists, true, - "Provide 'core_list' parameters to workers. Value determined " - "by cores available and 'core_limit' parameters of the scenarios."); namespace grpc { namespace testing { @@ -80,12 +77,12 @@ namespace testing { static std::unique_ptr<ScenarioResult> RunAndReport(const Scenario& scenario, bool* success) { std::cerr << "RUNNING SCENARIO: " << scenario.name() << "\n"; - auto result = RunScenario( - scenario.client_config(), scenario.num_clients(), - scenario.server_config(), scenario.num_servers(), - scenario.warmup_seconds(), scenario.benchmark_seconds(), - scenario.spawn_local_worker_count(), - FLAGS_qps_server_target_override.c_str(), FLAGS_configure_core_lists); + auto result = + RunScenario(scenario.client_config(), scenario.num_clients(), + scenario.server_config(), scenario.num_servers(), + scenario.warmup_seconds(), scenario.benchmark_seconds(), + scenario.spawn_local_worker_count(), + FLAGS_qps_server_target_override.c_str()); // Amend the result with scenario config. Eventually we should adjust // RunScenario contract so we don't need to touch the result here. @@ -212,6 +209,7 @@ static bool QpsDriver() { SearchOfferedLoad(FLAGS_initial_search_value, FLAGS_targeted_cpu_load, scenario, &success); gpr_log(GPR_INFO, "targeted_offered_load %f", targeted_offered_load); + GetCpuLoad(scenario, targeted_offered_load, &success); } else { gpr_log(GPR_ERROR, "Unimplemented search param"); } diff --git a/test/cpp/qps/qps_openloop_test.cc b/test/cpp/qps/qps_openloop_test.cc index 8dc50ac6d8..70e2709ac0 100644 --- a/test/cpp/qps/qps_openloop_test.cc +++ b/test/cpp/qps/qps_openloop_test.cc @@ -56,7 +56,7 @@ static void RunQPS() { client_config.set_async_client_threads(8); client_config.set_rpc_type(STREAMING); client_config.mutable_load_params()->mutable_poisson()->set_offered_load( - 1000.0 / GRPC_TEST_SLOWDOWN_FACTOR); + 1000.0 / grpc_test_slowdown_factor()); ServerConfig server_config; server_config.set_server_type(ASYNC_SERVER); diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index c3d18e5789..821d5935be 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -42,7 +42,6 @@ #include "src/proto/grpc/testing/messages.grpc.pb.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" -#include "test/cpp/qps/limit_cores.h" #include "test/cpp/qps/usage_timer.h" namespace grpc { @@ -51,7 +50,7 @@ namespace testing { class Server { public: explicit Server(const ServerConfig& config) : timer_(new UsageTimer) { - cores_ = LimitCores(config.core_list().data(), config.core_list_size()); + cores_ = gpr_cpu_num_cores(); if (config.port()) { port_ = config.port(); diff --git a/test/cpp/qps/usage_timer.cc b/test/cpp/qps/usage_timer.cc index c6697fbdfd..70ef26e82a 100644 --- a/test/cpp/qps/usage_timer.cc +++ b/test/cpp/qps/usage_timer.cc @@ -39,8 +39,15 @@ #include <grpc/support/log.h> #include <grpc/support/time.h> +#ifdef __linux__ #include <sys/resource.h> #include <sys/time.h> + +static double time_double(struct timeval* tv) { + return tv->tv_sec + 1e-6 * tv->tv_usec; +} +#endif + UsageTimer::UsageTimer() : start_(Sample()) {} double UsageTimer::Now() { @@ -48,8 +55,16 @@ double UsageTimer::Now() { return ts.tv_sec + 1e-9 * ts.tv_nsec; } -static double time_double(struct timeval* tv) { - return tv->tv_sec + 1e-6 * tv->tv_usec; +static void get_resource_usage(double* utime, double* stime) { +#ifdef __linux__ + struct rusage usage; + getrusage(RUSAGE_SELF, &usage); + *utime = time_double(&usage.ru_utime); + *stime = time_double(&usage.ru_stime); +#else + *utime = 0; + *stime = 0; +#endif } static void get_cpu_usage(unsigned long long* total_cpu_time, @@ -74,15 +89,9 @@ static void get_cpu_usage(unsigned long long* total_cpu_time, } UsageTimer::Result UsageTimer::Sample() { - struct rusage usage; - struct timeval tv; - gettimeofday(&tv, NULL); - getrusage(RUSAGE_SELF, &usage); - Result r; - r.wall = time_double(&tv); - r.user = time_double(&usage.ru_utime); - r.system = time_double(&usage.ru_stime); + r.wall = Now(); + get_resource_usage(&r.user, &r.system); r.total_cpu_time = 0; r.idle_cpu_time = 0; get_cpu_usage(&r.total_cpu_time, &r.idle_cpu_time); diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc index 2068b7c213..e88d0647dd 100644 --- a/test/cpp/qps/worker.cc +++ b/test/cpp/qps/worker.cc @@ -31,7 +31,7 @@ * */ -#include <sys/signal.h> +#include <signal.h> #include <chrono> #include <thread> diff --git a/test/cpp/test/server_context_test_spouse_test.cc b/test/cpp/test/server_context_test_spouse_test.cc index e0d6a2ff67..eb279e2401 100644 --- a/test/cpp/test/server_context_test_spouse_test.cc +++ b/test/cpp/test/server_context_test_spouse_test.cc @@ -36,11 +36,14 @@ #include <cstring> #include <vector> +#include <grpc++/impl/grpc_library.h> #include <gtest/gtest.h> namespace grpc { namespace testing { +static internal::GrpcLibraryInitializer g_initializer; + const char key1[] = "metadata-key1"; const char key2[] = "metadata-key2"; const char val1[] = "metadata-val1"; diff --git a/test/cpp/thread_manager/thread_manager_test.cc b/test/cpp/thread_manager/thread_manager_test.cc index 284761c53a..35c8d5d088 100644 --- a/test/cpp/thread_manager/thread_manager_test.cc +++ b/test/cpp/thread_manager/thread_manager_test.cc @@ -31,6 +31,7 @@ *is % allowed in string */ +#include <ctime> #include <memory> #include <string> diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc index a02a8b2ee2..041cc0e4c3 100644 --- a/test/cpp/util/cli_call.cc +++ b/test/cpp/util/cli_call.cc @@ -37,8 +37,6 @@ #include <grpc++/channel.h> #include <grpc++/client_context.h> -#include <grpc++/completion_queue.h> -#include <grpc++/generic/generic_stub.h> #include <grpc++/support/byte_buffer.h> #include <grpc/grpc.h> #include <grpc/slice.h> @@ -56,55 +54,172 @@ Status CliCall::Call(std::shared_ptr<grpc::Channel> channel, const OutgoingMetadataContainer& metadata, IncomingMetadataContainer* server_initial_metadata, IncomingMetadataContainer* server_trailing_metadata) { - std::unique_ptr<grpc::GenericStub> stub(new grpc::GenericStub(channel)); - grpc::ClientContext ctx; + CliCall call(channel, method, metadata); + call.Write(request); + call.WritesDone(); + if (!call.Read(response, server_initial_metadata)) { + fprintf(stderr, "Failed to read response.\n"); + } + return call.Finish(server_trailing_metadata); +} + +CliCall::CliCall(std::shared_ptr<grpc::Channel> channel, + const grpc::string& method, + const OutgoingMetadataContainer& metadata) + : stub_(new grpc::GenericStub(channel)) { + gpr_mu_init(&write_mu_); + gpr_cv_init(&write_cv_); if (!metadata.empty()) { for (OutgoingMetadataContainer::const_iterator iter = metadata.begin(); iter != metadata.end(); ++iter) { - ctx.AddMetadata(iter->first, iter->second); + ctx_.AddMetadata(iter->first, iter->second); } } - grpc::CompletionQueue cq; - std::unique_ptr<grpc::GenericClientAsyncReaderWriter> call( - stub->Call(&ctx, method, &cq, tag(1))); + call_ = stub_->Call(&ctx_, method, &cq_, tag(1)); void* got_tag; bool ok; - cq.Next(&got_tag, &ok); + cq_.Next(&got_tag, &ok); GPR_ASSERT(ok); +} + +CliCall::~CliCall() { + gpr_cv_destroy(&write_cv_); + gpr_mu_destroy(&write_mu_); +} + +void CliCall::Write(const grpc::string& request) { + void* got_tag; + bool ok; grpc_slice s = grpc_slice_from_copied_string(request.c_str()); grpc::Slice req_slice(s, grpc::Slice::STEAL_REF); grpc::ByteBuffer send_buffer(&req_slice, 1); - call->Write(send_buffer, tag(2)); - cq.Next(&got_tag, &ok); - GPR_ASSERT(ok); - call->WritesDone(tag(3)); - cq.Next(&got_tag, &ok); + call_->Write(send_buffer, tag(2)); + cq_.Next(&got_tag, &ok); GPR_ASSERT(ok); +} + +bool CliCall::Read(grpc::string* response, + IncomingMetadataContainer* server_initial_metadata) { + void* got_tag; + bool ok; + grpc::ByteBuffer recv_buffer; - call->Read(&recv_buffer, tag(4)); - cq.Next(&got_tag, &ok); - if (!ok) { - std::cout << "Failed to read response." << std::endl; + call_->Read(&recv_buffer, tag(3)); + + if (!cq_.Next(&got_tag, &ok) || !ok) { + return false; } - grpc::Status status; - call->Finish(&status, tag(5)); - cq.Next(&got_tag, &ok); + std::vector<grpc::Slice> slices; + GPR_ASSERT(recv_buffer.Dump(&slices).ok()); + + response->clear(); + for (size_t i = 0; i < slices.size(); i++) { + response->append(reinterpret_cast<const char*>(slices[i].begin()), + slices[i].size()); + } + if (server_initial_metadata) { + *server_initial_metadata = ctx_.GetServerInitialMetadata(); + } + return true; +} + +void CliCall::WritesDone() { + void* got_tag; + bool ok; + + call_->WritesDone(tag(4)); + cq_.Next(&got_tag, &ok); GPR_ASSERT(ok); +} - if (status.ok()) { - std::vector<grpc::Slice> slices; - (void)recv_buffer.Dump(&slices); +void CliCall::WriteAndWait(const grpc::string& request) { + grpc_slice s = grpc_slice_from_copied_string(request.c_str()); + grpc::Slice req_slice(s, grpc::Slice::STEAL_REF); + grpc::ByteBuffer send_buffer(&req_slice, 1); + + gpr_mu_lock(&write_mu_); + call_->Write(send_buffer, tag(2)); + write_done_ = false; + while (!write_done_) { + gpr_cv_wait(&write_cv_, &write_mu_, gpr_inf_future(GPR_CLOCK_REALTIME)); + } + gpr_mu_unlock(&write_mu_); +} + +void CliCall::WritesDoneAndWait() { + gpr_mu_lock(&write_mu_); + call_->WritesDone(tag(4)); + write_done_ = false; + while (!write_done_) { + gpr_cv_wait(&write_cv_, &write_mu_, gpr_inf_future(GPR_CLOCK_REALTIME)); + } + gpr_mu_unlock(&write_mu_); +} - response->clear(); - for (size_t i = 0; i < slices.size(); i++) { - response->append(reinterpret_cast<const char*>(slices[i].begin()), - slices[i].size()); +bool CliCall::ReadAndMaybeNotifyWrite( + grpc::string* response, + IncomingMetadataContainer* server_initial_metadata) { + void* got_tag; + bool ok; + grpc::ByteBuffer recv_buffer; + + call_->Read(&recv_buffer, tag(3)); + bool cq_result = cq_.Next(&got_tag, &ok); + + while (got_tag != tag(3)) { + gpr_mu_lock(&write_mu_); + write_done_ = true; + gpr_cv_signal(&write_cv_); + gpr_mu_unlock(&write_mu_); + + cq_result = cq_.Next(&got_tag, &ok); + if (got_tag == tag(2)) { + GPR_ASSERT(ok); } } - *server_initial_metadata = ctx.GetServerInitialMetadata(); - *server_trailing_metadata = ctx.GetServerTrailingMetadata(); + if (!cq_result || !ok) { + // If the RPC is ended on the server side, we should still wait for the + // pending write on the client side to be done. + if (!ok) { + gpr_mu_lock(&write_mu_); + if (!write_done_) { + cq_.Next(&got_tag, &ok); + GPR_ASSERT(got_tag != tag(2)); + write_done_ = true; + gpr_cv_signal(&write_cv_); + } + gpr_mu_unlock(&write_mu_); + } + return false; + } + + std::vector<grpc::Slice> slices; + GPR_ASSERT(recv_buffer.Dump(&slices).ok()); + response->clear(); + for (size_t i = 0; i < slices.size(); i++) { + response->append(reinterpret_cast<const char*>(slices[i].begin()), + slices[i].size()); + } + if (server_initial_metadata) { + *server_initial_metadata = ctx_.GetServerInitialMetadata(); + } + return true; +} + +Status CliCall::Finish(IncomingMetadataContainer* server_trailing_metadata) { + void* got_tag; + bool ok; + grpc::Status status; + + call_->Finish(&status, tag(5)); + cq_.Next(&got_tag, &ok); + GPR_ASSERT(ok); + if (server_trailing_metadata) { + *server_trailing_metadata = ctx_.GetServerTrailingMetadata(); + } + return status; } diff --git a/test/cpp/util/cli_call.h b/test/cpp/util/cli_call.h index 65da86bd4e..91f0dbc9ed 100644 --- a/test/cpp/util/cli_call.h +++ b/test/cpp/util/cli_call.h @@ -37,23 +37,74 @@ #include <map> #include <grpc++/channel.h> +#include <grpc++/completion_queue.h> +#include <grpc++/generic/generic_stub.h> #include <grpc++/support/status.h> #include <grpc++/support/string_ref.h> namespace grpc { + +class ClientContext; + namespace testing { +// CliCall handles the sending and receiving of generic messages given the name +// of the remote method. This class is only used by GrpcTool. Its thread-safe +// and thread-unsafe methods should not be used together. class CliCall final { public: typedef std::multimap<grpc::string, grpc::string> OutgoingMetadataContainer; typedef std::multimap<grpc::string_ref, grpc::string_ref> IncomingMetadataContainer; + + CliCall(std::shared_ptr<grpc::Channel> channel, const grpc::string& method, + const OutgoingMetadataContainer& metadata); + ~CliCall(); + + // Perform an unary generic RPC. static Status Call(std::shared_ptr<grpc::Channel> channel, const grpc::string& method, const grpc::string& request, grpc::string* response, const OutgoingMetadataContainer& metadata, IncomingMetadataContainer* server_initial_metadata, IncomingMetadataContainer* server_trailing_metadata); + + // Send a generic request message in a synchronous manner. NOT thread-safe. + void Write(const grpc::string& request); + + // Send a generic request message in a synchronous manner. NOT thread-safe. + void WritesDone(); + + // Receive a generic response message in a synchronous manner.NOT thread-safe. + bool Read(grpc::string* response, + IncomingMetadataContainer* server_initial_metadata); + + // Thread-safe write. Must be used with ReadAndMaybeNotifyWrite. Send out a + // generic request message and wait for ReadAndMaybeNotifyWrite to finish it. + void WriteAndWait(const grpc::string& request); + + // Thread-safe WritesDone. Must be used with ReadAndMaybeNotifyWrite. Send out + // WritesDone for gereneric request messages and wait for + // ReadAndMaybeNotifyWrite to finish it. + void WritesDoneAndWait(); + + // Thread-safe Read. Blockingly receive a generic response message. Notify + // writes if they are finished when this read is waiting for a resposne. + bool ReadAndMaybeNotifyWrite( + grpc::string* response, + IncomingMetadataContainer* server_initial_metadata); + + // Finish the RPC. + Status Finish(IncomingMetadataContainer* server_trailing_metadata); + + private: + std::unique_ptr<grpc::GenericStub> stub_; + grpc::ClientContext ctx_; + std::unique_ptr<grpc::GenericClientAsyncReaderWriter> call_; + grpc::CompletionQueue cq_; + gpr_mu write_mu_; + gpr_cv write_cv_; // Protected by write_mu_; + bool write_done_; // Portected by write_mu_; }; } // namespace testing diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc index fe8b5d5423..ad62e03490 100644 --- a/test/cpp/util/create_test_channel.cc +++ b/test/cpp/util/create_test_channel.cc @@ -35,11 +35,37 @@ #include <grpc++/create_channel.h> #include <grpc++/security/credentials.h> +#include <grpc/support/log.h> -#include "test/core/end2end/data/ssl_test_data.h" +#include "test/cpp/util/test_credentials_provider.h" namespace grpc { +namespace { + +const char kProdTlsCredentialsType[] = "prod_ssl"; + +class SslCredentialProvider : public testing::CredentialTypeProvider { + public: + std::shared_ptr<ChannelCredentials> GetChannelCredentials( + grpc::ChannelArguments* args) override { + return SslCredentials(SslCredentialsOptions()); + } + std::shared_ptr<ServerCredentials> GetServerCredentials() override { + return nullptr; + } +}; + +gpr_once g_once_init_add_prod_ssl_provider = GPR_ONCE_INIT; +// Register ssl with non-test roots type to the credentials provider. +void AddProdSslType() { + testing::GetCredentialsProvider()->AddSecureType( + kProdTlsCredentialsType, std::unique_ptr<testing::CredentialTypeProvider>( + new SslCredentialProvider)); +} + +} // namespace + // When ssl is enabled, if server is empty, override_hostname is used to // create channel. Otherwise, connect to server and override hostname if // override_hostname is provided. @@ -61,16 +87,22 @@ std::shared_ptr<Channel> CreateTestChannel( const std::shared_ptr<CallCredentials>& creds, const ChannelArguments& args) { ChannelArguments channel_args(args); + std::shared_ptr<ChannelCredentials> channel_creds; if (enable_ssl) { - const char* roots_certs = use_prod_roots ? "" : test_root_cert; - SslCredentialsOptions ssl_opts = {roots_certs, "", ""}; - - std::shared_ptr<ChannelCredentials> channel_creds = - SslCredentials(ssl_opts); - - if (!server.empty() && !override_hostname.empty()) { - channel_args.SetSslTargetNameOverride(override_hostname); + if (use_prod_roots) { + gpr_once_init(&g_once_init_add_prod_ssl_provider, &AddProdSslType); + channel_creds = testing::GetCredentialsProvider()->GetChannelCredentials( + kProdTlsCredentialsType, &channel_args); + if (!server.empty() && !override_hostname.empty()) { + channel_args.SetSslTargetNameOverride(override_hostname); + } + } else { + // override_hostname is discarded as the provider handles it. + channel_creds = testing::GetCredentialsProvider()->GetChannelCredentials( + testing::kTlsCredentialsType, &channel_args); } + GPR_ASSERT(channel_creds != nullptr); + const grpc::string& connect_to = server.empty() ? override_hostname : server; if (creds.get()) { @@ -103,4 +135,18 @@ std::shared_ptr<Channel> CreateTestChannel(const grpc::string& server, return CreateTestChannel(server, "foo.test.google.fr", enable_ssl, false); } +std::shared_ptr<Channel> CreateTestChannel( + const grpc::string& server, const grpc::string& credential_type, + const std::shared_ptr<CallCredentials>& creds) { + ChannelArguments channel_args; + std::shared_ptr<ChannelCredentials> channel_creds = + testing::GetCredentialsProvider()->GetChannelCredentials(credential_type, + &channel_args); + GPR_ASSERT(channel_creds != nullptr); + if (creds.get()) { + channel_creds = CompositeChannelCredentials(channel_creds, creds); + } + return CreateCustomChannel(server, channel_creds, channel_args); +} + } // namespace grpc diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index 4ff666dc1b..ce71a97edb 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -59,6 +59,10 @@ std::shared_ptr<Channel> CreateTestChannel( const std::shared_ptr<CallCredentials>& creds, const ChannelArguments& args); +std::shared_ptr<Channel> CreateTestChannel( + const grpc::string& server, const grpc::string& credential_type, + const std::shared_ptr<CallCredentials>& creds); + } // namespace grpc #endif // GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H diff --git a/test/cpp/util/grpc_cli.cc b/test/cpp/util/grpc_cli.cc index fe248601ee..a78bed4b90 100644 --- a/test/cpp/util/grpc_cli.cc +++ b/test/cpp/util/grpc_cli.cc @@ -83,10 +83,10 @@ DEFINE_string(outfile, "", "Output file (default is stdout)"); static bool SimplePrint(const grpc::string& outfile, const grpc::string& output) { if (outfile.empty()) { - std::cout << output; + std::cout << output << std::endl; } else { - std::ofstream output_file(outfile, std::ios::trunc | std::ios::binary); - output_file << output; + std::ofstream output_file(outfile, std::ios::app | std::ios::binary); + output_file << output << std::endl; output_file.close(); } return true; diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc index b9900ca1b7..856cd32c3c 100644 --- a/test/cpp/util/grpc_tool.cc +++ b/test/cpp/util/grpc_tool.cc @@ -33,12 +33,13 @@ #include "test/cpp/util/grpc_tool.h" -#include <unistd.h> +#include <cstdio> #include <fstream> #include <iostream> #include <memory> #include <sstream> #include <string> +#include <thread> #include <gflags/gflags.h> #include <grpc++/channel.h> @@ -47,12 +48,19 @@ #include <grpc++/security/credentials.h> #include <grpc++/support/string_ref.h> #include <grpc/grpc.h> +#include <grpc/support/port_platform.h> #include "test/cpp/util/cli_call.h" #include "test/cpp/util/proto_file_parser.h" #include "test/cpp/util/proto_reflection_descriptor_database.h" #include "test/cpp/util/service_describer.h" +#if GPR_WINDOWS +#include <io.h> +#else +#include <unistd.h> +#endif + namespace grpc { namespace testing { @@ -159,6 +167,36 @@ void PrintMetadata(const T& m, const grpc::string& message) { } } +void ReadResponse(CliCall* call, const grpc::string& method_name, + GrpcToolOutputCallback callback, ProtoFileParser* parser, + gpr_mu* parser_mu, bool print_mode) { + grpc::string serialized_response_proto; + std::multimap<grpc::string_ref, grpc::string_ref> server_initial_metadata; + + for (bool receive_initial_metadata = true; call->ReadAndMaybeNotifyWrite( + &serialized_response_proto, + receive_initial_metadata ? &server_initial_metadata : nullptr); + receive_initial_metadata = false) { + fprintf(stderr, "got response.\n"); + if (!FLAGS_binary_output) { + gpr_mu_lock(parser_mu); + serialized_response_proto = parser->GetTextFormatFromMethod( + method_name, serialized_response_proto, false /* is_request */); + if (parser->HasError() && print_mode) { + fprintf(stderr, "Failed to parse response.\n"); + } + gpr_mu_unlock(parser_mu); + } + if (receive_initial_metadata) { + PrintMetadata(server_initial_metadata, + "Received initial metadata from server:"); + } + if (!callback(serialized_response_proto) && print_mode) { + fprintf(stderr, "Failed to output response.\n"); + } + } +} + struct Command { const char* command; std::function<bool(GrpcTool*, int, const char**, const CliCredentials&, @@ -416,85 +454,191 @@ bool GrpcTool::CallMethod(int argc, const char** argv, grpc::string server_address(argv[0]); grpc::string method_name(argv[1]); grpc::string formatted_method_name; - std::unique_ptr<grpc::testing::ProtoFileParser> parser; + std::unique_ptr<ProtoFileParser> parser; grpc::string serialized_request_proto; + bool print_mode = false; - if (argc == 3) { - request_text = argv[2]; - if (!FLAGS_infile.empty()) { - fprintf(stderr, "warning: request given in argv, ignoring --infile\n"); - } + std::shared_ptr<grpc::Channel> channel = + FLAGS_remotedb + ? grpc::CreateChannel(server_address, cred.GetCredentials()) + : nullptr; + + parser.reset(new grpc::testing::ProtoFileParser(channel, FLAGS_proto_path, + FLAGS_protofiles)); + + if (FLAGS_binary_input) { + formatted_method_name = method_name; } else { - std::stringstream input_stream; + formatted_method_name = parser->GetFormattedMethodName(method_name); + } + + if (parser->HasError()) { + return false; + } + + if (parser->IsStreaming(method_name, true /* is_request */)) { + std::istream* input_stream; + std::ifstream input_file; + + if (argc == 3) { + request_text = argv[2]; + } + + std::multimap<grpc::string, grpc::string> client_metadata; + ParseMetadataFlag(&client_metadata); + PrintMetadata(client_metadata, "Sending client initial metadata:"); + + CliCall call(channel, formatted_method_name, client_metadata); + if (FLAGS_infile.empty()) { - if (isatty(STDIN_FILENO)) { - fprintf(stderr, "reading request message from stdin...\n"); + if (isatty(fileno(stdin))) { + print_mode = true; + fprintf(stderr, "reading streaming request message from stdin...\n"); } - input_stream << std::cin.rdbuf(); + input_stream = &std::cin; } else { - std::ifstream input_file(FLAGS_infile, std::ios::in | std::ios::binary); - input_stream << input_file.rdbuf(); + input_file.open(FLAGS_infile, std::ios::in | std::ios::binary); + input_stream = &input_file; + } + + gpr_mu parser_mu; + gpr_mu_init(&parser_mu); + std::thread read_thread(ReadResponse, &call, method_name, callback, + parser.get(), &parser_mu, print_mode); + + std::stringstream request_ss; + grpc::string line; + while (!request_text.empty() || + (!input_stream->eof() && getline(*input_stream, line))) { + if (!request_text.empty()) { + if (FLAGS_binary_input) { + serialized_request_proto = request_text; + request_text.clear(); + } else { + gpr_mu_lock(&parser_mu); + serialized_request_proto = parser->GetSerializedProtoFromMethod( + method_name, request_text, true /* is_request */); + request_text.clear(); + if (parser->HasError()) { + if (print_mode) { + fprintf(stderr, "Failed to parse request.\n"); + } + gpr_mu_unlock(&parser_mu); + continue; + } + gpr_mu_unlock(&parser_mu); + } + + call.WriteAndWait(serialized_request_proto); + if (print_mode) { + fprintf(stderr, "Request sent.\n"); + } + } else { + if (line.length() == 0) { + request_text = request_ss.str(); + request_ss.str(grpc::string()); + request_ss.clear(); + } else { + request_ss << line << ' '; + } + } + } + if (input_file.is_open()) { input_file.close(); } - request_text = input_stream.str(); - } - std::shared_ptr<grpc::Channel> channel = - grpc::CreateChannel(server_address, cred.GetCredentials()); - if (!FLAGS_binary_input || !FLAGS_binary_output) { - parser.reset( - new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr, - FLAGS_proto_path, FLAGS_protofiles)); - if (parser->HasError()) { + call.WritesDoneAndWait(); + read_thread.join(); + + std::multimap<grpc::string_ref, grpc::string_ref> server_trailing_metadata; + Status status = call.Finish(&server_trailing_metadata); + PrintMetadata(server_trailing_metadata, + "Received trailing metadata from server:"); + + if (status.ok()) { + fprintf(stderr, "Stream RPC succeeded with OK status\n"); + return true; + } else { + fprintf(stderr, "Rpc failed with status code %d, error message: %s\n", + status.error_code(), status.error_message().c_str()); return false; } - } - if (FLAGS_binary_input) { - serialized_request_proto = request_text; - formatted_method_name = method_name; - } else { - formatted_method_name = parser->GetFormattedMethodName(method_name); - serialized_request_proto = parser->GetSerializedProtoFromMethod( - method_name, request_text, true /* is_request */); - if (parser->HasError()) { - return false; + } else { // parser->IsStreaming(method_name, true /* is_request */) + if (argc == 3) { + request_text = argv[2]; + if (!FLAGS_infile.empty()) { + fprintf(stderr, "warning: request given in argv, ignoring --infile\n"); + } + } else { + std::stringstream input_stream; + if (FLAGS_infile.empty()) { + if (isatty(fileno(stdin))) { + fprintf(stderr, "reading request message from stdin...\n"); + } + input_stream << std::cin.rdbuf(); + } else { + std::ifstream input_file(FLAGS_infile, std::ios::in | std::ios::binary); + input_stream << input_file.rdbuf(); + input_file.close(); + } + request_text = input_stream.str(); } - } - fprintf(stderr, "connecting to %s\n", server_address.c_str()); - grpc::string serialized_response_proto; - std::multimap<grpc::string, grpc::string> client_metadata; - std::multimap<grpc::string_ref, grpc::string_ref> server_initial_metadata, - server_trailing_metadata; - ParseMetadataFlag(&client_metadata); - PrintMetadata(client_metadata, "Sending client initial metadata:"); - grpc::Status status = grpc::testing::CliCall::Call( - channel, formatted_method_name, serialized_request_proto, - &serialized_response_proto, client_metadata, &server_initial_metadata, - &server_trailing_metadata); - PrintMetadata(server_initial_metadata, - "Received initial metadata from server:"); - PrintMetadata(server_trailing_metadata, - "Received trailing metadata from server:"); - if (status.ok()) { - fprintf(stderr, "Rpc succeeded with OK status\n"); - if (FLAGS_binary_output) { - output_ss << serialized_response_proto; + if (FLAGS_binary_input) { + serialized_request_proto = request_text; + // formatted_method_name = method_name; } else { - grpc::string response_text = parser->GetTextFormatFromMethod( - method_name, serialized_response_proto, false /* is_request */); + // formatted_method_name = parser->GetFormattedMethodName(method_name); + serialized_request_proto = parser->GetSerializedProtoFromMethod( + method_name, request_text, true /* is_request */); if (parser->HasError()) { return false; } - output_ss << "Response: \n " << response_text << std::endl; } - } else { - fprintf(stderr, "Rpc failed with status code %d, error message: %s\n", - status.error_code(), status.error_message().c_str()); + fprintf(stderr, "connecting to %s\n", server_address.c_str()); + + grpc::string serialized_response_proto; + std::multimap<grpc::string, grpc::string> client_metadata; + std::multimap<grpc::string_ref, grpc::string_ref> server_initial_metadata, + server_trailing_metadata; + ParseMetadataFlag(&client_metadata); + PrintMetadata(client_metadata, "Sending client initial metadata:"); + + CliCall call(channel, formatted_method_name, client_metadata); + call.Write(serialized_request_proto); + call.WritesDone(); + + for (bool receive_initial_metadata = true; call.Read( + &serialized_response_proto, + receive_initial_metadata ? &server_initial_metadata : nullptr); + receive_initial_metadata = false) { + if (!FLAGS_binary_output) { + serialized_response_proto = parser->GetTextFormatFromMethod( + method_name, serialized_response_proto, false /* is_request */); + if (parser->HasError()) { + return false; + } + } + if (receive_initial_metadata) { + PrintMetadata(server_initial_metadata, + "Received initial metadata from server:"); + } + if (!callback(serialized_response_proto)) { + return false; + } + } + Status status = call.Finish(&server_trailing_metadata); + if (status.ok()) { + fprintf(stderr, "Rpc succeeded with OK status\n"); + return true; + } else { + fprintf(stderr, "Rpc failed with status code %d, error message: %s\n", + status.error_code(), status.error_message().c_str()); + return false; + } } - - return callback(output_ss.str()); + GPR_UNREACHABLE_CODE(return false); } bool GrpcTool::ParseMessage(int argc, const char** argv, @@ -531,7 +675,7 @@ bool GrpcTool::ParseMessage(int argc, const char** argv, } else { std::stringstream input_stream; if (FLAGS_infile.empty()) { - if (isatty(STDIN_FILENO)) { + if (isatty(fileno(stdin))) { fprintf(stderr, "reading request message from stdin...\n"); } input_stream << std::cin.rdbuf(); diff --git a/test/cpp/util/grpc_tool_test.cc b/test/cpp/util/grpc_tool_test.cc index 33ce611a60..26e2b1f502 100644 --- a/test/cpp/util/grpc_tool_test.cc +++ b/test/cpp/util/grpc_tool_test.cc @@ -102,6 +102,8 @@ DECLARE_bool(l); namespace { +const int kNumResponseStreamsMsgs = 3; + class TestCliCredentials final : public grpc::testing::CliCredentials { public: std::shared_ptr<grpc::ChannelCredentials> GetCredentials() const override { @@ -137,6 +139,71 @@ class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { response->set_message(request->message()); return Status::OK; } + + Status RequestStream(ServerContext* context, + ServerReader<EchoRequest>* reader, + EchoResponse* response) override { + EchoRequest request; + response->set_message(""); + if (!context->client_metadata().empty()) { + for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator + iter = context->client_metadata().begin(); + iter != context->client_metadata().end(); ++iter) { + context->AddInitialMetadata(ToString(iter->first), + ToString(iter->second)); + } + } + context->AddTrailingMetadata("trailing_key", "trailing_value"); + while (reader->Read(&request)) { + response->mutable_message()->append(request.message()); + } + + return Status::OK; + } + + Status ResponseStream(ServerContext* context, const EchoRequest* request, + ServerWriter<EchoResponse>* writer) override { + if (!context->client_metadata().empty()) { + for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator + iter = context->client_metadata().begin(); + iter != context->client_metadata().end(); ++iter) { + context->AddInitialMetadata(ToString(iter->first), + ToString(iter->second)); + } + } + context->AddTrailingMetadata("trailing_key", "trailing_value"); + + EchoResponse response; + for (int i = 0; i < kNumResponseStreamsMsgs; i++) { + response.set_message(request->message() + grpc::to_string(i)); + writer->Write(response); + } + + return Status::OK; + } + + Status BidiStream( + ServerContext* context, + ServerReaderWriter<EchoResponse, EchoRequest>* stream) override { + EchoRequest request; + EchoResponse response; + if (!context->client_metadata().empty()) { + for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator + iter = context->client_metadata().begin(); + iter != context->client_metadata().end(); ++iter) { + context->AddInitialMetadata(ToString(iter->first), + ToString(iter->second)); + } + } + context->AddTrailingMetadata("trailing_key", "trailing_value"); + + while (stream->Read(&request)) { + response.set_message(request.message()); + stream->Write(response); + } + + return Status::OK; + } }; } // namespace @@ -347,6 +414,132 @@ TEST_F(GrpcToolTest, CallCommand) { ShutdownServer(); } +TEST_F(GrpcToolTest, CallCommandRequestStream) { + // Test input: grpc_cli call localhost:<port> RequestStream "message: + // 'Hello0'" + std::stringstream output_stream; + + const grpc::string server_address = SetUpServer(); + const char* argv[] = {"grpc_cli", "call", server_address.c_str(), + "RequestStream", "message: 'Hello0'"}; + + // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n" + std::streambuf* orig = std::cin.rdbuf(); + std::istringstream ss("message: 'Hello1'\n\n message: 'Hello2'\n\n"); + std::cin.rdbuf(ss.rdbuf()); + + EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), + std::bind(PrintStream, &output_stream, + std::placeholders::_1))); + + // Expected output: "message: \"Hello0Hello1Hello2\"" + EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(), + "message: \"Hello0Hello1Hello2\"")); + std::cin.rdbuf(orig); + ShutdownServer(); +} + +TEST_F(GrpcToolTest, CallCommandRequestStreamWithBadRequest) { + // Test input: grpc_cli call localhost:<port> RequestStream "message: + // 'Hello0'" + std::stringstream output_stream; + + const grpc::string server_address = SetUpServer(); + const char* argv[] = {"grpc_cli", "call", server_address.c_str(), + "RequestStream", "message: 'Hello0'"}; + + // Mock std::cin input "bad_field: 'Hello1'\n\n message: 'Hello2'\n\n" + std::streambuf* orig = std::cin.rdbuf(); + std::istringstream ss("bad_field: 'Hello1'\n\n message: 'Hello2'\n\n"); + std::cin.rdbuf(ss.rdbuf()); + + EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), + std::bind(PrintStream, &output_stream, + std::placeholders::_1))); + + // Expected output: "message: \"Hello0Hello2\"" + EXPECT_TRUE(NULL != + strstr(output_stream.str().c_str(), "message: \"Hello0Hello2\"")); + std::cin.rdbuf(orig); + ShutdownServer(); +} + +TEST_F(GrpcToolTest, CallCommandResponseStream) { + // Test input: grpc_cli call localhost:<port> ResponseStream "message: + // 'Hello'" + std::stringstream output_stream; + + const grpc::string server_address = SetUpServer(); + const char* argv[] = {"grpc_cli", "call", server_address.c_str(), + "ResponseStream", "message: 'Hello'"}; + + EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), + std::bind(PrintStream, &output_stream, + std::placeholders::_1))); + + // Expected output: "message: \"Hello{n}\"" + for (int i = 0; i < kNumResponseStreamsMsgs; i++) { + grpc::string expected_response_text = + "message: \"Hello" + grpc::to_string(i) + "\"\n"; + EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(), + expected_response_text.c_str())); + } + + ShutdownServer(); +} + +TEST_F(GrpcToolTest, CallCommandBidiStream) { + // Test input: grpc_cli call localhost:<port> BidiStream "message: 'Hello0'" + std::stringstream output_stream; + + const grpc::string server_address = SetUpServer(); + const char* argv[] = {"grpc_cli", "call", server_address.c_str(), + "BidiStream", "message: 'Hello0'"}; + + // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n" + std::streambuf* orig = std::cin.rdbuf(); + std::istringstream ss("message: 'Hello1'\n\n message: 'Hello2'\n\n"); + std::cin.rdbuf(ss.rdbuf()); + + EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), + std::bind(PrintStream, &output_stream, + std::placeholders::_1))); + + // Expected output: "message: \"Hello0\"\nmessage: \"Hello1\"\nmessage: + // \"Hello2\"\n\n" + EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(), + "message: \"Hello0\"\nmessage: " + "\"Hello1\"\nmessage: \"Hello2\"\n")); + std::cin.rdbuf(orig); + ShutdownServer(); +} + +TEST_F(GrpcToolTest, CallCommandBidiStreamWithBadRequest) { + // Test input: grpc_cli call localhost:<port> BidiStream "message: 'Hello0'" + std::stringstream output_stream; + + const grpc::string server_address = SetUpServer(); + const char* argv[] = {"grpc_cli", "call", server_address.c_str(), + "BidiStream", "message: 'Hello0'"}; + + // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n" + std::streambuf* orig = std::cin.rdbuf(); + std::istringstream ss("message: 1.0\n\n message: 'Hello2'\n\n"); + std::cin.rdbuf(ss.rdbuf()); + + EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), + std::bind(PrintStream, &output_stream, + std::placeholders::_1))); + + // Expected output: "message: \"Hello0\"\nmessage: \"Hello1\"\nmessage: + // \"Hello2\"\n\n" + EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(), + "message: \"Hello0\"\nmessage: \"Hello2\"\n")); + std::cin.rdbuf(orig); + + ShutdownServer(); +} + TEST_F(GrpcToolTest, ParseCommand) { // Test input "grpc_cli parse localhost:<port> grpc.testing.EchoResponse // ECHO_RESPONSE_MESSAGE" diff --git a/test/cpp/util/proto_file_parser.cc b/test/cpp/util/proto_file_parser.cc index bc8a6083f4..5dd1b00e8a 100644 --- a/test/cpp/util/proto_file_parser.cc +++ b/test/cpp/util/proto_file_parser.cc @@ -81,7 +81,8 @@ class ErrorPrinter : public protobuf::compiler::MultiFileErrorCollector { ProtoFileParser::ProtoFileParser(std::shared_ptr<grpc::Channel> channel, const grpc::string& proto_path, const grpc::string& protofiles) - : has_error_(false) { + : has_error_(false), + dynamic_factory_(new protobuf::DynamicMessageFactory()) { std::vector<grpc::string> service_list; if (channel) { reflection_db_.reset(new grpc::ProtoReflectionDescriptorDatabase(channel)); @@ -127,7 +128,6 @@ ProtoFileParser::ProtoFileParser(std::shared_ptr<grpc::Channel> channel, } desc_pool_.reset(new protobuf::DescriptorPool(desc_db_.get())); - dynamic_factory_.reset(new protobuf::DynamicMessageFactory(desc_pool_.get())); for (auto it = service_list.begin(); it != service_list.end(); it++) { if (known_services.find(*it) == known_services.end()) { @@ -144,6 +144,11 @@ ProtoFileParser::~ProtoFileParser() {} grpc::string ProtoFileParser::GetFullMethodName(const grpc::string& method) { has_error_ = false; + + if (known_methods_.find(method) != known_methods_.end()) { + return known_methods_[method]; + } + const protobuf::MethodDescriptor* method_descriptor = nullptr; for (auto it = service_desc_list_.begin(); it != service_desc_list_.end(); it++) { @@ -169,6 +174,8 @@ grpc::string ProtoFileParser::GetFullMethodName(const grpc::string& method) { return ""; } + known_methods_[method] = method_descriptor->full_name(); + return method_descriptor->full_name(); } @@ -205,6 +212,25 @@ grpc::string ProtoFileParser::GetMessageTypeFromMethod( : method_desc->output_type()->full_name(); } +bool ProtoFileParser::IsStreaming(const grpc::string& method, bool is_request) { + has_error_ = false; + + grpc::string full_method_name = GetFullMethodName(method); + if (has_error_) { + return false; + } + + const protobuf::MethodDescriptor* method_desc = + desc_pool_->FindMethodByName(full_method_name); + if (!method_desc) { + LogError("Method not found"); + return false; + } + + return is_request ? method_desc->client_streaming() + : method_desc->server_streaming(); +} + grpc::string ProtoFileParser::GetSerializedProtoFromMethod( const grpc::string& method, const grpc::string& text_format_proto, bool is_request) { diff --git a/test/cpp/util/proto_file_parser.h b/test/cpp/util/proto_file_parser.h index c1070a37b5..23d311ef8f 100644 --- a/test/cpp/util/proto_file_parser.h +++ b/test/cpp/util/proto_file_parser.h @@ -84,6 +84,8 @@ class ProtoFileParser { const grpc::string& message_type_name, const grpc::string& serialized_proto); + bool IsStreaming(const grpc::string& method, bool is_request); + bool HasError() const { return has_error_; } void LogError(const grpc::string& error_msg); @@ -104,6 +106,7 @@ class ProtoFileParser { std::unique_ptr<protobuf::DynamicMessageFactory> dynamic_factory_; std::unique_ptr<grpc::protobuf::Message> request_prototype_; std::unique_ptr<grpc::protobuf::Message> response_prototype_; + std::unordered_map<grpc::string, grpc::string> known_methods_; std::vector<const protobuf::ServiceDescriptor*> service_desc_list_; }; diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc index 0456b96667..909b02a701 100644 --- a/test/cpp/util/test_credentials_provider.cc +++ b/test/cpp/util/test_credentials_provider.cc @@ -43,25 +43,9 @@ #include "test/core/end2end/data/ssl_test_data.h" namespace grpc { +namespace testing { namespace { -using grpc::testing::CredentialTypeProvider; - -// Provide test credentials. Thread-safe. -class CredentialsProvider { - public: - virtual ~CredentialsProvider() {} - - virtual void AddSecureType( - const grpc::string& type, - std::unique_ptr<CredentialTypeProvider> type_provider) = 0; - virtual std::shared_ptr<ChannelCredentials> GetChannelCredentials( - const grpc::string& type, ChannelArguments* args) = 0; - virtual std::shared_ptr<ServerCredentials> GetServerCredentials( - const grpc::string& type) = 0; - virtual std::vector<grpc::string> GetSecureCredentialsTypeList() = 0; -}; - class DefaultCredentialsProvider : public CredentialsProvider { public: ~DefaultCredentialsProvider() override {} @@ -145,37 +129,21 @@ class DefaultCredentialsProvider : public CredentialsProvider { added_secure_type_providers_; }; -gpr_once g_once_init_provider = GPR_ONCE_INIT; CredentialsProvider* g_provider = nullptr; -void CreateDefaultProvider() { g_provider = new DefaultCredentialsProvider; } - -CredentialsProvider* GetProvider() { - gpr_once_init(&g_once_init_provider, &CreateDefaultProvider); - return g_provider; -} - } // namespace -namespace testing { - -void AddSecureType(const grpc::string& type, - std::unique_ptr<CredentialTypeProvider> type_provider) { - GetProvider()->AddSecureType(type, std::move(type_provider)); -} - -std::shared_ptr<ChannelCredentials> GetChannelCredentials( - const grpc::string& type, ChannelArguments* args) { - return GetProvider()->GetChannelCredentials(type, args); -} - -std::shared_ptr<ServerCredentials> GetServerCredentials( - const grpc::string& type) { - return GetProvider()->GetServerCredentials(type); +CredentialsProvider* GetCredentialsProvider() { + if (g_provider == nullptr) { + g_provider = new DefaultCredentialsProvider; + } + return g_provider; } -std::vector<grpc::string> GetSecureCredentialsTypeList() { - return GetProvider()->GetSecureCredentialsTypeList(); +void SetCredentialsProvider(CredentialsProvider* provider) { + // For now, forbids overriding provider. + GPR_ASSERT(g_provider == nullptr); + g_provider = provider; } } // namespace testing diff --git a/test/cpp/util/test_credentials_provider.h b/test/cpp/util/test_credentials_provider.h index 1fb311e556..0bc52ebe4d 100644 --- a/test/cpp/util/test_credentials_provider.h +++ b/test/cpp/util/test_credentials_provider.h @@ -59,23 +59,39 @@ class CredentialTypeProvider { virtual std::shared_ptr<ServerCredentials> GetServerCredentials() = 0; }; -// Add a secure type in addition to the defaults above -// (kInsecureCredentialsType, kTlsCredentialsType) that can be returned from the -// functions below. -void AddSecureType(const grpc::string& type, - std::unique_ptr<CredentialTypeProvider> type_provider); - -// Provide channel credentials according to the given type. Alter the channel -// arguments if needed. -std::shared_ptr<ChannelCredentials> GetChannelCredentials( - const grpc::string& type, ChannelArguments* args); - -// Provide server credentials according to the given type. -std::shared_ptr<ServerCredentials> GetServerCredentials( - const grpc::string& type); - -// Provide a list of secure credentials type. -std::vector<grpc::string> GetSecureCredentialsTypeList(); +// Provide test credentials. Thread-safe. +class CredentialsProvider { + public: + virtual ~CredentialsProvider() {} + + // Add a secure type in addition to the defaults. The default provider has + // (kInsecureCredentialsType, kTlsCredentialsType). + virtual void AddSecureType( + const grpc::string& type, + std::unique_ptr<CredentialTypeProvider> type_provider) = 0; + + // Provide channel credentials according to the given type. Alter the channel + // arguments if needed. Return nullptr if type is not registered. + virtual std::shared_ptr<ChannelCredentials> GetChannelCredentials( + const grpc::string& type, ChannelArguments* args) = 0; + + // Provide server credentials according to the given type. + // Return nullptr if type is not registered. + virtual std::shared_ptr<ServerCredentials> GetServerCredentials( + const grpc::string& type) = 0; + + // Provide a list of secure credentials type. + virtual std::vector<grpc::string> GetSecureCredentialsTypeList() = 0; +}; + +// Get the current provider. Create a default one if not set. +// Not thread-safe. +CredentialsProvider* GetCredentialsProvider(); + +// Set the global provider. Takes ownership. The previous set provider will be +// destroyed. +// Not thread-safe. +void SetCredentialsProvider(CredentialsProvider* provider); } // namespace testing } // namespace grpc diff --git a/test/http2_test/http2_base_server.py b/test/http2_test/http2_base_server.py index ee7719b1a8..8de028ceb1 100644 --- a/test/http2_test/http2_base_server.py +++ b/test/http2_test/http2_base_server.py @@ -73,7 +73,6 @@ class H2ProtocolBaseServer(twisted.internet.protocol.Protocol): def on_connection_lost(self, reason): logging.info('Disconnected %s' % reason) - twisted.internet.reactor.callFromThread(twisted.internet.reactor.stop) def dataReceived(self, data): try: diff --git a/test/http2_test/http2_test_server.py b/test/http2_test/http2_test_server.py index 44e36d34b6..abde3433ad 100644 --- a/test/http2_test/http2_test_server.py +++ b/test/http2_test/http2_test_server.py @@ -73,18 +73,32 @@ class H2Factory(twisted.internet.protocol.Factory): else: return t().get_base_server() +def parse_arguments(): + parser = argparse.ArgumentParser() + parser.add_argument('--base_port', type=int, default=8080, + help='base port to run the servers (default: 8080). One test server is ' + 'started on each incrementing port, beginning with base_port, in the ' + 'following order: goaway,max_streams,ping,rst_after_data,rst_after_header,' + 'rst_during_data' + ) + return parser.parse_args() + +def start_test_servers(base_port): + """ Start one server per test case on incrementing port numbers + beginning with base_port """ + index = 0 + for test_case in sorted(_TEST_CASE_MAPPING.keys()): + portnum = base_port + index + logging.warning('serving on port %d : %s'%(portnum, test_case)) + endpoint = twisted.internet.endpoints.TCP4ServerEndpoint( + twisted.internet.reactor, portnum, backlog=128) + endpoint.listen(H2Factory(test_case)) + index += 1 + if __name__ == '__main__': logging.basicConfig( format='%(levelname) -10s %(asctime)s %(module)s:%(lineno)s | %(message)s', level=logging.INFO) - parser = argparse.ArgumentParser() - parser.add_argument('--test_case', choices=sorted(_TEST_CASE_MAPPING.keys()), - help='test case to run', required=True) - parser.add_argument('--port', type=int, default=8080, - help='port to run the server (default: 8080)') - args = parser.parse_args() - logging.info('Running test case %s on port %d' % (args.test_case, args.port)) - endpoint = twisted.internet.endpoints.TCP4ServerEndpoint( - twisted.internet.reactor, args.port, backlog=128) - endpoint.listen(H2Factory(args.test_case)) + args = parse_arguments() + start_test_servers(args.base_port) twisted.internet.reactor.run() |