From e9587db8530446d894d5de470591201dabb3ac77 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 6 Mar 2018 08:16:04 -0800 Subject: Move status util --- BUILD | 4 +- CMakeLists.txt | 14 +-- Makefile | 16 ++-- build.yaml | 6 +- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 3 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 8 +- package.xml | 4 +- .../ext/filters/client_channel/client_channel.cc | 2 +- .../ext/filters/client_channel/method_params.cc | 2 +- .../ext/filters/client_channel/method_params.h | 2 +- src/core/ext/filters/client_channel/status_util.cc | 100 --------------------- src/core/ext/filters/client_channel/status_util.h | 58 ------------ src/core/lib/channel/channel_trace.cc | 2 +- src/core/lib/channel/status_util.cc | 100 +++++++++++++++++++++ src/core/lib/channel/status_util.h | 58 ++++++++++++ src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/channel/BUILD | 18 +++- test/core/channel/status_util_test.cc | 49 ++++++++++ test/core/client_channel/BUILD | 12 --- test/core/client_channel/status_util_test.cc | 49 ---------- tools/doxygen/Doxyfile.c++.internal | 1 + tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 8 +- 27 files changed, 269 insertions(+), 267 deletions(-) delete mode 100644 src/core/ext/filters/client_channel/status_util.cc delete mode 100644 src/core/ext/filters/client_channel/status_util.h create mode 100644 src/core/lib/channel/status_util.cc create mode 100644 src/core/lib/channel/status_util.h create mode 100644 test/core/channel/status_util_test.cc delete mode 100644 test/core/client_channel/status_util_test.cc diff --git a/BUILD b/BUILD index 0baf89ff57..40ba497a59 100644 --- a/BUILD +++ b/BUILD @@ -677,6 +677,7 @@ grpc_cc_library( "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", "src/core/lib/channel/channel_tracer.cc", + "src/core/lib/channel/status_util.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/object_registry.cc", "src/core/lib/channel/handshaker.cc", @@ -814,6 +815,7 @@ grpc_cc_library( "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", "src/core/lib/channel/channel_tracer.h", + "src/core/lib/channel/status_util.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/object_registry.h", @@ -1006,7 +1008,6 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver.cc", "src/core/ext/filters/client_channel/resolver_registry.cc", "src/core/ext/filters/client_channel/retry_throttle.cc", - "src/core/ext/filters/client_channel/status_util.cc", "src/core/ext/filters/client_channel/subchannel.cc", "src/core/ext/filters/client_channel/subchannel_index.cc", "src/core/ext/filters/client_channel/uri_parser.cc", @@ -1029,7 +1030,6 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver_factory.h", "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.h", - "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.h", "src/core/ext/filters/client_channel/uri_parser.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c4d6a3070..088373f470 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -806,6 +806,7 @@ add_library(grpc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1010,7 +1011,6 @@ add_library(grpc src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1150,6 +1150,7 @@ add_library(grpc_cronet src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1325,7 +1326,6 @@ add_library(grpc_cronet src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1481,6 +1481,7 @@ add_library(grpc_test_util src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1625,7 +1626,6 @@ add_library(grpc_test_util src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1773,6 +1773,7 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1917,7 +1918,6 @@ add_library(grpc_test_util_unsecure src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -2044,6 +2044,7 @@ add_library(grpc_unsecure src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2221,7 +2222,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -2849,6 +2849,7 @@ add_library(grpc++_cronet src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2998,7 +2999,6 @@ add_library(grpc++_cronet src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -12402,7 +12402,7 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(status_util_test - test/core/client_channel/status_util_test.cc + test/core/channel/status_util_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) diff --git a/Makefile b/Makefile index ed87a6a2c4..6487050b63 100644 --- a/Makefile +++ b/Makefile @@ -3046,6 +3046,7 @@ LIBGRPC_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3250,7 +3251,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -3392,6 +3392,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3567,7 +3568,6 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -3724,6 +3724,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3868,7 +3869,6 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -4009,6 +4009,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4153,7 +4154,6 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -4260,6 +4260,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4437,7 +4438,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -5064,6 +5064,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -5213,7 +5214,6 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -18213,7 +18213,7 @@ endif STATUS_UTIL_TEST_SRC = \ - test/core/client_channel/status_util_test.cc \ + test/core/channel/status_util_test.cc \ STATUS_UTIL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STATUS_UTIL_TEST_SRC)))) ifeq ($(NO_SECURE),true) @@ -18244,7 +18244,7 @@ endif endif -$(OBJDIR)/$(CONFIG)/test/core/client_channel/status_util_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a +$(OBJDIR)/$(CONFIG)/test/core/channel/status_util_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a deps_status_util_test: $(STATUS_UTIL_TEST_OBJS:.o=.dep) diff --git a/build.yaml b/build.yaml index 85ea6e7993..d03aa62c27 100644 --- a/build.yaml +++ b/build.yaml @@ -160,6 +160,7 @@ filegroups: - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc - src/core/lib/channel/handshaker_registry.cc + - src/core/lib/channel/status_util.cc - src/core/lib/compression/compression.cc - src/core/lib/compression/compression_internal.cc - src/core/lib/compression/message_compress.cc @@ -319,6 +320,7 @@ filegroups: - src/core/lib/channel/handshaker.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h + - src/core/lib/channel/status_util.h - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/compression_internal.h - src/core/lib/compression/message_compress.h @@ -460,7 +462,6 @@ filegroups: - src/core/ext/filters/client_channel/resolver_factory.h - src/core/ext/filters/client_channel/resolver_registry.h - src/core/ext/filters/client_channel/retry_throttle.h - - src/core/ext/filters/client_channel/status_util.h - src/core/ext/filters/client_channel/subchannel.h - src/core/ext/filters/client_channel/subchannel_index.h - src/core/ext/filters/client_channel/uri_parser.h @@ -483,7 +484,6 @@ filegroups: - src/core/ext/filters/client_channel/resolver.cc - src/core/ext/filters/client_channel/resolver_registry.cc - src/core/ext/filters/client_channel/retry_throttle.cc - - src/core/ext/filters/client_channel/status_util.cc - src/core/ext/filters/client_channel/subchannel.cc - src/core/ext/filters/client_channel/subchannel_index.cc - src/core/ext/filters/client_channel/uri_parser.cc @@ -4909,7 +4909,7 @@ targets: build: test language: c++ src: - - test/core/client_channel/status_util_test.cc + - test/core/channel/status_util_test.cc deps: - grpc uses_polling: false diff --git a/config.m4 b/config.m4 index b46eb4078b..b53f5f7f35 100644 --- a/config.m4 +++ b/config.m4 @@ -90,6 +90,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -294,7 +295,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ diff --git a/config.w32 b/config.w32 index ea90cb5424..eeb4895181 100644 --- a/config.w32 +++ b/config.w32 @@ -67,6 +67,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + "src\\core\\lib\\channel\\handshaker_registry.cc " + + "src\\core\\lib\\channel\\status_util.cc " + "src\\core\\lib\\compression\\compression.cc " + "src\\core\\lib\\compression\\compression_internal.cc " + "src\\core\\lib\\compression\\message_compress.cc " + @@ -271,7 +272,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver_registry.cc " + "src\\core\\ext\\filters\\client_channel\\retry_throttle.cc " + - "src\\core\\ext\\filters\\client_channel\\status_util.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel_index.cc " + "src\\core\\ext\\filters\\client_channel\\uri_parser.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index ae45fe12f3..9df76bcd49 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -304,7 +304,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', - 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -323,6 +322,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -504,6 +504,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index cf26d7e73d..a7f27aeb10 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -315,7 +315,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', - 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -334,6 +333,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -479,6 +479,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -683,7 +684,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -813,7 +813,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', - 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -832,6 +831,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/grpc.gemspec b/grpc.gemspec index a20d8efe14..2f4591a4ae 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -241,7 +241,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver_factory.h ) s.files += %w( src/core/ext/filters/client_channel/resolver_registry.h ) s.files += %w( src/core/ext/filters/client_channel/retry_throttle.h ) - s.files += %w( src/core/ext/filters/client_channel/status_util.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.h ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.h ) @@ -260,6 +259,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/handshaker.h ) s.files += %w( src/core/lib/channel/handshaker_factory.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h ) + s.files += %w( src/core/lib/channel/status_util.h ) s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/compression_internal.h ) s.files += %w( src/core/lib/compression/message_compress.h ) @@ -409,6 +409,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) s.files += %w( src/core/lib/channel/handshaker_registry.cc ) + s.files += %w( src/core/lib/channel/status_util.cc ) s.files += %w( src/core/lib/compression/compression.cc ) s.files += %w( src/core/lib/compression/compression_internal.cc ) s.files += %w( src/core/lib/compression/message_compress.cc ) @@ -613,7 +614,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver_registry.cc ) s.files += %w( src/core/ext/filters/client_channel/retry_throttle.cc ) - s.files += %w( src/core/ext/filters/client_channel/status_util.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.cc ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.cc ) diff --git a/grpc.gyp b/grpc.gyp index 0b7b3b9daf..092487d1a5 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -231,6 +231,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -435,7 +436,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -533,6 +533,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -677,7 +678,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -753,6 +753,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -897,7 +898,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -951,6 +951,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -1128,7 +1129,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', diff --git a/package.xml b/package.xml index a2b59e7339..5e8356cb32 100644 --- a/package.xml +++ b/package.xml @@ -248,7 +248,6 @@ - @@ -267,6 +266,7 @@ + @@ -416,6 +416,7 @@ + @@ -620,7 +621,6 @@ - diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 90b93fbe23..09cc06e169 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -38,12 +38,12 @@ #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/retry_throttle.h" -#include "src/core/ext/filters/client_channel/status_util.h" #include "src/core/ext/filters/client_channel/subchannel.h" #include "src/core/ext/filters/deadline/deadline_filter.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/manual_constructor.h" diff --git a/src/core/ext/filters/client_channel/method_params.cc b/src/core/ext/filters/client_channel/method_params.cc index 374b87e170..1f116bb67d 100644 --- a/src/core/ext/filters/client_channel/method_params.cc +++ b/src/core/ext/filters/client_channel/method_params.cc @@ -26,7 +26,7 @@ #include #include "src/core/ext/filters/client_channel/method_params.h" -#include "src/core/ext/filters/client_channel/status_util.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/ext/filters/client_channel/method_params.h b/src/core/ext/filters/client_channel/method_params.h index 48ece29867..099924edf3 100644 --- a/src/core/ext/filters/client_channel/method_params.h +++ b/src/core/ext/filters/client_channel/method_params.h @@ -21,7 +21,7 @@ #include -#include "src/core/ext/filters/client_channel/status_util.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/exec_ctx.h" // for grpc_millis diff --git a/src/core/ext/filters/client_channel/status_util.cc b/src/core/ext/filters/client_channel/status_util.cc deleted file mode 100644 index 11f732ab44..0000000000 --- a/src/core/ext/filters/client_channel/status_util.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* - * - * Copyright 2017 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 - -#include "src/core/ext/filters/client_channel/status_util.h" - -#include "src/core/lib/gpr/useful.h" - -typedef struct { - const char* str; - grpc_status_code status; -} status_string_entry; - -static const status_string_entry g_status_string_entries[] = { - {"OK", GRPC_STATUS_OK}, - {"CANCELLED", GRPC_STATUS_CANCELLED}, - {"UNKNOWN", GRPC_STATUS_UNKNOWN}, - {"INVALID_ARGUMENT", GRPC_STATUS_INVALID_ARGUMENT}, - {"DEADLINE_EXCEEDED", GRPC_STATUS_DEADLINE_EXCEEDED}, - {"NOT_FOUND", GRPC_STATUS_NOT_FOUND}, - {"ALREADY_EXISTS", GRPC_STATUS_ALREADY_EXISTS}, - {"PERMISSION_DENIED", GRPC_STATUS_PERMISSION_DENIED}, - {"UNAUTHENTICATED", GRPC_STATUS_UNAUTHENTICATED}, - {"RESOURCE_EXHAUSTED", GRPC_STATUS_RESOURCE_EXHAUSTED}, - {"FAILED_PRECONDITION", GRPC_STATUS_FAILED_PRECONDITION}, - {"ABORTED", GRPC_STATUS_ABORTED}, - {"OUT_OF_RANGE", GRPC_STATUS_OUT_OF_RANGE}, - {"UNIMPLEMENTED", GRPC_STATUS_UNIMPLEMENTED}, - {"INTERNAL", GRPC_STATUS_INTERNAL}, - {"UNAVAILABLE", GRPC_STATUS_UNAVAILABLE}, - {"DATA_LOSS", GRPC_STATUS_DATA_LOSS}, -}; - -bool grpc_status_code_from_string(const char* status_str, - grpc_status_code* status) { - for (size_t i = 0; i < GPR_ARRAY_SIZE(g_status_string_entries); ++i) { - if (strcmp(status_str, g_status_string_entries[i].str) == 0) { - *status = g_status_string_entries[i].status; - return true; - } - } - return false; -} - -const char* grpc_status_code_to_string(grpc_status_code status) { - switch (status) { - case GRPC_STATUS_OK: - return "OK"; - case GRPC_STATUS_CANCELLED: - return "CANCELLED"; - case GRPC_STATUS_UNKNOWN: - return "UNKNOWN"; - case GRPC_STATUS_INVALID_ARGUMENT: - return "INVALID_ARGUMENT"; - case GRPC_STATUS_DEADLINE_EXCEEDED: - return "DEADLINE_EXCEEDED"; - case GRPC_STATUS_NOT_FOUND: - return "NOT_FOUND"; - case GRPC_STATUS_ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case GRPC_STATUS_PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case GRPC_STATUS_UNAUTHENTICATED: - return "UNAUTHENTICATED"; - case GRPC_STATUS_RESOURCE_EXHAUSTED: - return "RESOURCE_EXHAUSTED"; - case GRPC_STATUS_FAILED_PRECONDITION: - return "FAILED_PRECONDITION"; - case GRPC_STATUS_ABORTED: - return "ABORTED"; - case GRPC_STATUS_OUT_OF_RANGE: - return "OUT_OF_RANGE"; - case GRPC_STATUS_UNIMPLEMENTED: - return "UNIMPLEMENTED"; - case GRPC_STATUS_INTERNAL: - return "INTERNAL"; - case GRPC_STATUS_UNAVAILABLE: - return "UNAVAILABLE"; - case GRPC_STATUS_DATA_LOSS: - return "DATA_LOSS"; - default: - return "UNKNOWN"; - } -} diff --git a/src/core/ext/filters/client_channel/status_util.h b/src/core/ext/filters/client_channel/status_util.h deleted file mode 100644 index e018709730..0000000000 --- a/src/core/ext/filters/client_channel/status_util.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Copyright 2017 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. - * - */ - -#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H -#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H - -#include - -#include - -#include -#include - -/// If \a status_str is a valid status string, sets \a status to the -/// corresponding status value and returns true. -bool grpc_status_code_from_string(const char* status_str, - grpc_status_code* status); - -/// Returns the string form of \a status, or "UNKNOWN" if invalid. -const char* grpc_status_code_to_string(grpc_status_code status); - -namespace grpc_core { -namespace internal { - -/// A set of grpc_status_code values. -class StatusCodeSet { - public: - bool Empty() const { return status_code_mask_ == 0; } - - void Add(grpc_status_code status) { status_code_mask_ |= (1 << status); } - - bool Contains(grpc_status_code status) const { - return status_code_mask_ & (1 << status); - } - - private: - int status_code_mask_ = 0; // A bitfield of status codes in the set. -}; - -} // namespace internal -} // namespace grpc_core - -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H */ diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index 226ab0292d..07c2c1fd97 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -27,8 +27,8 @@ #include #include -#include "src/core/ext/filters/client_channel/status_util.h" #include "src/core/lib/channel/channel_trace_registry.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/lib/channel/status_util.cc b/src/core/lib/channel/status_util.cc new file mode 100644 index 0000000000..563db40846 --- /dev/null +++ b/src/core/lib/channel/status_util.cc @@ -0,0 +1,100 @@ +/* + * + * Copyright 2017 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 + +#include "src/core/lib/channel/status_util.h" + +#include "src/core/lib/gpr/useful.h" + +typedef struct { + const char* str; + grpc_status_code status; +} status_string_entry; + +static const status_string_entry g_status_string_entries[] = { + {"OK", GRPC_STATUS_OK}, + {"CANCELLED", GRPC_STATUS_CANCELLED}, + {"UNKNOWN", GRPC_STATUS_UNKNOWN}, + {"INVALID_ARGUMENT", GRPC_STATUS_INVALID_ARGUMENT}, + {"DEADLINE_EXCEEDED", GRPC_STATUS_DEADLINE_EXCEEDED}, + {"NOT_FOUND", GRPC_STATUS_NOT_FOUND}, + {"ALREADY_EXISTS", GRPC_STATUS_ALREADY_EXISTS}, + {"PERMISSION_DENIED", GRPC_STATUS_PERMISSION_DENIED}, + {"UNAUTHENTICATED", GRPC_STATUS_UNAUTHENTICATED}, + {"RESOURCE_EXHAUSTED", GRPC_STATUS_RESOURCE_EXHAUSTED}, + {"FAILED_PRECONDITION", GRPC_STATUS_FAILED_PRECONDITION}, + {"ABORTED", GRPC_STATUS_ABORTED}, + {"OUT_OF_RANGE", GRPC_STATUS_OUT_OF_RANGE}, + {"UNIMPLEMENTED", GRPC_STATUS_UNIMPLEMENTED}, + {"INTERNAL", GRPC_STATUS_INTERNAL}, + {"UNAVAILABLE", GRPC_STATUS_UNAVAILABLE}, + {"DATA_LOSS", GRPC_STATUS_DATA_LOSS}, +}; + +bool grpc_status_code_from_string(const char* status_str, + grpc_status_code* status) { + for (size_t i = 0; i < GPR_ARRAY_SIZE(g_status_string_entries); ++i) { + if (strcmp(status_str, g_status_string_entries[i].str) == 0) { + *status = g_status_string_entries[i].status; + return true; + } + } + return false; +} + +const char* grpc_status_code_to_string(grpc_status_code status) { + switch (status) { + case GRPC_STATUS_OK: + return "OK"; + case GRPC_STATUS_CANCELLED: + return "CANCELLED"; + case GRPC_STATUS_UNKNOWN: + return "UNKNOWN"; + case GRPC_STATUS_INVALID_ARGUMENT: + return "INVALID_ARGUMENT"; + case GRPC_STATUS_DEADLINE_EXCEEDED: + return "DEADLINE_EXCEEDED"; + case GRPC_STATUS_NOT_FOUND: + return "NOT_FOUND"; + case GRPC_STATUS_ALREADY_EXISTS: + return "ALREADY_EXISTS"; + case GRPC_STATUS_PERMISSION_DENIED: + return "PERMISSION_DENIED"; + case GRPC_STATUS_UNAUTHENTICATED: + return "UNAUTHENTICATED"; + case GRPC_STATUS_RESOURCE_EXHAUSTED: + return "RESOURCE_EXHAUSTED"; + case GRPC_STATUS_FAILED_PRECONDITION: + return "FAILED_PRECONDITION"; + case GRPC_STATUS_ABORTED: + return "ABORTED"; + case GRPC_STATUS_OUT_OF_RANGE: + return "OUT_OF_RANGE"; + case GRPC_STATUS_UNIMPLEMENTED: + return "UNIMPLEMENTED"; + case GRPC_STATUS_INTERNAL: + return "INTERNAL"; + case GRPC_STATUS_UNAVAILABLE: + return "UNAVAILABLE"; + case GRPC_STATUS_DATA_LOSS: + return "DATA_LOSS"; + default: + return "UNKNOWN"; + } +} diff --git a/src/core/lib/channel/status_util.h b/src/core/lib/channel/status_util.h new file mode 100644 index 0000000000..2c552fa20a --- /dev/null +++ b/src/core/lib/channel/status_util.h @@ -0,0 +1,58 @@ +/* + * + * Copyright 2017 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. + * + */ + +#ifndef GRPC_LIB_CHANNEL_STATUS_UTILS_H +#define GRPC_LIB_CHANNEL_STATUS_UTILS_H + +#include + +#include + +#include +#include + +/// If \a status_str is a valid status string, sets \a status to the +/// corresponding status value and returns true. +bool grpc_status_code_from_string(const char* status_str, + grpc_status_code* status); + +/// Returns the string form of \a status, or "UNKNOWN" if invalid. +const char* grpc_status_code_to_string(grpc_status_code status); + +namespace grpc_core { +namespace internal { + +/// A set of grpc_status_code values. +class StatusCodeSet { + public: + bool Empty() const { return status_code_mask_ == 0; } + + void Add(grpc_status_code status) { status_code_mask_ |= (1 << status); } + + bool Contains(grpc_status_code status) const { + return status_code_mask_ & (1 << status); + } + + private: + int status_code_mask_ = 0; // A bitfield of status codes in the set. +}; + +} // namespace internal +} // namespace grpc_core + +#endif /* GRPC_LIB_CHANNEL_STATUS_UTILS_H */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index bc9b5a3c73..49016bad55 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -66,6 +66,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -270,7 +271,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index 633c424eae..e1388c6e1a 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -69,9 +69,6 @@ grpc_cc_test( grpc_cc_test( name = "channel_trace_test", srcs = ["channel_trace_test.cc"], - external_deps = [ - "gtest", - ], language = "C++", deps = [ "//:gpr", @@ -80,4 +77,19 @@ grpc_cc_test( "//test/core/util:gpr_test_util", "//test/core/util:grpc_test_util", ], + external_deps = [ + "gtest", + ], +) + +grpc_cc_test( + name = "status_util_test", + srcs = ["status_util_test.cc"], + language = "C++", + deps = [ + "//:grpc", + ], + external_deps = [ + "gtest", + ], ) diff --git a/test/core/channel/status_util_test.cc b/test/core/channel/status_util_test.cc new file mode 100644 index 0000000000..1d64bf1995 --- /dev/null +++ b/test/core/channel/status_util_test.cc @@ -0,0 +1,49 @@ +/* + * + * Copyright 2017 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 "src/core/lib/channel/status_util.h" + +#include + +namespace grpc_core { +namespace internal { +namespace { + +TEST(StatusCodeSet, Basic) { + StatusCodeSet set; + EXPECT_TRUE(set.Empty()); + EXPECT_FALSE(set.Contains(GRPC_STATUS_OK)); + EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); + set.Add(GRPC_STATUS_OK); + EXPECT_FALSE(set.Empty()); + EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); + EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); + set.Add(GRPC_STATUS_UNAVAILABLE); + EXPECT_FALSE(set.Empty()); + EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); + EXPECT_TRUE(set.Contains(GRPC_STATUS_UNAVAILABLE)); +} + +} // namespace +} // namespace internal +} // namespace grpc_core + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/core/client_channel/BUILD b/test/core/client_channel/BUILD index d430b722df..5148dc5f74 100644 --- a/test/core/client_channel/BUILD +++ b/test/core/client_channel/BUILD @@ -53,15 +53,3 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) - -grpc_cc_test( - name = "status_util_test", - srcs = ["status_util_test.cc"], - language = "C++", - deps = [ - "//:grpc", - ], - external_deps = [ - "gtest", - ], -) diff --git a/test/core/client_channel/status_util_test.cc b/test/core/client_channel/status_util_test.cc deleted file mode 100644 index f944990ad2..0000000000 --- a/test/core/client_channel/status_util_test.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright 2017 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 "src/core/ext/filters/client_channel/status_util.h" - -#include - -namespace grpc_core { -namespace internal { -namespace { - -TEST(StatusCodeSet, Basic) { - StatusCodeSet set; - EXPECT_TRUE(set.Empty()); - EXPECT_FALSE(set.Contains(GRPC_STATUS_OK)); - EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); - set.Add(GRPC_STATUS_OK); - EXPECT_FALSE(set.Empty()); - EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); - EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); - set.Add(GRPC_STATUS_UNAVAILABLE); - EXPECT_FALSE(set.Empty()); - EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); - EXPECT_TRUE(set.Contains(GRPC_STATUS_UNAVAILABLE)); -} - -} // namespace -} // namespace internal -} // namespace grpc_core - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index cae5cc5fa1..30ee95d785 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1014,6 +1014,7 @@ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.h \ +src/core/lib/channel/status_util.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression_internal.h \ src/core/lib/compression/message_compress.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 78805a0ad1..326ced6d70 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -929,8 +929,6 @@ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/resolver_registry.h \ src/core/ext/filters/client_channel/retry_throttle.cc \ src/core/ext/filters/client_channel/retry_throttle.h \ -src/core/ext/filters/client_channel/status_util.cc \ -src/core/ext/filters/client_channel/status_util.h \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel.h \ src/core/ext/filters/client_channel/subchannel_index.cc \ @@ -1047,6 +1045,8 @@ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.cc \ src/core/lib/channel/handshaker_registry.h \ +src/core/lib/channel/status_util.cc \ +src/core/lib/channel/status_util.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 90ef05546f..706ec69845 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -4265,7 +4265,7 @@ "language": "c++", "name": "status_util_test", "src": [ - "test/core/client_channel/status_util_test.cc" + "test/core/channel/status_util_test.cc" ], "third_party": false, "type": "target" @@ -8581,6 +8581,7 @@ "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", "src/core/lib/channel/handshaker_registry.cc", + "src/core/lib/channel/status_util.cc", "src/core/lib/compression/compression.cc", "src/core/lib/compression/compression_internal.cc", "src/core/lib/compression/message_compress.cc", @@ -8741,6 +8742,7 @@ "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", + "src/core/lib/channel/status_util.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", @@ -8887,6 +8889,7 @@ "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", + "src/core/lib/channel/status_util.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", @@ -9032,7 +9035,6 @@ "src/core/ext/filters/client_channel/resolver_factory.h", "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.h", - "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.h", "src/core/ext/filters/client_channel/uri_parser.h" @@ -9076,8 +9078,6 @@ "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.cc", "src/core/ext/filters/client_channel/retry_throttle.h", - "src/core/ext/filters/client_channel/status_util.cc", - "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.cc", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.cc", -- cgit v1.2.3