diff options
author | 2017-10-06 13:16:08 -0700 | |
---|---|---|
committer | 2017-10-06 13:16:08 -0700 | |
commit | e08e39d14811c51334151ca43b40764a70380e23 (patch) | |
tree | 2b14caea98ad852fc37cc6cd391e3546ac98d014 | |
parent | a69912cb2c7abae2d930c4158bd56c33b9b7b898 (diff) | |
parent | 3640b4084ac8485ef99ab3162cae7b8b079bbf6b (diff) |
Merge github.com:grpc/grpc into qps_failya
-rw-r--r-- | CMakeLists.txt | 12 | ||||
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | binding.gyp | 2 | ||||
-rw-r--r-- | build.yaml | 2 | ||||
-rw-r--r-- | config.m4 | 2 | ||||
-rw-r--r-- | config.w32 | 2 | ||||
-rw-r--r-- | gRPC-Core.podspec | 2 | ||||
-rw-r--r-- | grpc.gemspec | 2 | ||||
-rw-r--r-- | grpc.gyp | 8 | ||||
-rw-r--r-- | package.xml | 2 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc | 4 | ||||
-rw-r--r-- | src/python/grpcio/grpc_core_dependencies.py | 2 | ||||
-rw-r--r-- | test/core/slice/BUILD | 14 | ||||
-rw-r--r-- | test/core/util/BUILD | 8 | ||||
-rw-r--r-- | test/core/util/fuzzer_corpus_test.cc | 136 | ||||
-rw-r--r-- | test/core/util/grpc_fuzzer.bzl | 20 | ||||
-rw-r--r-- | tools/doxygen/Doxyfile.core.internal | 2 | ||||
-rw-r--r-- | tools/run_tests/generated/sources_and_headers.json | 2 |
18 files changed, 194 insertions, 40 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2321afc1b0..139d1bd46c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -954,7 +954,7 @@ endif (gRPC_BUILD_TESTS) add_library(grpc src/core/lib/surface/init.cc - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc @@ -1306,7 +1306,7 @@ endif() add_library(grpc_cronet src/core/lib/surface/init.cc - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc @@ -1626,7 +1626,7 @@ add_library(grpc_test_util test/core/util/port_server_client.c test/core/util/slice_splitter.c test/core/util/trickle_endpoint.c - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc @@ -1890,7 +1890,7 @@ add_library(grpc_test_util_unsecure test/core/util/port_server_client.c test/core/util/slice_splitter.c test/core/util/trickle_endpoint.c - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc @@ -2140,7 +2140,7 @@ endif (gRPC_BUILD_TESTS) add_library(grpc_unsecure src/core/lib/surface/init.cc src/core/lib/surface/init_unsecure.cc - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc @@ -2898,7 +2898,7 @@ add_library(grpc++_cronet src/core/ext/transport/chttp2/transport/stream_map.cc src/core/ext/transport/chttp2/transport/varint.cc src/core/ext/transport/chttp2/transport/writing.cc - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc @@ -2945,7 +2945,7 @@ endif LIBGRPC_SRC = \ src/core/lib/surface/init.cc \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ @@ -3297,7 +3297,7 @@ endif LIBGRPC_CRONET_SRC = \ src/core/lib/surface/init.cc \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ @@ -3616,7 +3616,7 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/util/port_server_client.c \ test/core/util/slice_splitter.c \ test/core/util/trickle_endpoint.c \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ @@ -3871,7 +3871,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/util/port_server_client.c \ test/core/util/slice_splitter.c \ test/core/util/trickle_endpoint.c \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ @@ -4099,7 +4099,7 @@ endif LIBGRPC_UNSECURE_SRC = \ src/core/lib/surface/init.cc \ src/core/lib/surface/init_unsecure.cc \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ @@ -4840,7 +4840,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/transport/chttp2/transport/stream_map.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ src/core/ext/transport/chttp2/transport/writing.cc \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ diff --git a/binding.gyp b/binding.gyp index e10532e8e9..91919c3330 100644 --- a/binding.gyp +++ b/binding.gyp @@ -657,7 +657,7 @@ ], 'sources': [ 'src/core/lib/surface/init.cc', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', diff --git a/build.yaml b/build.yaml index ead40766d8..d23716af2a 100644 --- a/build.yaml +++ b/build.yaml @@ -182,7 +182,7 @@ filegroups: - grpc++_codegen_base - name: grpc_base src: - - src/core/lib/backoff/backoff.c + - src/core/lib/backoff/backoff.cc - src/core/lib/channel/channel_args.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc @@ -85,7 +85,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/support/tmpfile_windows.cc \ src/core/lib/support/wrap_memcpy.cc \ src/core/lib/surface/init.cc \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ diff --git a/config.w32 b/config.w32 index 20ccf3a068..67b5e2f554 100644 --- a/config.w32 +++ b/config.w32 @@ -62,7 +62,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\support\\tmpfile_windows.cc " + "src\\core\\lib\\support\\wrap_memcpy.cc " + "src\\core\\lib\\surface\\init.cc " + - "src\\core\\lib\\backoff\\backoff.c " + + "src\\core\\lib\\backoff\\backoff.cc " + "src\\core\\lib\\channel\\channel_args.cc " + "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 659ea07ba6..08ef738732 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -460,7 +460,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', 'src/core/ext/filters/workarounds/workaround_utils.h', 'src/core/lib/surface/init.cc', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', diff --git a/grpc.gemspec b/grpc.gemspec index fd3010b044..ce23e6f7df 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -407,7 +407,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h ) s.files += %w( src/core/ext/filters/workarounds/workaround_utils.h ) s.files += %w( src/core/lib/surface/init.cc ) - s.files += %w( src/core/lib/backoff/backoff.c ) + s.files += %w( src/core/lib/backoff/backoff.cc ) s.files += %w( src/core/lib/channel/channel_args.cc ) s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) @@ -223,7 +223,7 @@ ], 'sources': [ 'src/core/lib/surface/init.cc', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', @@ -525,7 +525,7 @@ 'test/core/util/port_server_client.c', 'test/core/util/slice_splitter.c', 'test/core/util/trickle_endpoint.c', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', @@ -732,7 +732,7 @@ 'test/core/util/port_server_client.c', 'test/core/util/slice_splitter.c', 'test/core/util/trickle_endpoint.c', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', @@ -924,7 +924,7 @@ 'sources': [ 'src/core/lib/surface/init.cc', 'src/core/lib/surface/init_unsecure.cc', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', diff --git a/package.xml b/package.xml index 0b527d78db..df0142124d 100644 --- a/package.xml +++ b/package.xml @@ -419,7 +419,7 @@ <file baseinstalldir="/" name="src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/workarounds/workaround_utils.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/surface/init.cc" role="src" /> - <file baseinstalldir="/" name="src/core/lib/backoff/backoff.c" role="src" /> + <file baseinstalldir="/" name="src/core/lib/backoff/backoff.cc" role="src" /> <file baseinstalldir="/" name="src/core/lib/channel/channel_args.cc" role="src" /> <file baseinstalldir="/" name="src/core/lib/channel/channel_stack.cc" role="src" /> <file baseinstalldir="/" name="src/core/lib/channel/channel_stack_builder.cc" role="src" /> diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 02a983c63c..53fa0fff04 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -1010,6 +1010,10 @@ static void glb_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer); glb_policy->retry_timer_active = false; } + if (glb_policy->fallback_timer_active) { + grpc_timer_cancel(exec_ctx, &glb_policy->lb_fallback_timer); + glb_policy->fallback_timer_active = false; + } pending_pick *pp = glb_policy->pending_picks; glb_policy->pending_picks = NULL; diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index e60dfb7c2c..140f4ceee1 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -61,7 +61,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/support/tmpfile_windows.cc', 'src/core/lib/support/wrap_memcpy.cc', 'src/core/lib/surface/init.cc', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', diff --git a/test/core/slice/BUILD b/test/core/slice/BUILD index f86a3a6082..ad2308a4d6 100644 --- a/test/core/slice/BUILD +++ b/test/core/slice/BUILD @@ -21,10 +21,22 @@ licenses(["notice"]) # Apache v2 load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_fuzzer( + name = "percent_encode_fuzzer", + srcs = ["percent_encode_fuzzer.c"], + language = "C", + corpus = "percent_encode_corpus", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:grpc_test_util", + ], +) + +grpc_fuzzer( name = "percent_decode_fuzzer", srcs = ["percent_decode_fuzzer.c"], language = "C", - corpus = "response_corpus", + corpus = "percent_decode_corpus", deps = [ "//:gpr", "//:grpc", diff --git a/test/core/util/BUILD b/test/core/util/BUILD index 10eefe159a..abb50a0c99 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -89,12 +89,16 @@ grpc_cc_library( ) grpc_cc_library( - name = "one_corpus_entry_fuzzer", - srcs = ["one_corpus_entry_fuzzer.c"], + name = "fuzzer_corpus_test", + srcs = ["fuzzer_corpus_test.cc"], deps = [ ":gpr_test_util", "//:grpc", ], + external_deps = [ + "gtest", + "gflags", + ], ) sh_library( diff --git a/test/core/util/fuzzer_corpus_test.cc b/test/core/util/fuzzer_corpus_test.cc new file mode 100644 index 0000000000..a5e99a1bac --- /dev/null +++ b/test/core/util/fuzzer_corpus_test.cc @@ -0,0 +1,136 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <stdbool.h> + +#include <dirent.h> +#include <gflags/gflags.h> +#include <grpc/support/log.h> +#include <gtest/gtest.h> +#include <stdio.h> +#include <sys/types.h> + +#include "src/core/lib/iomgr/load_file.h" +#include "test/core/util/test_config.h" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); +extern "C" bool squelch; +extern "C" bool leak_check; + +DEFINE_string(file, "", "Use this file as test data"); +DEFINE_string(directory, "", "Use this directory as test data"); + +class FuzzerCorpusTest : public ::testing::TestWithParam<std::string> {}; + +TEST_P(FuzzerCorpusTest, RunOneExample) { + gpr_log(GPR_DEBUG, "Example file: %s", GetParam().c_str()); + grpc_slice buffer; + squelch = false; + leak_check = false; + GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", + grpc_load_file(GetParam().c_str(), 0, &buffer))); + LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer), + GRPC_SLICE_LENGTH(buffer)); + grpc_slice_unref(buffer); +} + +class ExampleGenerator + : public ::testing::internal::ParamGeneratorInterface<std::string> { + public: + virtual ::testing::internal::ParamIteratorInterface<std::string>* Begin() + const; + virtual ::testing::internal::ParamIteratorInterface<std::string>* End() const; + + private: + void Materialize() const { + if (examples_.empty()) { + if (!FLAGS_file.empty()) examples_.push_back(FLAGS_file); + if (!FLAGS_directory.empty()) { + DIR* dp; + struct dirent* ep; + dp = opendir(FLAGS_directory.c_str()); + + if (dp != NULL) { + while ((ep = readdir(dp)) != nullptr) { + if (ep->d_type == DT_REG) { + examples_.push_back(FLAGS_directory + "/" + ep->d_name); + } + } + + (void)closedir(dp); + } else { + perror("Couldn't open the directory"); + abort(); + } + } + } + } + + mutable std::vector<std::string> examples_; +}; + +class ExampleIterator + : public ::testing::internal::ParamIteratorInterface<std::string> { + public: + ExampleIterator(const ExampleGenerator& base_, + std::vector<std::string>::const_iterator begin) + : base_(base_), begin_(begin), current_(begin) {} + + virtual const ExampleGenerator* BaseGenerator() const { return &base_; } + + virtual void Advance() { current_++; } + virtual ExampleIterator* Clone() const { return new ExampleIterator(*this); } + virtual const std::string* Current() const { return &*current_; } + + virtual bool Equals(const ParamIteratorInterface<std::string>& other) const { + return &base_ == other.BaseGenerator() && + current_ == dynamic_cast<const ExampleIterator*>(&other)->current_; + } + + private: + ExampleIterator(const ExampleIterator& other) + : base_(other.base_), begin_(other.begin_), current_(other.current_) {} + + const ExampleGenerator& base_; + const std::vector<std::string>::const_iterator begin_; + std::vector<std::string>::const_iterator current_; +}; + +::testing::internal::ParamIteratorInterface<std::string>* +ExampleGenerator::Begin() const { + Materialize(); + return new ExampleIterator(*this, examples_.begin()); +} + +::testing::internal::ParamIteratorInterface<std::string>* +ExampleGenerator::End() const { + Materialize(); + return new ExampleIterator(*this, examples_.end()); +} + +INSTANTIATE_TEST_CASE_P( + CorpusExamples, FuzzerCorpusTest, + ::testing::internal::ParamGenerator<std::string>(new ExampleGenerator)); + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + ::gflags::ParseCommandLineFlags(&argc, &argv, true); + ::testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} diff --git a/test/core/util/grpc_fuzzer.bzl b/test/core/util/grpc_fuzzer.bzl index 41f6cdc8ba..55b6f1c1a5 100644 --- a/test/core/util/grpc_fuzzer.bzl +++ b/test/core/util/grpc_fuzzer.bzl @@ -12,19 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("//bazel:grpc_build_system.bzl", "grpc_cc_binary") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test") def grpc_fuzzer(name, corpus, srcs = [], deps = [], **kwargs): - grpc_cc_binary( - name = '%s/one_entry.bin' % name, + grpc_cc_test( + name = name, srcs = srcs, - deps = deps + ["//test/core/util:one_corpus_entry_fuzzer"], + deps = deps + ["//test/core/util:fuzzer_corpus_test"], + data = [corpus], + args = ['--directory', '$(location %s)' % corpus], + external_deps = [ + 'gtest', + ], **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/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 37dc9b4ba5..d4654034f2 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1056,7 +1056,7 @@ src/core/ext/transport/inproc/inproc_plugin.cc \ src/core/ext/transport/inproc/inproc_transport.cc \ src/core/ext/transport/inproc/inproc_transport.h \ src/core/lib/README.md \ -src/core/lib/backoff/backoff.c \ +src/core/lib/backoff/backoff.cc \ src/core/lib/backoff/backoff.h \ src/core/lib/channel/README.md \ src/core/lib/channel/channel_args.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 8b11bb742e..babdfeb685 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7994,7 +7994,7 @@ "language": "c", "name": "grpc_base", "src": [ - "src/core/lib/backoff/backoff.c", + "src/core/lib/backoff/backoff.cc", "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", |