Merge branch 'master' into transport-refs

pull/36454/head
Craig Tiller 11 months ago
commit 73d40c3115
  1. 1
      BUILD
  2. 24
      CMakeLists.txt
  3. 17
      build_autogenerated.yaml
  4. 1
      gRPC-C++.podspec
  5. 4
      include/grpcpp/client_context.h
  6. 8
      include/grpcpp/completion_queue.h
  7. 10
      include/grpcpp/impl/call_op_set.h
  8. 111
      include/grpcpp/impl/interceptor_common.h
  9. 4
      include/grpcpp/impl/proto_utils.h
  10. 4
      include/grpcpp/impl/rpc_service_method.h
  11. 18
      include/grpcpp/impl/server_callback_handlers.h
  12. 39
      include/grpcpp/impl/service_type.h
  13. 3
      include/grpcpp/impl/sync.h
  14. 6
      include/grpcpp/server_interface.h
  15. 90
      include/grpcpp/support/async_stream.h
  16. 20
      include/grpcpp/support/async_unary_call.h
  17. 16
      include/grpcpp/support/callback_common.h
  18. 34
      include/grpcpp/support/client_callback.h
  19. 4
      include/grpcpp/support/client_interceptor.h
  20. 4
      include/grpcpp/support/method_handler.h
  21. 9
      include/grpcpp/support/proto_buffer_reader.h
  22. 9
      include/grpcpp/support/proto_buffer_writer.h
  23. 4
      include/grpcpp/support/server_interceptor.h
  24. 22
      include/grpcpp/support/sync_stream.h
  25. 19
      test/core/iomgr/BUILD
  26. 4
      test/core/iomgr/buffer_list_test.cc
  27. 10
      test/core/iomgr/endpoint_pair_test.cc
  28. 20
      test/core/iomgr/endpoint_tests.cc
  29. 4
      test/core/iomgr/fd_conservation_posix_test.cc
  30. 3
      test/core/iomgr/resolve_address_test.cc
  31. 4
      test/core/iomgr/socket_utils_test.cc
  32. 5
      test/core/memory_usage/BUILD
  33. 5
      test/core/memory_usage/callback_client.cc
  34. 3
      test/core/memory_usage/callback_server.cc
  35. 12
      test/core/memory_usage/client.cc
  36. 3
      test/core/memory_usage/memstats.cc
  37. 27
      test/core/memory_usage/server.cc
  38. 1
      test/cpp/client/BUILD
  39. 33
      test/cpp/client/credentials_test.cc
  40. 2
      test/cpp/common/BUILD
  41. 12
      test/cpp/common/time_jump_test.cc
  42. 10
      test/cpp/common/timer_test.cc
  43. 4
      test/cpp/grpclb/grpclb_api_test.cc
  44. 2
      test/cpp/interop/BUILD
  45. 2
      test/cpp/interop/backend_metrics_lb_policy.cc
  46. 8
      test/cpp/interop/interop_client.cc
  47. 6
      test/cpp/interop/interop_server.cc
  48. 4
      test/cpp/interop/reconnect_interop_server.cc
  49. 2
      test/cpp/interop/rpc_behavior_lb_policy.cc
  50. 12
      test/cpp/interop/xds_interop_client.cc
  51. 5
      test/cpp/naming/BUILD
  52. 8
      test/cpp/naming/address_sorting_test.cc
  53. 3
      test/cpp/naming/cancel_ares_query_test.cc
  54. 3
      test/cpp/naming/generate_resolver_component_tests.bzl
  55. 14
      test/cpp/naming/resolver_component_test.cc
  56. 5
      test/cpp/naming/resolver_component_tests_runner_invoker.cc
  57. 1
      test/cpp/performance/BUILD
  58. 30
      test/cpp/performance/writes_per_rpc_test.cc
  59. 2
      test/cpp/qps/parse_json.cc
  60. 1
      test/cpp/server/BUILD
  61. 20
      test/cpp/server/credentials_test.cc
  62. 2
      test/cpp/server/load_reporter/BUILD
  63. 3
      test/cpp/server/load_reporter/load_reporter_test.cc

@ -897,6 +897,7 @@ grpc_cc_library(
name = "grpc++_public_hdrs", name = "grpc++_public_hdrs",
hdrs = GRPCXX_PUBLIC_HDRS, hdrs = GRPCXX_PUBLIC_HDRS,
external_deps = [ external_deps = [
"absl/log:check",
"absl/strings:cord", "absl/strings:cord",
"absl/synchronization", "absl/synchronization",
"protobuf_headers", "protobuf_headers",

24
CMakeLists.txt generated

@ -109,6 +109,7 @@ set(gRPC_ABSL_USED_TARGETS
absl_bind_front absl_bind_front
absl_bits absl_bits
absl_charset absl_charset
absl_check
absl_city absl_city
absl_civil_time absl_civil_time
absl_cleanup absl_cleanup
@ -169,6 +170,8 @@ set(gRPC_ABSL_USED_TARGETS
absl_log_entry absl_log_entry
absl_log_globals absl_log_globals
absl_log_internal_append_truncated absl_log_internal_append_truncated
absl_log_internal_check_impl
absl_log_internal_check_op
absl_log_internal_conditions absl_log_internal_conditions
absl_log_internal_config absl_log_internal_config
absl_log_internal_fnmatch absl_log_internal_fnmatch
@ -4146,6 +4149,7 @@ target_include_directories(grpc++
) )
target_link_libraries(grpc++ target_link_libraries(grpc++
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
absl::check
grpc grpc
${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES}
) )
@ -4887,6 +4891,7 @@ target_include_directories(grpc++_unsecure
) )
target_link_libraries(grpc++_unsecure target_link_libraries(grpc++_unsecure
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
absl::check
grpc_unsecure grpc_unsecure
${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES}
) )
@ -5815,6 +5820,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
target_link_libraries(fd_conservation_posix_test target_link_libraries(fd_conservation_posix_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
absl::check
grpc_test_util grpc_test_util
) )
@ -6128,6 +6134,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
target_link_libraries(address_sorting_test_unsecure target_link_libraries(address_sorting_test_unsecure
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc++_unsecure grpc++_unsecure
grpc_test_util_unsecure grpc_test_util_unsecure
grpc++_test_config grpc++_test_config
@ -8332,6 +8339,7 @@ target_include_directories(buffer_list_test
target_link_libraries(buffer_list_test target_link_libraries(buffer_list_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc_test_util grpc_test_util
) )
@ -12865,6 +12873,7 @@ target_include_directories(endpoint_pair_test
target_link_libraries(endpoint_pair_test target_link_libraries(endpoint_pair_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc_test_util grpc_test_util
) )
@ -13015,6 +13024,7 @@ target_include_directories(error_test
target_link_libraries(error_test target_link_libraries(error_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc_test_util grpc_test_util
) )
@ -15345,7 +15355,6 @@ target_include_directories(grpc_cli
target_link_libraries(grpc_cli target_link_libraries(grpc_cli
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
absl::check
grpc++ grpc++
${_gRPC_PROTOBUF_PROTOC_LIBRARIES} ${_gRPC_PROTOBUF_PROTOC_LIBRARIES}
grpc++_test_config grpc++_test_config
@ -23760,6 +23769,7 @@ target_include_directories(resolve_address_using_ares_resolver_test
target_link_libraries(resolve_address_using_ares_resolver_test target_link_libraries(resolve_address_using_ares_resolver_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc_test_util grpc_test_util
grpc++_test_config grpc++_test_config
) )
@ -23866,6 +23876,7 @@ target_include_directories(resolve_address_using_native_resolver_test
target_link_libraries(resolve_address_using_native_resolver_test target_link_libraries(resolve_address_using_native_resolver_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc_test_util grpc_test_util
grpc++_test_config grpc++_test_config
) )
@ -26606,6 +26617,7 @@ target_include_directories(secure_endpoint_test
target_link_libraries(secure_endpoint_test target_link_libraries(secure_endpoint_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc_test_util grpc_test_util
) )
@ -28454,6 +28466,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
target_link_libraries(socket_utils_test target_link_libraries(socket_utils_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc_test_util grpc_test_util
) )
@ -29595,6 +29608,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX)
target_link_libraries(tcp_posix_test target_link_libraries(tcp_posix_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc_test_util grpc_test_util
) )
@ -30382,6 +30396,7 @@ target_include_directories(test_cpp_client_credentials_test
target_link_libraries(test_cpp_client_credentials_test target_link_libraries(test_cpp_client_credentials_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc++ grpc++
grpc_test_util grpc_test_util
) )
@ -30541,6 +30556,7 @@ target_include_directories(test_cpp_server_credentials_test
target_link_libraries(test_cpp_server_credentials_test target_link_libraries(test_cpp_server_credentials_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc++ grpc++
grpc_test_util grpc_test_util
) )
@ -30960,6 +30976,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
target_link_libraries(time_jump_test target_link_libraries(time_jump_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc++ grpc++
grpc_test_util grpc_test_util
) )
@ -31203,6 +31220,7 @@ target_include_directories(timer_test
target_link_libraries(timer_test target_link_libraries(timer_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc++ grpc++
grpc_test_util grpc_test_util
) )
@ -36957,7 +36975,7 @@ generate_pkgconfig(
"gRPC++" "gRPC++"
"C++ wrapper for gRPC" "C++ wrapper for gRPC"
"${gRPC_CPP_VERSION}" "${gRPC_CPP_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc" "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc"
"libcares openssl re2 zlib" "libcares openssl re2 zlib"
"-lgrpc++" "-lgrpc++"
"-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib" "-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"
@ -36968,7 +36986,7 @@ generate_pkgconfig(
"gRPC++ unsecure" "gRPC++ unsecure"
"C++ wrapper for gRPC without SSL" "C++ wrapper for gRPC without SSL"
"${gRPC_CPP_VERSION}" "${gRPC_CPP_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc_unsecure" "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc_unsecure"
"libcares zlib" "libcares zlib"
"-lgrpc++_unsecure" "-lgrpc++_unsecure"
"-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib" "-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"

@ -3937,6 +3937,7 @@ libs:
- src/cpp/util/string_ref.cc - src/cpp/util/string_ref.cc
- src/cpp/util/time_cc.cc - src/cpp/util/time_cc.cc
deps: deps:
- absl/log:check
- grpc - grpc
- protobuf - protobuf
baselib: true baselib: true
@ -4310,6 +4311,7 @@ libs:
- src/cpp/util/string_ref.cc - src/cpp/util/string_ref.cc
- src/cpp/util/time_cc.cc - src/cpp/util/time_cc.cc
deps: deps:
- absl/log:check
- grpc_unsecure - grpc_unsecure
- protobuf - protobuf
baselib: true baselib: true
@ -5140,6 +5142,7 @@ targets:
- test/core/util/slice_splitter.cc - test/core/util/slice_splitter.cc
- test/core/util/tracer_util.cc - test/core/util/tracer_util.cc
deps: deps:
- absl/log:check
- grpc_test_util - grpc_test_util
platforms: platforms:
- linux - linux
@ -5310,6 +5313,7 @@ targets:
- test/cpp/util/subprocess.cc - test/cpp/util/subprocess.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc++_unsecure - grpc++_unsecure
- grpc_test_util_unsecure - grpc_test_util_unsecure
- grpc++_test_config - grpc++_test_config
@ -6274,6 +6278,7 @@ targets:
- test/core/util/tracer_util.cc - test/core/util/tracer_util.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc_test_util - grpc_test_util
- name: byte_buffer_test - name: byte_buffer_test
gtest: true gtest: true
@ -8985,6 +8990,7 @@ targets:
- test/core/util/tracer_util.cc - test/core/util/tracer_util.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc_test_util - grpc_test_util
- name: env_test - name: env_test
gtest: true gtest: true
@ -9042,6 +9048,7 @@ targets:
- test/core/util/tracer_util.cc - test/core/util/tracer_util.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc_test_util - grpc_test_util
uses_polling: false uses_polling: false
- name: error_utils_test - name: error_utils_test
@ -10519,7 +10526,6 @@ targets:
- test/cpp/util/proto_reflection_descriptor_database.cc - test/cpp/util/proto_reflection_descriptor_database.cc
- test/cpp/util/service_describer.cc - test/cpp/util/service_describer.cc
deps: deps:
- absl/log:check
- grpc++ - grpc++
- protoc - protoc
- grpc++_test_config - grpc++_test_config
@ -15310,6 +15316,7 @@ targets:
- test/core/util/tracer_util.cc - test/core/util/tracer_util.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc_test_util - grpc_test_util
- grpc++_test_config - grpc++_test_config
- name: resolve_address_using_native_resolver_posix_test - name: resolve_address_using_native_resolver_posix_test
@ -15379,6 +15386,7 @@ targets:
- test/core/util/tracer_util.cc - test/core/util/tracer_util.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc_test_util - grpc_test_util
- grpc++_test_config - grpc++_test_config
- name: resource_quota_end2end_stress_test - name: resource_quota_end2end_stress_test
@ -17759,6 +17767,7 @@ targets:
- test/core/util/tracer_util.cc - test/core/util/tracer_util.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc_test_util - grpc_test_util
- name: security_connector_test - name: security_connector_test
gtest: true gtest: true
@ -18704,6 +18713,7 @@ targets:
- test/core/util/tracer_util.cc - test/core/util/tracer_util.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc_test_util - grpc_test_util
platforms: platforms:
- linux - linux
@ -19183,6 +19193,7 @@ targets:
- test/core/util/tracer_util.cc - test/core/util/tracer_util.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc_test_util - grpc_test_util
platforms: platforms:
- linux - linux
@ -19584,6 +19595,7 @@ targets:
- test/cpp/util/tls_test_utils.cc - test/cpp/util/tls_test_utils.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc++ - grpc++
- grpc_test_util - grpc_test_util
- name: test_cpp_end2end_ssl_credentials_test - name: test_cpp_end2end_ssl_credentials_test
@ -19651,6 +19663,7 @@ targets:
- test/cpp/util/tls_test_utils.cc - test/cpp/util/tls_test_utils.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc++ - grpc++
- grpc_test_util - grpc_test_util
- name: test_cpp_util_slice_test - name: test_cpp_util_slice_test
@ -19782,6 +19795,7 @@ targets:
- test/cpp/common/time_jump_test.cc - test/cpp/common/time_jump_test.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc++ - grpc++
- grpc_test_util - grpc_test_util
platforms: platforms:
@ -19914,6 +19928,7 @@ targets:
- test/cpp/common/timer_test.cc - test/cpp/common/timer_test.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc++ - grpc++
- grpc_test_util - grpc_test_util
- name: tls_certificate_verifier_test - name: tls_certificate_verifier_test

1
gRPC-C++.podspec generated

@ -242,6 +242,7 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/functional/bind_front', abseil_version ss.dependency 'abseil/functional/bind_front', abseil_version
ss.dependency 'abseil/functional/function_ref', abseil_version ss.dependency 'abseil/functional/function_ref', abseil_version
ss.dependency 'abseil/hash/hash', abseil_version ss.dependency 'abseil/hash/hash', abseil_version
ss.dependency 'abseil/log/check', abseil_version
ss.dependency 'abseil/log/log', abseil_version ss.dependency 'abseil/log/log', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/meta/type_traits', abseil_version ss.dependency 'abseil/meta/type_traits', abseil_version

@ -38,6 +38,8 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "absl/log/check.h"
#include <grpc/impl/compression_types.h> #include <grpc/impl/compression_types.h>
#include <grpc/impl/propagation_bits.h> #include <grpc/impl/propagation_bits.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -246,7 +248,7 @@ class ClientContext {
/// \return A multimap of initial metadata key-value pairs from the server. /// \return A multimap of initial metadata key-value pairs from the server.
const std::multimap<grpc::string_ref, grpc::string_ref>& const std::multimap<grpc::string_ref, grpc::string_ref>&
GetServerInitialMetadata() const { GetServerInitialMetadata() const {
GPR_ASSERT(initial_metadata_received_); CHECK(initial_metadata_received_);
return *recv_initial_metadata_.map(); return *recv_initial_metadata_.map();
} }

@ -34,6 +34,8 @@
#include <list> #include <list>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/atm.h> #include <grpc/support/atm.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -323,7 +325,7 @@ class CompletionQueue : private grpc::internal::GrpcLibrary {
bool ok = ev.success != 0; bool ok = ev.success != 0;
void* ignored = tag; void* ignored = tag;
if (tag->FinalizeResult(&ignored, &ok)) { if (tag->FinalizeResult(&ignored, &ok)) {
GPR_ASSERT(ignored == tag); CHECK(ignored == tag);
return ok; return ok;
} }
} }
@ -344,7 +346,7 @@ class CompletionQueue : private grpc::internal::GrpcLibrary {
bool ok = ev.success != 0; bool ok = ev.success != 0;
void* ignored = tag; void* ignored = tag;
// the tag must be swallowed if using TryPluck // the tag must be swallowed if using TryPluck
GPR_ASSERT(!tag->FinalizeResult(&ignored, &ok)); CHECK(!tag->FinalizeResult(&ignored, &ok));
} }
/// Performs a single polling pluck on \a tag. Calls tag->FinalizeResult if /// Performs a single polling pluck on \a tag. Calls tag->FinalizeResult if
@ -361,7 +363,7 @@ class CompletionQueue : private grpc::internal::GrpcLibrary {
bool ok = ev.success != 0; bool ok = ev.success != 0;
void* ignored = tag; void* ignored = tag;
GPR_ASSERT(!tag->FinalizeResult(&ignored, &ok)); CHECK(!tag->FinalizeResult(&ignored, &ok));
} }
/// Manage state of avalanching operations : completion queue tags that /// Manage state of avalanching operations : completion queue tags that

@ -23,6 +23,8 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/impl/compression_types.h> #include <grpc/impl/compression_types.h>
#include <grpc/impl/grpc_types.h> #include <grpc/impl/grpc_types.h>
@ -316,7 +318,7 @@ class CallOpSendMessage {
return; return;
} }
if (msg_ != nullptr) { if (msg_ != nullptr) {
GPR_ASSERT(serializer_(msg_).ok()); CHECK(serializer_(msg_).ok());
} }
serializer_ = nullptr; serializer_ = nullptr;
grpc_op* op = &ops[(*nops)++]; grpc_op* op = &ops[(*nops)++];
@ -795,7 +797,7 @@ class CallOpClientRecvStatus {
if (recv_status_ == nullptr || hijacked_) return; if (recv_status_ == nullptr || hijacked_) return;
if (static_cast<StatusCode>(status_code_) == StatusCode::OK) { if (static_cast<StatusCode>(status_code_) == StatusCode::OK) {
*recv_status_ = Status(); *recv_status_ = Status();
GPR_DEBUG_ASSERT(debug_error_string_ == nullptr); DCHECK_EQ(debug_error_string_, nullptr);
} else { } else {
*recv_status_ = *recv_status_ =
Status(static_cast<StatusCode>(status_code_), Status(static_cast<StatusCode>(status_code_),
@ -974,7 +976,7 @@ class CallOpSet : public CallOpSetInterface,
// WritesDone multiple times // WritesDone multiple times
gpr_log(GPR_ERROR, "API misuse of type %s observed", gpr_log(GPR_ERROR, "API misuse of type %s observed",
grpc_call_error_to_string(err)); grpc_call_error_to_string(err));
GPR_ASSERT(false); CHECK(false);
} }
} }
@ -984,7 +986,7 @@ class CallOpSet : public CallOpSetInterface,
done_intercepting_ = true; done_intercepting_ = true;
// The following call_start_batch is internally-generated so no need for an // The following call_start_batch is internally-generated so no need for an
// explanatory log on failure. // explanatory log on failure.
GPR_ASSERT(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag(), CHECK(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag(),
nullptr) == GRPC_CALL_OK); nullptr) == GRPC_CALL_OK);
} }

@ -22,6 +22,8 @@
#include <array> #include <array>
#include <functional> #include <functional>
#include "absl/log/check.h"
#include <grpc/impl/grpc_types.h> #include <grpc/impl/grpc_types.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/impl/call.h> #include <grpcpp/impl/call.h>
@ -56,16 +58,15 @@ class InterceptorBatchMethodsImpl
if (call_->client_rpc_info() != nullptr) { if (call_->client_rpc_info() != nullptr) {
return ProceedClient(); return ProceedClient();
} }
GPR_ASSERT(call_->server_rpc_info() != nullptr); CHECK_NE(call_->server_rpc_info(), nullptr);
ProceedServer(); ProceedServer();
} }
void Hijack() override { void Hijack() override {
// Only the client can hijack when sending down initial metadata // Only the client can hijack when sending down initial metadata
GPR_ASSERT(!reverse_ && ops_ != nullptr && CHECK(!reverse_ && ops_ != nullptr && call_->client_rpc_info() != nullptr);
call_->client_rpc_info() != nullptr);
// It is illegal to call Hijack twice // It is illegal to call Hijack twice
GPR_ASSERT(!ran_hijacking_interceptor_); CHECK(!ran_hijacking_interceptor_);
auto* rpc_info = call_->client_rpc_info(); auto* rpc_info = call_->client_rpc_info();
rpc_info->hijacked_ = true; rpc_info->hijacked_ = true;
rpc_info->hijacked_interceptor_ = current_interceptor_index_; rpc_info->hijacked_interceptor_ = current_interceptor_index_;
@ -80,21 +81,21 @@ class InterceptorBatchMethodsImpl
} }
ByteBuffer* GetSerializedSendMessage() override { ByteBuffer* GetSerializedSendMessage() override {
GPR_ASSERT(orig_send_message_ != nullptr); CHECK_NE(orig_send_message_, nullptr);
if (*orig_send_message_ != nullptr) { if (*orig_send_message_ != nullptr) {
GPR_ASSERT(serializer_(*orig_send_message_).ok()); CHECK(serializer_(*orig_send_message_).ok());
*orig_send_message_ = nullptr; *orig_send_message_ = nullptr;
} }
return send_message_; return send_message_;
} }
const void* GetSendMessage() override { const void* GetSendMessage() override {
GPR_ASSERT(orig_send_message_ != nullptr); CHECK_NE(orig_send_message_, nullptr);
return *orig_send_message_; return *orig_send_message_;
} }
void ModifySendMessage(const void* message) override { void ModifySendMessage(const void* message) override {
GPR_ASSERT(orig_send_message_ != nullptr); CHECK_NE(orig_send_message_, nullptr);
*orig_send_message_ = message; *orig_send_message_ = message;
} }
@ -129,7 +130,7 @@ class InterceptorBatchMethodsImpl
Status* GetRecvStatus() override { return recv_status_; } Status* GetRecvStatus() override { return recv_status_; }
void FailHijackedSendMessage() override { void FailHijackedSendMessage() override {
GPR_ASSERT(hooks_[static_cast<size_t>( CHECK(hooks_[static_cast<size_t>(
experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)]); experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)]);
*fail_send_message_ = true; *fail_send_message_ = true;
} }
@ -192,7 +193,7 @@ class InterceptorBatchMethodsImpl
} }
void FailHijackedRecvMessage() override { void FailHijackedRecvMessage() override {
GPR_ASSERT(hooks_[static_cast<size_t>( CHECK(hooks_[static_cast<size_t>(
experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)]); experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)]);
*hijacked_recv_message_failed_ = true; *hijacked_recv_message_failed_ = true;
} }
@ -236,7 +237,7 @@ class InterceptorBatchMethodsImpl
// ContinueFinalizeOpsAfterInterception will be called. Note that neither of // ContinueFinalizeOpsAfterInterception will be called. Note that neither of
// them is invoked if there were no interceptors registered. // them is invoked if there were no interceptors registered.
bool RunInterceptors() { bool RunInterceptors() {
GPR_ASSERT(ops_); CHECK(ops_);
auto* client_rpc_info = call_->client_rpc_info(); auto* client_rpc_info = call_->client_rpc_info();
if (client_rpc_info != nullptr) { if (client_rpc_info != nullptr) {
if (client_rpc_info->interceptors_.empty()) { if (client_rpc_info->interceptors_.empty()) {
@ -261,8 +262,8 @@ class InterceptorBatchMethodsImpl
// SyncRequest. // SyncRequest.
bool RunInterceptors(std::function<void(void)> f) { bool RunInterceptors(std::function<void(void)> f) {
// This is used only by the server for initial call request // This is used only by the server for initial call request
GPR_ASSERT(reverse_ == true); CHECK_EQ(reverse_, true);
GPR_ASSERT(call_->client_rpc_info() == nullptr); CHECK_EQ(call_->client_rpc_info(), nullptr);
auto* server_rpc_info = call_->server_rpc_info(); auto* server_rpc_info = call_->server_rpc_info();
if (server_rpc_info == nullptr || server_rpc_info->interceptors_.empty()) { if (server_rpc_info == nullptr || server_rpc_info->interceptors_.empty()) {
return true; return true;
@ -356,7 +357,7 @@ class InterceptorBatchMethodsImpl
return ops_->ContinueFinalizeResultAfterInterception(); return ops_->ContinueFinalizeResultAfterInterception();
} }
} }
GPR_ASSERT(callback_); CHECK(callback_);
callback_(); callback_();
} }
@ -422,112 +423,98 @@ class CancelInterceptorBatchMethods
void Hijack() override { void Hijack() override {
// Only the client can hijack when sending down initial metadata // Only the client can hijack when sending down initial metadata
GPR_ASSERT(false && CHECK(false) << "It is illegal to call Hijack on a method which has a "
"It is illegal to call Hijack on a method which has a " "Cancel notification";
"Cancel notification");
} }
ByteBuffer* GetSerializedSendMessage() override { ByteBuffer* GetSerializedSendMessage() override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call GetSendMessage on a method which "
"It is illegal to call GetSendMessage on a method which " "has a Cancel notification";
"has a Cancel notification");
return nullptr; return nullptr;
} }
bool GetSendMessageStatus() override { bool GetSendMessageStatus() override {
GPR_ASSERT(false && CHECK(false)
"It is illegal to call GetSendMessageStatus on a method which " << "It is illegal to call GetSendMessageStatus on a method which "
"has a Cancel notification"); "has a Cancel notification";
return false; return false;
} }
const void* GetSendMessage() override { const void* GetSendMessage() override {
GPR_ASSERT(false && CHECK(false)
"It is illegal to call GetOriginalSendMessage on a method which " << "It is illegal to call GetOriginalSendMessage on a method which "
"has a Cancel notification"); "has a Cancel notification";
return nullptr; return nullptr;
} }
void ModifySendMessage(const void* /*message*/) override { void ModifySendMessage(const void* /*message*/) override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call ModifySendMessage on a method which "
"It is illegal to call ModifySendMessage on a method which " "has a Cancel notification";
"has a Cancel notification");
} }
std::multimap<std::string, std::string>* GetSendInitialMetadata() override { std::multimap<std::string, std::string>* GetSendInitialMetadata() override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call GetSendInitialMetadata on a "
"It is illegal to call GetSendInitialMetadata on a " "method which has a Cancel notification";
"method which has a Cancel notification");
return nullptr; return nullptr;
} }
Status GetSendStatus() override { Status GetSendStatus() override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call GetSendStatus on a method which "
"It is illegal to call GetSendStatus on a method which " "has a Cancel notification";
"has a Cancel notification");
return Status(); return Status();
} }
void ModifySendStatus(const Status& /*status*/) override { void ModifySendStatus(const Status& /*status*/) override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call ModifySendStatus on a method "
"It is illegal to call ModifySendStatus on a method " "which has a Cancel notification";
"which has a Cancel notification");
} }
std::multimap<std::string, std::string>* GetSendTrailingMetadata() override { std::multimap<std::string, std::string>* GetSendTrailingMetadata() override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call GetSendTrailingMetadata on a "
"It is illegal to call GetSendTrailingMetadata on a " "method which has a Cancel notification";
"method which has a Cancel notification");
return nullptr; return nullptr;
} }
void* GetRecvMessage() override { void* GetRecvMessage() override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call GetRecvMessage on a method which "
"It is illegal to call GetRecvMessage on a method which " "has a Cancel notification";
"has a Cancel notification");
return nullptr; return nullptr;
} }
std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvInitialMetadata() std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvInitialMetadata()
override { override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call GetRecvInitialMetadata on a "
"It is illegal to call GetRecvInitialMetadata on a " "method which has a Cancel notification";
"method which has a Cancel notification");
return nullptr; return nullptr;
} }
Status* GetRecvStatus() override { Status* GetRecvStatus() override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call GetRecvStatus on a method which "
"It is illegal to call GetRecvStatus on a method which " "has a Cancel notification";
"has a Cancel notification");
return nullptr; return nullptr;
} }
std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvTrailingMetadata() std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvTrailingMetadata()
override { override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call GetRecvTrailingMetadata on a "
"It is illegal to call GetRecvTrailingMetadata on a " "method which has a Cancel notification";
"method which has a Cancel notification");
return nullptr; return nullptr;
} }
std::unique_ptr<ChannelInterface> GetInterceptedChannel() override { std::unique_ptr<ChannelInterface> GetInterceptedChannel() override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call GetInterceptedChannel on a "
"It is illegal to call GetInterceptedChannel on a " "method which has a Cancel notification";
"method which has a Cancel notification");
return std::unique_ptr<ChannelInterface>(nullptr); return std::unique_ptr<ChannelInterface>(nullptr);
} }
void FailHijackedRecvMessage() override { void FailHijackedRecvMessage() override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call FailHijackedRecvMessage on a "
"It is illegal to call FailHijackedRecvMessage on a " "method which has a Cancel notification";
"method which has a Cancel notification");
} }
void FailHijackedSendMessage() override { void FailHijackedSendMessage() override {
GPR_ASSERT(false && CHECK(false) << "It is illegal to call FailHijackedSendMessage on a "
"It is illegal to call FailHijackedSendMessage on a " "method which has a Cancel notification";
"method which has a Cancel notification");
} }
}; };
} // namespace internal } // namespace internal

@ -21,6 +21,8 @@
#include <type_traits> #include <type_traits>
#include "absl/log/check.h"
#include <grpc/byte_buffer_reader.h> #include <grpc/byte_buffer_reader.h>
#include <grpc/impl/grpc_types.h> #include <grpc/impl/grpc_types.h>
#include <grpc/slice.h> #include <grpc/slice.h>
@ -51,7 +53,7 @@ Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb,
if (static_cast<size_t>(byte_size) <= GRPC_SLICE_INLINED_SIZE) { if (static_cast<size_t>(byte_size) <= GRPC_SLICE_INLINED_SIZE) {
Slice slice(byte_size); Slice slice(byte_size);
// We serialize directly into the allocated slices memory // We serialize directly into the allocated slices memory
GPR_ASSERT(slice.end() == msg.SerializeWithCachedSizesToArray( CHECK(slice.end() == msg.SerializeWithCachedSizesToArray(
const_cast<uint8_t*>(slice.begin()))); const_cast<uint8_t*>(slice.begin())));
ByteBuffer tmp(&slice, 1); ByteBuffer tmp(&slice, 1);
bb->Swap(&tmp); bb->Swap(&tmp);

@ -25,6 +25,8 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/impl/rpc_method.h> #include <grpcpp/impl/rpc_method.h>
#include <grpcpp/support/byte_buffer.h> #include <grpcpp/support/byte_buffer.h>
@ -75,7 +77,7 @@ class MethodHandler {
// retained by the handler. Returns nullptr if deserialization failed. // retained by the handler. Returns nullptr if deserialization failed.
virtual void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req, virtual void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req,
Status* /*status*/, void** /*handler_data*/) { Status* /*status*/, void** /*handler_data*/) {
GPR_ASSERT(req == nullptr); CHECK_EQ(req, nullptr);
return nullptr; return nullptr;
} }
}; };

@ -18,6 +18,8 @@
#ifndef GRPCPP_IMPL_SERVER_CALLBACK_HANDLERS_H #ifndef GRPCPP_IMPL_SERVER_CALLBACK_HANDLERS_H
#define GRPCPP_IMPL_SERVER_CALLBACK_HANDLERS_H #define GRPCPP_IMPL_SERVER_CALLBACK_HANDLERS_H
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/impl/call.h> #include <grpc/impl/call.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -147,7 +149,7 @@ class CallbackUnaryHandler : public grpc::internal::MethodHandler {
} }
void SendInitialMetadata() override { void SendInitialMetadata() override {
GPR_ASSERT(!ctx_->sent_initial_metadata_); CHECK(!ctx_->sent_initial_metadata_);
this->Ref(); this->Ref();
// The callback for this function should not be marked inline because it // The callback for this function should not be marked inline because it
// is directly invoking a user-controlled reaction // is directly invoking a user-controlled reaction
@ -335,7 +337,7 @@ class CallbackClientStreamingHandler : public grpc::internal::MethodHandler {
} }
void SendInitialMetadata() override { void SendInitialMetadata() override {
GPR_ASSERT(!ctx_->sent_initial_metadata_); CHECK(!ctx_->sent_initial_metadata_);
this->Ref(); this->Ref();
// The callback for this function should not be inlined because it invokes // The callback for this function should not be inlined because it invokes
// a user-controlled reaction, but any resulting OnDone can be inlined in // a user-controlled reaction, but any resulting OnDone can be inlined in
@ -539,7 +541,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
} }
void SendInitialMetadata() override { void SendInitialMetadata() override {
GPR_ASSERT(!ctx_->sent_initial_metadata_); CHECK(!ctx_->sent_initial_metadata_);
this->Ref(); this->Ref();
// The callback for this function should not be inlined because it invokes // The callback for this function should not be inlined because it invokes
// a user-controlled reaction, but any resulting OnDone can be inlined in // a user-controlled reaction, but any resulting OnDone can be inlined in
@ -577,7 +579,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
ctx_->sent_initial_metadata_ = true; ctx_->sent_initial_metadata_ = true;
} }
// TODO(vjpai): don't assert // TODO(vjpai): don't assert
GPR_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); CHECK(write_ops_.SendMessagePtr(resp, options).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
@ -585,7 +587,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
grpc::Status s) override { grpc::Status s) override {
// This combines the write into the finish callback // This combines the write into the finish callback
// TODO(vjpai): don't assert // TODO(vjpai): don't assert
GPR_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); CHECK(finish_ops_.SendMessagePtr(resp, options).ok());
Finish(std::move(s)); Finish(std::move(s));
} }
@ -751,7 +753,7 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler {
} }
void SendInitialMetadata() override { void SendInitialMetadata() override {
GPR_ASSERT(!ctx_->sent_initial_metadata_); CHECK(!ctx_->sent_initial_metadata_);
this->Ref(); this->Ref();
// The callback for this function should not be inlined because it invokes // The callback for this function should not be inlined because it invokes
// a user-controlled reaction, but any resulting OnDone can be inlined in // a user-controlled reaction, but any resulting OnDone can be inlined in
@ -789,14 +791,14 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler {
ctx_->sent_initial_metadata_ = true; ctx_->sent_initial_metadata_ = true;
} }
// TODO(vjpai): don't assert // TODO(vjpai): don't assert
GPR_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); CHECK(write_ops_.SendMessagePtr(resp, options).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
void WriteAndFinish(const ResponseType* resp, grpc::WriteOptions options, void WriteAndFinish(const ResponseType* resp, grpc::WriteOptions options,
grpc::Status s) override { grpc::Status s) override {
// TODO(vjpai): don't assert // TODO(vjpai): don't assert
GPR_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); CHECK(finish_ops_.SendMessagePtr(resp, options).ok());
Finish(std::move(s)); Finish(std::move(s));
} }

@ -19,6 +19,8 @@
#ifndef GRPCPP_IMPL_SERVICE_TYPE_H #ifndef GRPCPP_IMPL_SERVICE_TYPE_H
#define GRPCPP_IMPL_SERVICE_TYPE_H #define GRPCPP_IMPL_SERVICE_TYPE_H
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/impl/rpc_service_method.h> #include <grpcpp/impl/rpc_service_method.h>
#include <grpcpp/impl/serialization_traits.h> #include <grpcpp/impl/serialization_traits.h>
@ -150,9 +152,9 @@ class Service {
// This does not have to be a hard error, however no one has approached us // This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one. // with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index); size_t idx = static_cast<size_t>(index);
GPR_ASSERT(methods_[idx].get() != nullptr && CHECK_NE(methods_[idx].get(), nullptr)
"Cannot mark the method as 'async' because it has already been " << "Cannot mark the method as 'async' because it has already been "
"marked as 'generic'."); "marked as 'generic'.";
methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::ASYNC); methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::ASYNC);
} }
@ -160,9 +162,9 @@ class Service {
// This does not have to be a hard error, however no one has approached us // This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one. // with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index); size_t idx = static_cast<size_t>(index);
GPR_ASSERT(methods_[idx].get() != nullptr && CHECK_NE(methods_[idx].get(), nullptr)
"Cannot mark the method as 'raw' because it has already " << "Cannot mark the method as 'raw' because it has already "
"been marked as 'generic'."); "been marked as 'generic'.";
methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::RAW); methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::RAW);
} }
@ -170,10 +172,9 @@ class Service {
// This does not have to be a hard error, however no one has approached us // This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one. // with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index); size_t idx = static_cast<size_t>(index);
GPR_ASSERT( CHECK_NE(methods_[idx]->handler(), nullptr)
methods_[idx]->handler() != nullptr && << "Cannot mark the method as 'generic' because it has already been "
"Cannot mark the method as 'generic' because it has already been " "marked as 'async' or 'raw'.";
"marked as 'async' or 'raw'.");
methods_[idx].reset(); methods_[idx].reset();
} }
@ -181,8 +182,8 @@ class Service {
// This does not have to be a hard error, however no one has approached us // This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one. // with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index); size_t idx = static_cast<size_t>(index);
GPR_ASSERT(methods_[idx] && methods_[idx]->handler() && CHECK(methods_[idx] && methods_[idx]->handler())
"Cannot mark an async or generic method Streamed"); << "Cannot mark an async or generic method Streamed";
methods_[idx]->SetHandler(streamed_method); methods_[idx]->SetHandler(streamed_method);
// From the server's point of view, streamed unary is a special // From the server's point of view, streamed unary is a special
@ -196,10 +197,9 @@ class Service {
// This does not have to be a hard error, however no one has approached us // This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one. // with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index); size_t idx = static_cast<size_t>(index);
GPR_ASSERT( CHECK_NE(methods_[idx].get(), nullptr)
methods_[idx].get() != nullptr && << "Cannot mark the method as 'callback' because it has already been "
"Cannot mark the method as 'callback' because it has already been " "marked as 'generic'.";
"marked as 'generic'.");
methods_[idx]->SetHandler(handler); methods_[idx]->SetHandler(handler);
methods_[idx]->SetServerApiType( methods_[idx]->SetServerApiType(
internal::RpcServiceMethod::ApiType::CALL_BACK); internal::RpcServiceMethod::ApiType::CALL_BACK);
@ -209,10 +209,9 @@ class Service {
// This does not have to be a hard error, however no one has approached us // This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one. // with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index); size_t idx = static_cast<size_t>(index);
GPR_ASSERT( CHECK_NE(methods_[idx].get(), nullptr)
methods_[idx].get() != nullptr && << "Cannot mark the method as 'raw callback' because it has already "
"Cannot mark the method as 'raw callback' because it has already " "been marked as 'generic'.";
"been marked as 'generic'.");
methods_[idx]->SetHandler(handler); methods_[idx]->SetHandler(handler);
methods_[idx]->SetServerApiType( methods_[idx]->SetServerApiType(
internal::RpcServiceMethod::ApiType::RAW_CALL_BACK); internal::RpcServiceMethod::ApiType::RAW_CALL_BACK);

@ -27,6 +27,7 @@
#include <mutex> #include <mutex>
#include "absl/log/check.h"
#include "absl/synchronization/mutex.h" #include "absl/synchronization/mutex.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -105,7 +106,7 @@ class ABSL_SCOPED_LOCKABLE ReleasableMutexLock {
ReleasableMutexLock& operator=(const ReleasableMutexLock&) = delete; ReleasableMutexLock& operator=(const ReleasableMutexLock&) = delete;
void Release() ABSL_UNLOCK_FUNCTION() { void Release() ABSL_UNLOCK_FUNCTION() {
GPR_DEBUG_ASSERT(!released_); DCHECK(!released_);
released_ = true; released_ = true;
mu_->Unlock(); mu_->Unlock();
} }

@ -19,6 +19,8 @@
#ifndef GRPCPP_SERVER_INTERFACE_H #ifndef GRPCPP_SERVER_INTERFACE_H
#define GRPCPP_SERVER_INTERFACE_H #define GRPCPP_SERVER_INTERFACE_H
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/impl/grpc_types.h> #include <grpc/impl/grpc_types.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -318,7 +320,7 @@ class ServerInterface : public internal::CallHook {
grpc::CompletionQueue* call_cq, grpc::CompletionQueue* call_cq,
grpc::ServerCompletionQueue* notification_cq, void* tag, grpc::ServerCompletionQueue* notification_cq, void* tag,
Message* message) { Message* message) {
GPR_ASSERT(method); CHECK(method);
new PayloadAsyncRequest<Message>(method, this, context, stream, call_cq, new PayloadAsyncRequest<Message>(method, this, context, stream, call_cq,
notification_cq, tag, message); notification_cq, tag, message);
} }
@ -329,7 +331,7 @@ class ServerInterface : public internal::CallHook {
grpc::CompletionQueue* call_cq, grpc::CompletionQueue* call_cq,
grpc::ServerCompletionQueue* notification_cq, grpc::ServerCompletionQueue* notification_cq,
void* tag) { void* tag) {
GPR_ASSERT(method); CHECK(method);
new NoPayloadAsyncRequest(method, this, context, stream, call_cq, new NoPayloadAsyncRequest(method, this, context, stream, call_cq,
notification_cq, tag); notification_cq, tag);
} }

@ -19,6 +19,8 @@
#ifndef GRPCPP_SUPPORT_ASYNC_STREAM_H #ifndef GRPCPP_SUPPORT_ASYNC_STREAM_H
#define GRPCPP_SUPPORT_ASYNC_STREAM_H #define GRPCPP_SUPPORT_ASYNC_STREAM_H
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/impl/call.h> #include <grpcpp/impl/call.h>
@ -200,7 +202,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
public: public:
// always allocated against a call arena, no memory free required // always allocated against a call arena, no memory free required
static void operator delete(void* /*ptr*/, std::size_t size) { static void operator delete(void* /*ptr*/, std::size_t size) {
GPR_ASSERT(size == sizeof(ClientAsyncReader)); CHECK_EQ(size, sizeof(ClientAsyncReader));
} }
// This operator should never be called as the memory should be freed as part // This operator should never be called as the memory should be freed as part
@ -208,10 +210,10 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
// delete to the operator new so that some compilers will not complain (see // delete to the operator new so that some compilers will not complain (see
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
// there are no tests catching the compiler warning. // there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_ASSERT(false); } static void operator delete(void*, void*) { CHECK(false); }
void StartCall(void* tag) override { void StartCall(void* tag) override {
GPR_ASSERT(!started_); CHECK(!started_);
started_ = true; started_ = true;
StartCallInternal(tag); StartCallInternal(tag);
} }
@ -225,8 +227,8 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
/// calling code can access the received metadata through the /// calling code can access the received metadata through the
/// \a ClientContext. /// \a ClientContext.
void ReadInitialMetadata(void* tag) override { void ReadInitialMetadata(void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
GPR_ASSERT(!context_->initial_metadata_received_); CHECK(!context_->initial_metadata_received_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
meta_ops_.RecvInitialMetadata(context_); meta_ops_.RecvInitialMetadata(context_);
@ -234,7 +236,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
} }
void Read(R* msg, void* tag) override { void Read(R* msg, void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
read_ops_.set_output_tag(tag); read_ops_.set_output_tag(tag);
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
read_ops_.RecvInitialMetadata(context_); read_ops_.RecvInitialMetadata(context_);
@ -249,7 +251,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
/// - the \a ClientContext associated with this call is updated with /// - the \a ClientContext associated with this call is updated with
/// possible initial and trailing metadata received from the server. /// possible initial and trailing metadata received from the server.
void Finish(grpc::Status* status, void* tag) override { void Finish(grpc::Status* status, void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
finish_ops_.set_output_tag(tag); finish_ops_.set_output_tag(tag);
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
finish_ops_.RecvInitialMetadata(context_); finish_ops_.RecvInitialMetadata(context_);
@ -265,12 +267,12 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
const W& request, bool start, void* tag) const W& request, bool start, void* tag)
: context_(context), call_(call), started_(start) { : context_(context), call_(call), started_(start) {
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_ASSERT(init_ops_.SendMessage(request).ok()); CHECK(init_ops_.SendMessage(request).ok());
init_ops_.ClientSendClose(); init_ops_.ClientSendClose();
if (start) { if (start) {
StartCallInternal(tag); StartCallInternal(tag);
} else { } else {
GPR_ASSERT(tag == nullptr); CHECK(tag == nullptr);
} }
} }
@ -348,7 +350,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
public: public:
// always allocated against a call arena, no memory free required // always allocated against a call arena, no memory free required
static void operator delete(void* /*ptr*/, std::size_t size) { static void operator delete(void* /*ptr*/, std::size_t size) {
GPR_ASSERT(size == sizeof(ClientAsyncWriter)); CHECK_EQ(size, sizeof(ClientAsyncWriter));
} }
// This operator should never be called as the memory should be freed as part // This operator should never be called as the memory should be freed as part
@ -356,10 +358,10 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
// delete to the operator new so that some compilers will not complain (see // delete to the operator new so that some compilers will not complain (see
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
// there are no tests catching the compiler warning. // there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_ASSERT(false); } static void operator delete(void*, void*) { CHECK(false); }
void StartCall(void* tag) override { void StartCall(void* tag) override {
GPR_ASSERT(!started_); CHECK(!started_);
started_ = true; started_ = true;
StartCallInternal(tag); StartCallInternal(tag);
} }
@ -372,8 +374,8 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
/// associated with this call is updated, and the calling code can access /// associated with this call is updated, and the calling code can access
/// the received metadata through the \a ClientContext. /// the received metadata through the \a ClientContext.
void ReadInitialMetadata(void* tag) override { void ReadInitialMetadata(void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
GPR_ASSERT(!context_->initial_metadata_received_); CHECK(!context_->initial_metadata_received_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
meta_ops_.RecvInitialMetadata(context_); meta_ops_.RecvInitialMetadata(context_);
@ -381,27 +383,27 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
} }
void Write(const W& msg, void* tag) override { void Write(const W& msg, void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_ASSERT(write_ops_.SendMessage(msg).ok()); CHECK(write_ops_.SendMessage(msg).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
void Write(const W& msg, grpc::WriteOptions options, void* tag) override { void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
if (options.is_last_message()) { if (options.is_last_message()) {
options.set_buffer_hint(); options.set_buffer_hint();
write_ops_.ClientSendClose(); write_ops_.ClientSendClose();
} }
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_ASSERT(write_ops_.SendMessage(msg, options).ok()); CHECK(write_ops_.SendMessage(msg, options).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
void WritesDone(void* tag) override { void WritesDone(void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
write_ops_.ClientSendClose(); write_ops_.ClientSendClose();
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
@ -415,7 +417,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
/// - attempts to fill in the \a response parameter passed to this class's /// - attempts to fill in the \a response parameter passed to this class's
/// constructor with the server's response message. /// constructor with the server's response message.
void Finish(grpc::Status* status, void* tag) override { void Finish(grpc::Status* status, void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
finish_ops_.set_output_tag(tag); finish_ops_.set_output_tag(tag);
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
finish_ops_.RecvInitialMetadata(context_); finish_ops_.RecvInitialMetadata(context_);
@ -435,7 +437,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
if (start) { if (start) {
StartCallInternal(tag); StartCallInternal(tag);
} else { } else {
GPR_ASSERT(tag == nullptr); CHECK(tag == nullptr);
} }
} }
@ -515,7 +517,7 @@ class ClientAsyncReaderWriter final
public: public:
// always allocated against a call arena, no memory free required // always allocated against a call arena, no memory free required
static void operator delete(void* /*ptr*/, std::size_t size) { static void operator delete(void* /*ptr*/, std::size_t size) {
GPR_ASSERT(size == sizeof(ClientAsyncReaderWriter)); CHECK_EQ(size, sizeof(ClientAsyncReaderWriter));
} }
// This operator should never be called as the memory should be freed as part // This operator should never be called as the memory should be freed as part
@ -523,10 +525,10 @@ class ClientAsyncReaderWriter final
// delete to the operator new so that some compilers will not complain (see // delete to the operator new so that some compilers will not complain (see
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
// there are no tests catching the compiler warning. // there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_ASSERT(false); } static void operator delete(void*, void*) { CHECK(false); }
void StartCall(void* tag) override { void StartCall(void* tag) override {
GPR_ASSERT(!started_); CHECK(!started_);
started_ = true; started_ = true;
StartCallInternal(tag); StartCallInternal(tag);
} }
@ -539,8 +541,8 @@ class ClientAsyncReaderWriter final
/// is updated with it, and then the receiving initial metadata can /// is updated with it, and then the receiving initial metadata can
/// be accessed through this \a ClientContext. /// be accessed through this \a ClientContext.
void ReadInitialMetadata(void* tag) override { void ReadInitialMetadata(void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
GPR_ASSERT(!context_->initial_metadata_received_); CHECK(!context_->initial_metadata_received_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
meta_ops_.RecvInitialMetadata(context_); meta_ops_.RecvInitialMetadata(context_);
@ -548,7 +550,7 @@ class ClientAsyncReaderWriter final
} }
void Read(R* msg, void* tag) override { void Read(R* msg, void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
read_ops_.set_output_tag(tag); read_ops_.set_output_tag(tag);
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
read_ops_.RecvInitialMetadata(context_); read_ops_.RecvInitialMetadata(context_);
@ -558,27 +560,27 @@ class ClientAsyncReaderWriter final
} }
void Write(const W& msg, void* tag) override { void Write(const W& msg, void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_ASSERT(write_ops_.SendMessage(msg).ok()); CHECK(write_ops_.SendMessage(msg).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
void Write(const W& msg, grpc::WriteOptions options, void* tag) override { void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
if (options.is_last_message()) { if (options.is_last_message()) {
options.set_buffer_hint(); options.set_buffer_hint();
write_ops_.ClientSendClose(); write_ops_.ClientSendClose();
} }
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_ASSERT(write_ops_.SendMessage(msg, options).ok()); CHECK(write_ops_.SendMessage(msg, options).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
void WritesDone(void* tag) override { void WritesDone(void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
write_ops_.ClientSendClose(); write_ops_.ClientSendClose();
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
@ -589,7 +591,7 @@ class ClientAsyncReaderWriter final
/// - the \a ClientContext associated with this call is updated with /// - the \a ClientContext associated with this call is updated with
/// possible initial and trailing metadata sent from the server. /// possible initial and trailing metadata sent from the server.
void Finish(grpc::Status* status, void* tag) override { void Finish(grpc::Status* status, void* tag) override {
GPR_ASSERT(started_); CHECK(started_);
finish_ops_.set_output_tag(tag); finish_ops_.set_output_tag(tag);
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
finish_ops_.RecvInitialMetadata(context_); finish_ops_.RecvInitialMetadata(context_);
@ -606,7 +608,7 @@ class ClientAsyncReaderWriter final
if (start) { if (start) {
StartCallInternal(tag); StartCallInternal(tag);
} else { } else {
GPR_ASSERT(tag == nullptr); CHECK(tag == nullptr);
} }
} }
@ -706,7 +708,7 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
/// - The initial metadata that will be sent to the client from this op will /// - The initial metadata that will be sent to the client from this op will
/// be taken from the \a ServerContext associated with the call. /// be taken from the \a ServerContext associated with the call.
void SendInitialMetadata(void* tag) override { void SendInitialMetadata(void* tag) override {
GPR_ASSERT(!ctx_->sent_initial_metadata_); CHECK(!ctx_->sent_initial_metadata_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
@ -765,7 +767,7 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
/// gRPC doesn't take ownership or a reference to \a status, so it is safe to /// gRPC doesn't take ownership or a reference to \a status, so it is safe to
/// to deallocate once FinishWithError returns. /// to deallocate once FinishWithError returns.
void FinishWithError(const grpc::Status& status, void* tag) override { void FinishWithError(const grpc::Status& status, void* tag) override {
GPR_ASSERT(!status.ok()); CHECK(!status.ok());
finish_ops_.set_output_tag(tag); finish_ops_.set_output_tag(tag);
if (!ctx_->sent_initial_metadata_) { if (!ctx_->sent_initial_metadata_) {
finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
@ -855,7 +857,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
/// ///
/// \param[in] tag Tag identifying this request. /// \param[in] tag Tag identifying this request.
void SendInitialMetadata(void* tag) override { void SendInitialMetadata(void* tag) override {
GPR_ASSERT(!ctx_->sent_initial_metadata_); CHECK(!ctx_->sent_initial_metadata_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
@ -871,7 +873,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
EnsureInitialMetadataSent(&write_ops_); EnsureInitialMetadataSent(&write_ops_);
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_ASSERT(write_ops_.SendMessage(msg).ok()); CHECK(write_ops_.SendMessage(msg).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
@ -883,7 +885,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
EnsureInitialMetadataSent(&write_ops_); EnsureInitialMetadataSent(&write_ops_);
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_ASSERT(write_ops_.SendMessage(msg, options).ok()); CHECK(write_ops_.SendMessage(msg, options).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
@ -902,7 +904,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
EnsureInitialMetadataSent(&write_ops_); EnsureInitialMetadataSent(&write_ops_);
options.set_buffer_hint(); options.set_buffer_hint();
GPR_ASSERT(write_ops_.SendMessage(msg, options).ok()); CHECK(write_ops_.SendMessage(msg, options).ok());
write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
@ -1021,7 +1023,7 @@ class ServerAsyncReaderWriter final
/// ///
/// \param[in] tag Tag identifying this request. /// \param[in] tag Tag identifying this request.
void SendInitialMetadata(void* tag) override { void SendInitialMetadata(void* tag) override {
GPR_ASSERT(!ctx_->sent_initial_metadata_); CHECK(!ctx_->sent_initial_metadata_);
meta_ops_.set_output_tag(tag); meta_ops_.set_output_tag(tag);
meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
@ -1043,7 +1045,7 @@ class ServerAsyncReaderWriter final
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
EnsureInitialMetadataSent(&write_ops_); EnsureInitialMetadataSent(&write_ops_);
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_ASSERT(write_ops_.SendMessage(msg).ok()); CHECK(write_ops_.SendMessage(msg).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
@ -1053,7 +1055,7 @@ class ServerAsyncReaderWriter final
options.set_buffer_hint(); options.set_buffer_hint();
} }
EnsureInitialMetadataSent(&write_ops_); EnsureInitialMetadataSent(&write_ops_);
GPR_ASSERT(write_ops_.SendMessage(msg, options).ok()); CHECK(write_ops_.SendMessage(msg, options).ok());
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }
@ -1073,7 +1075,7 @@ class ServerAsyncReaderWriter final
write_ops_.set_output_tag(tag); write_ops_.set_output_tag(tag);
EnsureInitialMetadataSent(&write_ops_); EnsureInitialMetadataSent(&write_ops_);
options.set_buffer_hint(); options.set_buffer_hint();
GPR_ASSERT(write_ops_.SendMessage(msg, options).ok()); CHECK(write_ops_.SendMessage(msg, options).ok());
write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
call_.PerformOps(&write_ops_); call_.PerformOps(&write_ops_);
} }

@ -19,6 +19,8 @@
#ifndef GRPCPP_SUPPORT_ASYNC_UNARY_CALL_H #ifndef GRPCPP_SUPPORT_ASYNC_UNARY_CALL_H
#define GRPCPP_SUPPORT_ASYNC_UNARY_CALL_H #define GRPCPP_SUPPORT_ASYNC_UNARY_CALL_H
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/client_context.h> #include <grpcpp/client_context.h>
@ -130,7 +132,7 @@ class ClientAsyncResponseReaderHelper {
new (grpc_call_arena_alloc(call, sizeof(SingleBufType))) SingleBufType; new (grpc_call_arena_alloc(call, sizeof(SingleBufType))) SingleBufType;
*single_buf_ptr = single_buf; *single_buf_ptr = single_buf;
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_ASSERT(single_buf->SendMessage(request).ok()); CHECK(single_buf->SendMessage(request).ok());
single_buf->ClientSendClose(); single_buf->ClientSendClose();
// The purpose of the following functions is to type-erase the actual // The purpose of the following functions is to type-erase the actual
@ -220,7 +222,7 @@ class ClientAsyncResponseReader final
public: public:
// always allocated against a call arena, no memory free required // always allocated against a call arena, no memory free required
static void operator delete(void* /*ptr*/, std::size_t size) { static void operator delete(void* /*ptr*/, std::size_t size) {
GPR_ASSERT(size == sizeof(ClientAsyncResponseReader)); CHECK_EQ(size, sizeof(ClientAsyncResponseReader));
} }
// This operator should never be called as the memory should be freed as part // This operator should never be called as the memory should be freed as part
@ -228,10 +230,10 @@ class ClientAsyncResponseReader final
// delete to the operator new so that some compilers will not complain (see // delete to the operator new so that some compilers will not complain (see
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
// there are no tests catching the compiler warning. // there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_ASSERT(false); } static void operator delete(void*, void*) { CHECK(false); }
void StartCall() override { void StartCall() override {
GPR_DEBUG_ASSERT(!started_); DCHECK(!started_);
started_ = true; started_ = true;
internal::ClientAsyncResponseReaderHelper::StartCall(context_, single_buf_); internal::ClientAsyncResponseReaderHelper::StartCall(context_, single_buf_);
} }
@ -243,8 +245,8 @@ class ClientAsyncResponseReader final
/// - the \a ClientContext associated with this call is updated with /// - the \a ClientContext associated with this call is updated with
/// possible initial and trailing metadata sent from the server. /// possible initial and trailing metadata sent from the server.
void ReadInitialMetadata(void* tag) override { void ReadInitialMetadata(void* tag) override {
GPR_DEBUG_ASSERT(started_); DCHECK(started_);
GPR_DEBUG_ASSERT(!context_->initial_metadata_received_); DCHECK(!context_->initial_metadata_received_);
read_initial_metadata_(context_, &call_, single_buf_, tag); read_initial_metadata_(context_, &call_, single_buf_, tag);
initial_metadata_read_ = true; initial_metadata_read_ = true;
} }
@ -255,7 +257,7 @@ class ClientAsyncResponseReader final
/// - the \a ClientContext associated with this call is updated with /// - the \a ClientContext associated with this call is updated with
/// possible initial and trailing metadata sent from the server. /// possible initial and trailing metadata sent from the server.
void Finish(R* msg, grpc::Status* status, void* tag) override { void Finish(R* msg, grpc::Status* status, void* tag) override {
GPR_DEBUG_ASSERT(started_); DCHECK(started_);
finish_(context_, &call_, initial_metadata_read_, single_buf_, &finish_buf_, finish_(context_, &call_, initial_metadata_read_, single_buf_, &finish_buf_,
static_cast<void*>(msg), status, tag); static_cast<void*>(msg), status, tag);
} }
@ -304,7 +306,7 @@ class ServerAsyncResponseWriter final
/// ///
/// \param[in] tag Tag identifying this request. /// \param[in] tag Tag identifying this request.
void SendInitialMetadata(void* tag) override { void SendInitialMetadata(void* tag) override {
GPR_ASSERT(!ctx_->sent_initial_metadata_); CHECK(!ctx_->sent_initial_metadata_);
meta_buf_.set_output_tag(tag); meta_buf_.set_output_tag(tag);
meta_buf_.SendInitialMetadata(&ctx_->initial_metadata_, meta_buf_.SendInitialMetadata(&ctx_->initial_metadata_,
@ -373,7 +375,7 @@ class ServerAsyncResponseWriter final
/// deallocate them once the Finish operation is complete (i.e. a result /// deallocate them once the Finish operation is complete (i.e. a result
/// arrives in the completion queue). /// arrives in the completion queue).
void FinishWithError(const grpc::Status& status, void* tag) { void FinishWithError(const grpc::Status& status, void* tag) {
GPR_ASSERT(!status.ok()); CHECK(!status.ok());
finish_buf_.set_output_tag(tag); finish_buf_.set_output_tag(tag);
if (!ctx_->sent_initial_metadata_) { if (!ctx_->sent_initial_metadata_) {
finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_, finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_,

@ -21,6 +21,8 @@
#include <functional> #include <functional>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/impl/grpc_types.h> #include <grpc/impl/grpc_types.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -71,7 +73,7 @@ class CallbackWithStatusTag : public grpc_completion_queue_functor {
public: public:
// always allocated against a call arena, no memory free required // always allocated against a call arena, no memory free required
static void operator delete(void* /*ptr*/, std::size_t size) { static void operator delete(void* /*ptr*/, std::size_t size) {
GPR_ASSERT(size == sizeof(CallbackWithStatusTag)); CHECK_EQ(size, sizeof(CallbackWithStatusTag));
} }
// This operator should never be called as the memory should be freed as part // This operator should never be called as the memory should be freed as part
@ -79,7 +81,7 @@ class CallbackWithStatusTag : public grpc_completion_queue_functor {
// delete to the operator new so that some compilers will not complain (see // delete to the operator new so that some compilers will not complain (see
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
// there are no tests catching the compiler warning. // there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_ASSERT(false); } static void operator delete(void*, void*) { CHECK(false); }
CallbackWithStatusTag(grpc_call* call, std::function<void(Status)> f, CallbackWithStatusTag(grpc_call* call, std::function<void(Status)> f,
CompletionQueueTag* ops) CompletionQueueTag* ops)
@ -118,7 +120,7 @@ class CallbackWithStatusTag : public grpc_completion_queue_functor {
// The tag was swallowed // The tag was swallowed
return; return;
} }
GPR_ASSERT(ignored == ops_); CHECK(ignored == ops_);
// Last use of func_ or status_, so ok to move them out // Last use of func_ or status_, so ok to move them out
auto func = std::move(func_); auto func = std::move(func_);
@ -137,7 +139,7 @@ class CallbackWithSuccessTag : public grpc_completion_queue_functor {
public: public:
// always allocated against a call arena, no memory free required // always allocated against a call arena, no memory free required
static void operator delete(void* /*ptr*/, std::size_t size) { static void operator delete(void* /*ptr*/, std::size_t size) {
GPR_ASSERT(size == sizeof(CallbackWithSuccessTag)); CHECK_EQ(size, sizeof(CallbackWithSuccessTag));
} }
// This operator should never be called as the memory should be freed as part // This operator should never be called as the memory should be freed as part
@ -145,7 +147,7 @@ class CallbackWithSuccessTag : public grpc_completion_queue_functor {
// delete to the operator new so that some compilers will not complain (see // delete to the operator new so that some compilers will not complain (see
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
// there are no tests catching the compiler warning. // there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_ASSERT(false); } static void operator delete(void*, void*) { CHECK(false); }
CallbackWithSuccessTag() : call_(nullptr) {} CallbackWithSuccessTag() : call_(nullptr) {}
@ -162,7 +164,7 @@ class CallbackWithSuccessTag : public grpc_completion_queue_functor {
// callbacks. // callbacks.
void Set(grpc_call* call, std::function<void(bool)> f, void Set(grpc_call* call, std::function<void(bool)> f,
CompletionQueueTag* ops, bool can_inline) { CompletionQueueTag* ops, bool can_inline) {
GPR_ASSERT(call_ == nullptr); CHECK_EQ(call_, nullptr);
grpc_call_ref(call); grpc_call_ref(call);
call_ = call; call_ = call;
func_ = std::move(f); func_ = std::move(f);
@ -208,7 +210,7 @@ class CallbackWithSuccessTag : public grpc_completion_queue_functor {
#endif #endif
bool do_callback = ops_->FinalizeResult(&ignored, &ok); bool do_callback = ops_->FinalizeResult(&ignored, &ok);
#ifndef NDEBUG #ifndef NDEBUG
GPR_DEBUG_ASSERT(ignored == ops); DCHECK(ignored == ops);
#endif #endif
if (do_callback) { if (do_callback) {

@ -22,6 +22,8 @@
#include <atomic> #include <atomic>
#include <functional> #include <functional>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/impl/call.h> #include <grpc/impl/call.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -70,7 +72,7 @@ class CallbackUnaryCallImpl {
const InputMessage* request, OutputMessage* result, const InputMessage* request, OutputMessage* result,
std::function<void(grpc::Status)> on_completion) { std::function<void(grpc::Status)> on_completion) {
grpc::CompletionQueue* cq = channel->CallbackCQ(); grpc::CompletionQueue* cq = channel->CallbackCQ();
GPR_ASSERT(cq != nullptr); CHECK_NE(cq, nullptr);
grpc::internal::Call call(channel->CreateCall(method, context, cq)); grpc::internal::Call call(channel->CreateCall(method, context, cq));
using FullCallOpSet = grpc::internal::CallOpSet< using FullCallOpSet = grpc::internal::CallOpSet<
@ -304,7 +306,7 @@ class ClientBidiReactor : public internal::ClientReactor {
/// The argument to AddMultipleHolds must be positive. /// The argument to AddMultipleHolds must be positive.
void AddHold() { AddMultipleHolds(1); } void AddHold() { AddMultipleHolds(1); }
void AddMultipleHolds(int holds) { void AddMultipleHolds(int holds) {
GPR_DEBUG_ASSERT(holds > 0); DCHECK_GT(holds, 0);
stream_->AddHold(holds); stream_->AddHold(holds);
} }
void RemoveHold() { stream_->RemoveHold(); } void RemoveHold() { stream_->RemoveHold(); }
@ -368,7 +370,7 @@ class ClientReadReactor : public internal::ClientReactor {
void AddHold() { AddMultipleHolds(1); } void AddHold() { AddMultipleHolds(1); }
void AddMultipleHolds(int holds) { void AddMultipleHolds(int holds) {
GPR_DEBUG_ASSERT(holds > 0); DCHECK_GT(holds, 0);
reader_->AddHold(holds); reader_->AddHold(holds);
} }
void RemoveHold() { reader_->RemoveHold(); } void RemoveHold() { reader_->RemoveHold(); }
@ -400,7 +402,7 @@ class ClientWriteReactor : public internal::ClientReactor {
void AddHold() { AddMultipleHolds(1); } void AddHold() { AddMultipleHolds(1); }
void AddMultipleHolds(int holds) { void AddMultipleHolds(int holds) {
GPR_DEBUG_ASSERT(holds > 0); DCHECK_GT(holds, 0);
writer_->AddHold(holds); writer_->AddHold(holds);
} }
void RemoveHold() { writer_->RemoveHold(); } void RemoveHold() { writer_->RemoveHold(); }
@ -461,7 +463,7 @@ class ClientCallbackReaderWriterImpl
public: public:
// always allocated against a call arena, no memory free required // always allocated against a call arena, no memory free required
static void operator delete(void* /*ptr*/, std::size_t size) { static void operator delete(void* /*ptr*/, std::size_t size) {
GPR_ASSERT(size == sizeof(ClientCallbackReaderWriterImpl)); CHECK_EQ(size, sizeof(ClientCallbackReaderWriterImpl));
} }
// This operator should never be called as the memory should be freed as part // This operator should never be called as the memory should be freed as part
@ -469,7 +471,7 @@ class ClientCallbackReaderWriterImpl
// delete to the operator new so that some compilers will not complain (see // delete to the operator new so that some compilers will not complain (see
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
// there are no tests catching the compiler warning. // there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_ASSERT(false); } static void operator delete(void*, void*) { CHECK(false); }
void StartCall() ABSL_LOCKS_EXCLUDED(start_mu_) override { void StartCall() ABSL_LOCKS_EXCLUDED(start_mu_) override {
// This call initiates two batches, plus any backlog, each with a callback // This call initiates two batches, plus any backlog, each with a callback
@ -527,7 +529,7 @@ class ClientCallbackReaderWriterImpl
write_ops_.ClientSendClose(); write_ops_.ClientSendClose();
} }
// TODO(vjpai): don't assert // TODO(vjpai): don't assert
GPR_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); CHECK(write_ops_.SendMessagePtr(msg, options).ok());
callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed);
if (GPR_UNLIKELY(corked_write_needed_)) { if (GPR_UNLIKELY(corked_write_needed_)) {
write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
@ -719,7 +721,7 @@ class ClientCallbackReaderImpl : public ClientCallbackReader<Response> {
public: public:
// always allocated against a call arena, no memory free required // always allocated against a call arena, no memory free required
static void operator delete(void* /*ptr*/, std::size_t size) { static void operator delete(void* /*ptr*/, std::size_t size) {
GPR_ASSERT(size == sizeof(ClientCallbackReaderImpl)); CHECK_EQ(size, sizeof(ClientCallbackReaderImpl));
} }
// This operator should never be called as the memory should be freed as part // This operator should never be called as the memory should be freed as part
@ -727,7 +729,7 @@ class ClientCallbackReaderImpl : public ClientCallbackReader<Response> {
// delete to the operator new so that some compilers will not complain (see // delete to the operator new so that some compilers will not complain (see
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
// there are no tests catching the compiler warning. // there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_ASSERT(false); } static void operator delete(void*, void*) { CHECK(false); }
void StartCall() override { void StartCall() override {
// This call initiates two batches, plus any backlog, each with a callback // This call initiates two batches, plus any backlog, each with a callback
@ -804,7 +806,7 @@ class ClientCallbackReaderImpl : public ClientCallbackReader<Response> {
: context_(context), call_(call), reactor_(reactor) { : context_(context), call_(call), reactor_(reactor) {
this->BindReactor(reactor); this->BindReactor(reactor);
// TODO(vjpai): don't assert // TODO(vjpai): don't assert
GPR_ASSERT(start_ops_.SendMessagePtr(request).ok()); CHECK(start_ops_.SendMessagePtr(request).ok());
start_ops_.ClientSendClose(); start_ops_.ClientSendClose();
} }
@ -880,7 +882,7 @@ class ClientCallbackWriterImpl : public ClientCallbackWriter<Request> {
public: public:
// always allocated against a call arena, no memory free required // always allocated against a call arena, no memory free required
static void operator delete(void* /*ptr*/, std::size_t size) { static void operator delete(void* /*ptr*/, std::size_t size) {
GPR_ASSERT(size == sizeof(ClientCallbackWriterImpl)); CHECK_EQ(size, sizeof(ClientCallbackWriterImpl));
} }
// This operator should never be called as the memory should be freed as part // This operator should never be called as the memory should be freed as part
@ -888,7 +890,7 @@ class ClientCallbackWriterImpl : public ClientCallbackWriter<Request> {
// delete to the operator new so that some compilers will not complain (see // delete to the operator new so that some compilers will not complain (see
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
// there are no tests catching the compiler warning. // there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_ASSERT(false); } static void operator delete(void*, void*) { CHECK(false); }
void StartCall() ABSL_LOCKS_EXCLUDED(start_mu_) override { void StartCall() ABSL_LOCKS_EXCLUDED(start_mu_) override {
// This call initiates two batches, plus any backlog, each with a callback // This call initiates two batches, plus any backlog, each with a callback
@ -929,7 +931,7 @@ class ClientCallbackWriterImpl : public ClientCallbackWriter<Request> {
write_ops_.ClientSendClose(); write_ops_.ClientSendClose();
} }
// TODO(vjpai): don't assert // TODO(vjpai): don't assert
GPR_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); CHECK(write_ops_.SendMessagePtr(msg, options).ok());
callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed);
if (GPR_UNLIKELY(corked_write_needed_)) { if (GPR_UNLIKELY(corked_write_needed_)) {
@ -1110,7 +1112,7 @@ class ClientCallbackUnaryImpl final : public ClientCallbackUnary {
public: public:
// always allocated against a call arena, no memory free required // always allocated against a call arena, no memory free required
static void operator delete(void* /*ptr*/, std::size_t size) { static void operator delete(void* /*ptr*/, std::size_t size) {
GPR_ASSERT(size == sizeof(ClientCallbackUnaryImpl)); CHECK_EQ(size, sizeof(ClientCallbackUnaryImpl));
} }
// This operator should never be called as the memory should be freed as part // This operator should never be called as the memory should be freed as part
@ -1118,7 +1120,7 @@ class ClientCallbackUnaryImpl final : public ClientCallbackUnary {
// delete to the operator new so that some compilers will not complain (see // delete to the operator new so that some compilers will not complain (see
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
// there are no tests catching the compiler warning. // there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_ASSERT(false); } static void operator delete(void*, void*) { CHECK(false); }
void StartCall() override { void StartCall() override {
// This call initiates two batches, each with a callback // This call initiates two batches, each with a callback
@ -1157,7 +1159,7 @@ class ClientCallbackUnaryImpl final : public ClientCallbackUnary {
: context_(context), call_(call), reactor_(reactor) { : context_(context), call_(call), reactor_(reactor) {
this->BindReactor(reactor); this->BindReactor(reactor);
// TODO(vjpai): don't assert // TODO(vjpai): don't assert
GPR_ASSERT(start_ops_.SendMessagePtr(request).ok()); CHECK(start_ops_.SendMessagePtr(request).ok());
start_ops_.ClientSendClose(); start_ops_.ClientSendClose();
finish_ops_.RecvMessage(response); finish_ops_.RecvMessage(response);
finish_ops_.AllowNoMessage(); finish_ops_.AllowNoMessage();

@ -22,6 +22,8 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/impl/rpc_method.h> #include <grpcpp/impl/rpc_method.h>
#include <grpcpp/support/interceptor.h> #include <grpcpp/support/interceptor.h>
@ -139,7 +141,7 @@ class ClientRpcInfo {
// Runs interceptor at pos \a pos. // Runs interceptor at pos \a pos.
void RunInterceptor( void RunInterceptor(
experimental::InterceptorBatchMethods* interceptor_methods, size_t pos) { experimental::InterceptorBatchMethods* interceptor_methods, size_t pos) {
GPR_ASSERT(pos < interceptors_.size()); CHECK_LT(pos, interceptors_.size());
interceptors_[pos]->Intercept(interceptor_methods); interceptors_[pos]->Intercept(interceptor_methods);
} }

@ -19,6 +19,8 @@
#ifndef GRPCPP_SUPPORT_METHOD_HANDLER_H #ifndef GRPCPP_SUPPORT_METHOD_HANDLER_H
#define GRPCPP_SUPPORT_METHOD_HANDLER_H #define GRPCPP_SUPPORT_METHOD_HANDLER_H
#include "absl/log/check.h"
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/impl/rpc_service_method.h> #include <grpcpp/impl/rpc_service_method.h>
@ -57,7 +59,7 @@ template <class Callable>
template <class ResponseType> template <class ResponseType>
void UnaryRunHandlerHelper(const MethodHandler::HandlerParameter& param, void UnaryRunHandlerHelper(const MethodHandler::HandlerParameter& param,
ResponseType* rsp, grpc::Status& status) { ResponseType* rsp, grpc::Status& status) {
GPR_ASSERT(!param.server_context->sent_initial_metadata_); CHECK(!param.server_context->sent_initial_metadata_);
grpc::internal::CallOpSet<grpc::internal::CallOpSendInitialMetadata, grpc::internal::CallOpSet<grpc::internal::CallOpSendInitialMetadata,
grpc::internal::CallOpSendMessage, grpc::internal::CallOpSendMessage,
grpc::internal::CallOpServerSendStatus> grpc::internal::CallOpServerSendStatus>

@ -21,6 +21,7 @@
#include <type_traits> #include <type_traits>
#include "absl/log/check.h"
#include "absl/strings/cord.h" #include "absl/strings/cord.h"
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
@ -75,7 +76,7 @@ class ProtoBufferReader : public grpc::protobuf::io::ZeroCopyInputStream {
if (backup_count_ > 0) { if (backup_count_ > 0) {
*data = GRPC_SLICE_START_PTR(*slice_) + GRPC_SLICE_LENGTH(*slice_) - *data = GRPC_SLICE_START_PTR(*slice_) + GRPC_SLICE_LENGTH(*slice_) -
backup_count_; backup_count_;
GPR_ASSERT(backup_count_ <= INT_MAX); CHECK_LE(backup_count_, INT_MAX);
*size = static_cast<int>(backup_count_); *size = static_cast<int>(backup_count_);
backup_count_ = 0; backup_count_ = 0;
return true; return true;
@ -86,7 +87,7 @@ class ProtoBufferReader : public grpc::protobuf::io::ZeroCopyInputStream {
} }
*data = GRPC_SLICE_START_PTR(*slice_); *data = GRPC_SLICE_START_PTR(*slice_);
// On win x64, int is only 32bit // On win x64, int is only 32bit
GPR_ASSERT(GRPC_SLICE_LENGTH(*slice_) <= INT_MAX); CHECK_LE(GRPC_SLICE_LENGTH(*slice_), static_cast<size_t>(INT_MAX));
byte_count_ += * size = static_cast<int>(GRPC_SLICE_LENGTH(*slice_)); byte_count_ += * size = static_cast<int>(GRPC_SLICE_LENGTH(*slice_));
return true; return true;
} }
@ -98,7 +99,7 @@ class ProtoBufferReader : public grpc::protobuf::io::ZeroCopyInputStream {
/// bytes that have already been returned by the last call of Next. /// bytes that have already been returned by the last call of Next.
/// So do the backup and have that ready for a later Next. /// So do the backup and have that ready for a later Next.
void BackUp(int count) override { void BackUp(int count) override {
GPR_ASSERT(count <= static_cast<int>(GRPC_SLICE_LENGTH(*slice_))); CHECK_LE(count, static_cast<int>(GRPC_SLICE_LENGTH(*slice_)));
backup_count_ = count; backup_count_ = count;
} }
@ -174,7 +175,7 @@ class ProtoBufferReader : public grpc::protobuf::io::ZeroCopyInputStream {
return true; return true;
} }
} }
GPR_ASSERT(count == 0); CHECK_EQ(count, 0);
return true; return true;
} }
#endif // GRPC_PROTOBUF_CORD_SUPPORT_ENABLED #endif // GRPC_PROTOBUF_CORD_SUPPORT_ENABLED

@ -21,6 +21,7 @@
#include <type_traits> #include <type_traits>
#include "absl/log/check.h"
#include "absl/strings/cord.h" #include "absl/strings/cord.h"
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
@ -64,7 +65,7 @@ class ProtoBufferWriter : public grpc::protobuf::io::ZeroCopyOutputStream {
total_size_(total_size), total_size_(total_size),
byte_count_(0), byte_count_(0),
have_backup_(false) { have_backup_(false) {
GPR_ASSERT(!byte_buffer->Valid()); CHECK(!byte_buffer->Valid());
/// Create an empty raw byte buffer and look at its underlying slice buffer /// Create an empty raw byte buffer and look at its underlying slice buffer
grpc_byte_buffer* bp = grpc_raw_byte_buffer_create(nullptr, 0); grpc_byte_buffer* bp = grpc_raw_byte_buffer_create(nullptr, 0);
byte_buffer->set_buffer(bp); byte_buffer->set_buffer(bp);
@ -81,7 +82,7 @@ class ProtoBufferWriter : public grpc::protobuf::io::ZeroCopyOutputStream {
/// safe for the caller to write from data[0, size - 1]. /// safe for the caller to write from data[0, size - 1].
bool Next(void** data, int* size) override { bool Next(void** data, int* size) override {
// Protobuf should not ask for more memory than total_size_. // Protobuf should not ask for more memory than total_size_.
GPR_ASSERT(byte_count_ < total_size_); CHECK_LT(byte_count_, total_size_);
// 1. Use the remaining backup slice if we have one // 1. Use the remaining backup slice if we have one
// 2. Otherwise allocate a slice, up to the remaining length needed // 2. Otherwise allocate a slice, up to the remaining length needed
// or our maximum allocation size // or our maximum allocation size
@ -106,7 +107,7 @@ class ProtoBufferWriter : public grpc::protobuf::io::ZeroCopyOutputStream {
} }
*data = GRPC_SLICE_START_PTR(slice_); *data = GRPC_SLICE_START_PTR(slice_);
// On win x64, int is only 32bit // On win x64, int is only 32bit
GPR_ASSERT(GRPC_SLICE_LENGTH(slice_) <= INT_MAX); CHECK(GRPC_SLICE_LENGTH(slice_) <= static_cast<size_t>(INT_MAX));
byte_count_ += * size = static_cast<int>(GRPC_SLICE_LENGTH(slice_)); byte_count_ += * size = static_cast<int>(GRPC_SLICE_LENGTH(slice_));
// Using grpc_slice_buffer_add could modify slice_ and merge it with the // Using grpc_slice_buffer_add could modify slice_ and merge it with the
// previous slice. Therefore, use grpc_slice_buffer_add_indexed method to // previous slice. Therefore, use grpc_slice_buffer_add_indexed method to
@ -131,7 +132,7 @@ class ProtoBufferWriter : public grpc::protobuf::io::ZeroCopyOutputStream {
/// 2. Split it into the needed (if any) and unneeded part /// 2. Split it into the needed (if any) and unneeded part
/// 3. Add the needed part back to the slice buffer /// 3. Add the needed part back to the slice buffer
/// 4. Mark that we still have the remaining part (for later use/unref) /// 4. Mark that we still have the remaining part (for later use/unref)
GPR_ASSERT(count <= static_cast<int>(GRPC_SLICE_LENGTH(slice_))); CHECK_LE(count, static_cast<int>(GRPC_SLICE_LENGTH(slice_)));
grpc_slice_buffer_pop(slice_buffer_); grpc_slice_buffer_pop(slice_buffer_);
if (static_cast<size_t>(count) == GRPC_SLICE_LENGTH(slice_)) { if (static_cast<size_t>(count) == GRPC_SLICE_LENGTH(slice_)) {
backup_slice_ = slice_; backup_slice_ = slice_;

@ -22,6 +22,8 @@
#include <atomic> #include <atomic>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/impl/rpc_method.h> #include <grpcpp/impl/rpc_method.h>
#include <grpcpp/support/interceptor.h> #include <grpcpp/support/interceptor.h>
@ -100,7 +102,7 @@ class ServerRpcInfo {
// Runs interceptor at pos \a pos. // Runs interceptor at pos \a pos.
void RunInterceptor( void RunInterceptor(
experimental::InterceptorBatchMethods* interceptor_methods, size_t pos) { experimental::InterceptorBatchMethods* interceptor_methods, size_t pos) {
GPR_ASSERT(pos < interceptors_.size()); CHECK_LT(pos, interceptors_.size());
interceptors_[pos]->Intercept(interceptor_methods); interceptors_[pos]->Intercept(interceptor_methods);
} }

@ -19,6 +19,8 @@
#ifndef GRPCPP_SUPPORT_SYNC_STREAM_H #ifndef GRPCPP_SUPPORT_SYNC_STREAM_H
#define GRPCPP_SUPPORT_SYNC_STREAM_H #define GRPCPP_SUPPORT_SYNC_STREAM_H
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/client_context.h> #include <grpcpp/client_context.h>
#include <grpcpp/completion_queue.h> #include <grpcpp/completion_queue.h>
@ -184,7 +186,7 @@ class ClientReader final : public ClientReaderInterface<R> {
/// the server will be accessible through the \a ClientContext used to /// the server will be accessible through the \a ClientContext used to
/// construct this object. /// construct this object.
void WaitForInitialMetadata() override { void WaitForInitialMetadata() override {
GPR_ASSERT(!context_->initial_metadata_received_); CHECK(!context_->initial_metadata_received_);
grpc::internal::CallOpSet<grpc::internal::CallOpRecvInitialMetadata> ops; grpc::internal::CallOpSet<grpc::internal::CallOpRecvInitialMetadata> ops;
ops.RecvInitialMetadata(context_); ops.RecvInitialMetadata(context_);
@ -230,7 +232,7 @@ class ClientReader final : public ClientReaderInterface<R> {
grpc::Status status; grpc::Status status;
ops.ClientRecvStatus(context_, &status); ops.ClientRecvStatus(context_, &status);
call_.PerformOps(&ops); call_.PerformOps(&ops);
GPR_ASSERT(cq_.Pluck(&ops)); CHECK(cq_.Pluck(&ops));
return status; return status;
} }
@ -259,7 +261,7 @@ class ClientReader final : public ClientReaderInterface<R> {
ops.SendInitialMetadata(&context->send_initial_metadata_, ops.SendInitialMetadata(&context->send_initial_metadata_,
context->initial_metadata_flags()); context->initial_metadata_flags());
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_ASSERT(ops.SendMessagePtr(&request).ok()); CHECK(ops.SendMessagePtr(&request).ok());
ops.ClientSendClose(); ops.ClientSendClose();
call_.PerformOps(&ops); call_.PerformOps(&ops);
cq_.Pluck(&ops); cq_.Pluck(&ops);
@ -306,7 +308,7 @@ class ClientWriter : public ClientWriterInterface<W> {
/// Once complete, the initial metadata read from the server will be /// Once complete, the initial metadata read from the server will be
/// accessible through the \a ClientContext used to construct this object. /// accessible through the \a ClientContext used to construct this object.
void WaitForInitialMetadata() { void WaitForInitialMetadata() {
GPR_ASSERT(!context_->initial_metadata_received_); CHECK(!context_->initial_metadata_received_);
grpc::internal::CallOpSet<grpc::internal::CallOpRecvInitialMetadata> ops; grpc::internal::CallOpSet<grpc::internal::CallOpRecvInitialMetadata> ops;
ops.RecvInitialMetadata(context_); ops.RecvInitialMetadata(context_);
@ -364,7 +366,7 @@ class ClientWriter : public ClientWriterInterface<W> {
} }
finish_ops_.ClientRecvStatus(context_, &status); finish_ops_.ClientRecvStatus(context_, &status);
call_.PerformOps(&finish_ops_); call_.PerformOps(&finish_ops_);
GPR_ASSERT(cq_.Pluck(&finish_ops_)); CHECK(cq_.Pluck(&finish_ops_));
return status; return status;
} }
@ -455,7 +457,7 @@ class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
/// Once complete, the initial metadata read from the server will be /// Once complete, the initial metadata read from the server will be
/// accessible through the \a ClientContext used to construct this object. /// accessible through the \a ClientContext used to construct this object.
void WaitForInitialMetadata() override { void WaitForInitialMetadata() override {
GPR_ASSERT(!context_->initial_metadata_received_); CHECK(!context_->initial_metadata_received_);
grpc::internal::CallOpSet<grpc::internal::CallOpRecvInitialMetadata> ops; grpc::internal::CallOpSet<grpc::internal::CallOpRecvInitialMetadata> ops;
ops.RecvInitialMetadata(context_); ops.RecvInitialMetadata(context_);
@ -536,7 +538,7 @@ class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
grpc::Status status; grpc::Status status;
ops.ClientRecvStatus(context_, &status); ops.ClientRecvStatus(context_, &status);
call_.PerformOps(&ops); call_.PerformOps(&ops);
GPR_ASSERT(cq_.Pluck(&ops)); CHECK(cq_.Pluck(&ops));
return status; return status;
} }
@ -583,7 +585,7 @@ class ServerReader final : public ServerReaderInterface<R> {
/// for semantics. Note that initial metadata will be affected by the /// for semantics. Note that initial metadata will be affected by the
/// \a ServerContext associated with this call. /// \a ServerContext associated with this call.
void SendInitialMetadata() override { void SendInitialMetadata() override {
GPR_ASSERT(!ctx_->sent_initial_metadata_); CHECK(!ctx_->sent_initial_metadata_);
grpc::internal::CallOpSet<grpc::internal::CallOpSendInitialMetadata> ops; grpc::internal::CallOpSet<grpc::internal::CallOpSendInitialMetadata> ops;
ops.SendInitialMetadata(&ctx_->initial_metadata_, ops.SendInitialMetadata(&ctx_->initial_metadata_,
@ -640,7 +642,7 @@ class ServerWriter final : public ServerWriterInterface<W> {
/// Note that initial metadata will be affected by the /// Note that initial metadata will be affected by the
/// \a ServerContext associated with this call. /// \a ServerContext associated with this call.
void SendInitialMetadata() override { void SendInitialMetadata() override {
GPR_ASSERT(!ctx_->sent_initial_metadata_); CHECK(!ctx_->sent_initial_metadata_);
grpc::internal::CallOpSet<grpc::internal::CallOpSendInitialMetadata> ops; grpc::internal::CallOpSet<grpc::internal::CallOpSendInitialMetadata> ops;
ops.SendInitialMetadata(&ctx_->initial_metadata_, ops.SendInitialMetadata(&ctx_->initial_metadata_,
@ -713,7 +715,7 @@ class ServerReaderWriterBody final {
: call_(call), ctx_(ctx) {} : call_(call), ctx_(ctx) {}
void SendInitialMetadata() { void SendInitialMetadata() {
GPR_ASSERT(!ctx_->sent_initial_metadata_); CHECK(!ctx_->sent_initial_metadata_);
grpc::internal::CallOpSet<grpc::internal::CallOpSendInitialMetadata> ops; grpc::internal::CallOpSet<grpc::internal::CallOpSendInitialMetadata> ops;
ops.SendInitialMetadata(&ctx_->initial_metadata_, ops.SendInitialMetadata(&ctx_->initial_metadata_,

@ -26,6 +26,7 @@ grpc_cc_library(
name = "endpoint_tests", name = "endpoint_tests",
srcs = ["endpoint_tests.cc"], srcs = ["endpoint_tests.cc"],
hdrs = ["endpoint_tests.h"], hdrs = ["endpoint_tests.h"],
external_deps = ["absl/log:check"],
language = "C++", language = "C++",
visibility = [ visibility = [
"//test:__subpackages__", "//test:__subpackages__",
@ -59,7 +60,10 @@ grpc_cc_test(
grpc_cc_test( grpc_cc_test(
name = "endpoint_pair_test", name = "endpoint_pair_test",
srcs = ["endpoint_pair_test.cc"], srcs = ["endpoint_pair_test.cc"],
external_deps = ["gtest"], external_deps = [
"absl/log:check",
"gtest",
],
language = "C++", language = "C++",
tags = [ tags = [
"endpoint_test", "endpoint_test",
@ -95,6 +99,7 @@ grpc_cc_test(
grpc_cc_test( grpc_cc_test(
name = "fd_conservation_posix_test", name = "fd_conservation_posix_test",
srcs = ["fd_conservation_posix_test.cc"], srcs = ["fd_conservation_posix_test.cc"],
external_deps = ["absl/log:check"],
language = "C++", language = "C++",
tags = ["no_windows"], tags = ["no_windows"],
deps = [ deps = [
@ -180,6 +185,7 @@ grpc_cc_test(
name = "resolve_address_using_ares_resolver_test", name = "resolve_address_using_ares_resolver_test",
srcs = ["resolve_address_test.cc"], srcs = ["resolve_address_test.cc"],
external_deps = [ external_deps = [
"absl/log:check",
"absl/strings", "absl/strings",
"gtest", "gtest",
], ],
@ -198,6 +204,7 @@ grpc_cc_test(
name = "resolve_address_using_native_resolver_test", name = "resolve_address_using_native_resolver_test",
srcs = ["resolve_address_test.cc"], srcs = ["resolve_address_test.cc"],
external_deps = [ external_deps = [
"absl/log:check",
"absl/strings", "absl/strings",
"gtest", "gtest",
], ],
@ -215,7 +222,10 @@ grpc_cc_test(
grpc_cc_test( grpc_cc_test(
name = "socket_utils_test", name = "socket_utils_test",
srcs = ["socket_utils_test.cc"], srcs = ["socket_utils_test.cc"],
external_deps = ["gtest"], external_deps = [
"absl/log:check",
"gtest",
],
language = "C++", language = "C++",
tags = ["no_windows"], tags = ["no_windows"],
deps = [ deps = [
@ -270,7 +280,10 @@ grpc_cc_test(
grpc_cc_test( grpc_cc_test(
name = "buffer_list_test", name = "buffer_list_test",
srcs = ["buffer_list_test.cc"], srcs = ["buffer_list_test.cc"],
external_deps = ["gtest"], external_deps = [
"absl/log:check",
"gtest",
],
language = "C++", language = "C++",
deps = [ deps = [
"//:gpr", "//:gpr",

@ -20,6 +20,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -37,7 +39,7 @@ extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
static gpr_timespec g_now; static gpr_timespec g_now;
gpr_timespec now_impl(gpr_clock_type clock_type) { gpr_timespec now_impl(gpr_clock_type clock_type) {
GPR_ASSERT(clock_type != GPR_TIMESPAN); CHECK(clock_type != GPR_TIMESPAN);
gpr_timespec ts = g_now; gpr_timespec ts = g_now;
ts.clock_type = clock_type; ts.clock_type = clock_type;
return ts; return ts;

@ -22,6 +22,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h"
#include <grpc/event_engine/event_engine.h> #include <grpc/event_engine/event_engine.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
@ -58,7 +60,7 @@ grpc_endpoint_pair grpc_iomgr_event_engine_shim_endpoint_pair(
std::string target_addr = absl::StrCat( std::string target_addr = absl::StrCat(
"ipv6:[::1]:", std::to_string(grpc_pick_unused_port_or_die())); "ipv6:[::1]:", std::to_string(grpc_pick_unused_port_or_die()));
auto resolved_addr = URIToResolvedAddress(target_addr); auto resolved_addr = URIToResolvedAddress(target_addr);
GPR_ASSERT(resolved_addr.ok()); CHECK_OK(resolved_addr);
std::unique_ptr<EventEngine::Endpoint> client_endpoint; std::unique_ptr<EventEngine::Endpoint> client_endpoint;
std::unique_ptr<EventEngine::Endpoint> server_endpoint; std::unique_ptr<EventEngine::Endpoint> server_endpoint;
grpc_core::Notification client_signal; grpc_core::Notification client_signal;
@ -80,13 +82,13 @@ grpc_endpoint_pair grpc_iomgr_event_engine_shim_endpoint_pair(
std::move(accept_cb), [](absl::Status /*status*/) {}, config, std::move(accept_cb), [](absl::Status /*status*/) {}, config,
std::make_unique<grpc_core::MemoryQuota>("foo")); std::make_unique<grpc_core::MemoryQuota>("foo"));
GPR_ASSERT(listener->Bind(*resolved_addr).ok()); CHECK_OK(listener->Bind(*resolved_addr));
GPR_ASSERT(listener->Start().ok()); CHECK_OK(listener->Start());
ee->Connect( ee->Connect(
[&client_endpoint, &client_signal]( [&client_endpoint, &client_signal](
absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> endpoint) { absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> endpoint) {
GPR_ASSERT(endpoint.ok()); CHECK_OK(endpoint);
client_endpoint = std::move(*endpoint); client_endpoint = std::move(*endpoint);
client_signal.Notify(); client_signal.Notify();
}, },

@ -22,6 +22,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <sys/types.h> #include <sys/types.h>
#include "absl/log/check.h"
#include <grpc/slice.h> #include <grpc/slice.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -61,7 +63,7 @@ size_t count_slices(grpc_slice* slices, size_t nslices, int* current_data) {
for (i = 0; i < nslices; ++i) { for (i = 0; i < nslices; ++i) {
buf = GRPC_SLICE_START_PTR(slices[i]); buf = GRPC_SLICE_START_PTR(slices[i]);
for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) { for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) {
GPR_ASSERT(buf[j] == *current_data); CHECK(buf[j] == *current_data);
*current_data = (*current_data + 1) % 256; *current_data = (*current_data + 1) % 256;
} }
num_bytes += GRPC_SLICE_LENGTH(slices[i]); num_bytes += GRPC_SLICE_LENGTH(slices[i]);
@ -99,7 +101,7 @@ static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size,
(*current_data)++; (*current_data)++;
} }
} }
GPR_ASSERT(num_bytes_left == 0); CHECK_EQ(num_bytes_left, 0u);
return slices; return slices;
} }
@ -273,9 +275,9 @@ static void read_and_write_test(grpc_endpoint_test_config config,
gpr_mu_lock(g_mu); gpr_mu_lock(g_mu);
while (!state.read_done || !state.write_done) { while (!state.read_done || !state.write_done) {
grpc_pollset_worker* worker = nullptr; grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(grpc_core::Timestamp::Now() < deadline); CHECK(grpc_core::Timestamp::Now() < deadline);
GPR_ASSERT(GRPC_LOG_IF_ERROR( CHECK(GRPC_LOG_IF_ERROR("pollset_work",
"pollset_work", grpc_pollset_work(g_pollset, &worker, deadline))); grpc_pollset_work(g_pollset, &worker, deadline)));
} }
gpr_mu_unlock(g_mu); gpr_mu_unlock(g_mu);
grpc_core::ExecCtx::Get()->Flush(); grpc_core::ExecCtx::Get()->Flush();
@ -290,7 +292,7 @@ static void read_and_write_test(grpc_endpoint_test_config config,
static void inc_on_failure(void* arg, grpc_error_handle error) { static void inc_on_failure(void* arg, grpc_error_handle error) {
gpr_mu_lock(g_mu); gpr_mu_lock(g_mu);
*static_cast<int*>(arg) += (!error.ok()); *static_cast<int*>(arg) += (!error.ok());
GPR_ASSERT(GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr))); CHECK(GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu); gpr_mu_unlock(g_mu);
} }
@ -302,13 +304,13 @@ static void wait_for_fail_count(int* fail_count, int want_fail_count) {
while (grpc_core::Timestamp::Now() < deadline && while (grpc_core::Timestamp::Now() < deadline &&
*fail_count < want_fail_count) { *fail_count < want_fail_count) {
grpc_pollset_worker* worker = nullptr; grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR( CHECK(GRPC_LOG_IF_ERROR("pollset_work",
"pollset_work", grpc_pollset_work(g_pollset, &worker, deadline))); grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu); gpr_mu_unlock(g_mu);
grpc_core::ExecCtx::Get()->Flush(); grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu); gpr_mu_lock(g_mu);
} }
GPR_ASSERT(*fail_count == want_fail_count); CHECK(*fail_count == want_fail_count);
gpr_mu_unlock(g_mu); gpr_mu_unlock(g_mu);
} }

@ -18,6 +18,8 @@
#include <sys/resource.h> #include <sys/resource.h>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -40,7 +42,7 @@ int main(int argc, char** argv) {
// verify we can create and destroy many more than this number // verify we can create and destroy many more than this number
// of descriptors // of descriptors
rlim.rlim_cur = rlim.rlim_max = 1000; rlim.rlim_cur = rlim.rlim_max = 1000;
GPR_ASSERT(0 == setrlimit(RLIMIT_NOFILE, &rlim)); CHECK_EQ(setrlimit(RLIMIT_NOFILE, &rlim), 0);
for (i = 0; i < 10000; i++) { for (i = 0; i < 10000; i++) {
p = grpc_iomgr_create_endpoint_pair("test", nullptr); p = grpc_iomgr_create_endpoint_pair("test", nullptr);
grpc_endpoint_destroy(p.client); grpc_endpoint_destroy(p.client);

@ -25,6 +25,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/functional/bind_front.h" #include "absl/functional/bind_front.h"
#include "absl/log/check.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
@ -546,7 +547,7 @@ int main(int argc, char** argv) {
} else if (absl::StrContains(std::string(argv[0]), "using_ares_resolver")) { } else if (absl::StrContains(std::string(argv[0]), "using_ares_resolver")) {
g_resolver_type = "ares"; g_resolver_type = "ares";
} else { } else {
GPR_ASSERT(0); CHECK(0);
} }
grpc_core::ConfigVars::Overrides overrides; grpc_core::ConfigVars::Overrides overrides;
overrides.dns_resolver = g_resolver_type; overrides.dns_resolver = g_resolver_type;

@ -28,6 +28,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
@ -198,7 +200,7 @@ TEST(SocketUtilsTest, MainTest) {
if (grpc_ipv6_loopback_available()) { if (grpc_ipv6_loopback_available()) {
sock = socket(AF_INET6, SOCK_STREAM, 0); sock = socket(AF_INET6, SOCK_STREAM, 0);
GPR_ASSERT(sock > 0); CHECK_GT(sock, 0);
test_set_socket_dscp_ipv6(sock, 8 /*CS1*/); test_set_socket_dscp_ipv6(sock, 8 /*CS1*/);
test_set_socket_dscp_ipv6(sock, 16 /*CS2*/); test_set_socket_dscp_ipv6(sock, 16 /*CS2*/);

@ -26,6 +26,7 @@ grpc_cc_library(
], ],
hdrs = ["memstats.h"], hdrs = ["memstats.h"],
external_deps = [ external_deps = [
"absl/log:check",
"absl/types:optional", "absl/types:optional",
], ],
tags = [ tags = [
@ -44,6 +45,7 @@ grpc_cc_binary(
external_deps = [ external_deps = [
"absl/flags:flag", "absl/flags:flag",
"absl/flags:parse", "absl/flags:parse",
"absl/log:check",
], ],
tags = [ tags = [
"bazel_only", "bazel_only",
@ -66,6 +68,7 @@ grpc_cc_binary(
external_deps = [ external_deps = [
"absl/flags:flag", "absl/flags:flag",
"absl/flags:parse", "absl/flags:parse",
"absl/log:check",
], ],
tags = [ tags = [
"bazel_only", "bazel_only",
@ -90,6 +93,7 @@ grpc_cc_binary(
external_deps = [ external_deps = [
"absl/flags:flag", "absl/flags:flag",
"absl/flags:parse", "absl/flags:parse",
"absl/log:check",
"absl/time", "absl/time",
], ],
tags = [ tags = [
@ -115,6 +119,7 @@ grpc_cc_binary(
external_deps = [ external_deps = [
"absl/flags:flag", "absl/flags:flag",
"absl/flags:parse", "absl/flags:parse",
"absl/log:check",
], ],
tags = [ tags = [
"bazel_only", "bazel_only",

@ -27,6 +27,7 @@
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/flags/parse.h" #include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -124,7 +125,7 @@ std::shared_ptr<CallParams> GetBeforeSnapshot(
int main(int argc, char** argv) { int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv); absl::ParseCommandLine(argc, argv);
char* fake_argv[1]; char* fake_argv[1];
GPR_ASSERT(argc >= 1); CHECK_GE(argc, 1);
fake_argv[0] = argv[0]; fake_argv[0] = argv[0];
grpc::testing::TestEnvironment env(&argc, argv); grpc::testing::TestEnvironment env(&argc, argv);
if (absl::GetFlag(FLAGS_target).empty()) { if (absl::GetFlag(FLAGS_target).empty()) {
@ -158,7 +159,7 @@ int main(int argc, char** argv) {
// Checking that all channels are still open // Checking that all channels are still open
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
GPR_ASSERT(!std::exchange(channels_list[i], nullptr) CHECK(!std::exchange(channels_list[i], nullptr)
->WaitForStateChange(GRPC_CHANNEL_READY, ->WaitForStateChange(GRPC_CHANNEL_READY,
std::chrono::system_clock::now() + std::chrono::system_clock::now() +
std::chrono::milliseconds(1))); std::chrono::milliseconds(1)));

@ -24,6 +24,7 @@
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/flags/parse.h" #include "absl/flags/parse.h"
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/grpcpp.h> #include <grpcpp/grpcpp.h>
@ -77,7 +78,7 @@ static void sigint_handler(int /*x*/) { _exit(0); }
int main(int argc, char** argv) { int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv); absl::ParseCommandLine(argc, argv);
char* fake_argv[1]; char* fake_argv[1];
GPR_ASSERT(argc >= 1); CHECK_GE(argc, 1);
fake_argv[0] = argv[0]; fake_argv[0] = argv[0];
grpc::testing::TestEnvironment env(&argc, argv); grpc::testing::TestEnvironment env(&argc, argv);
grpc_init(); grpc_init();

@ -27,6 +27,7 @@
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/flags/parse.h" #include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
@ -91,7 +92,7 @@ static void init_ping_pong_request(int call_idx) {
grpc_slice_from_static_string("/Reflector/reflectUnary"), &hostname, grpc_slice_from_static_string("/Reflector/reflectUnary"), &hostname,
gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call, CHECK(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call,
metadata_ops, metadata_ops,
(size_t)(op - metadata_ops), (size_t)(op - metadata_ops),
tag(call_idx), nullptr)); tag(call_idx), nullptr));
@ -111,8 +112,7 @@ static void finish_ping_pong_request(int call_idx) {
op->data.recv_status_on_client.status_details = &calls[call_idx].details; op->data.recv_status_on_client.status_details = &calls[call_idx].details;
op++; op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call, CHECK(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call, status_ops,
status_ops,
(size_t)(op - status_ops), (size_t)(op - status_ops),
tag(call_idx), nullptr)); tag(call_idx), nullptr));
grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
@ -155,7 +155,7 @@ static MemStats send_snapshot_request(int call_idx, grpc_slice call_type) {
calls[call_idx].call = grpc_channel_create_call( calls[call_idx].call = grpc_channel_create_call(
channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, call_type, &hostname, channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, call_type, &hostname,
gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call, CHECK(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call,
snapshot_ops, snapshot_ops,
(size_t)(op - snapshot_ops), (size_t)(op - snapshot_ops),
(void*)nullptr, nullptr)); (void*)nullptr, nullptr));
@ -165,7 +165,7 @@ static MemStats send_snapshot_request(int call_idx, grpc_slice call_type) {
std::string(grpc_core::StringViewFromSlice(calls[call_idx].details)) std::string(grpc_core::StringViewFromSlice(calls[call_idx].details))
.c_str()); .c_str());
GPR_ASSERT(response_payload_recv != nullptr); CHECK_NE(response_payload_recv, nullptr);
grpc_byte_buffer_reader reader; grpc_byte_buffer_reader reader;
grpc_byte_buffer_reader_init(&reader, response_payload_recv); grpc_byte_buffer_reader_init(&reader, response_payload_recv);
grpc_slice response = grpc_byte_buffer_reader_readall(&reader); grpc_slice response = grpc_byte_buffer_reader_readall(&reader);
@ -238,7 +238,7 @@ int main(int argc, char** argv) {
grpc_slice slice = grpc_slice_from_copied_string("x"); grpc_slice slice = grpc_slice_from_copied_string("x");
char* fake_argv[1]; char* fake_argv[1];
GPR_ASSERT(argc >= 1); CHECK_GE(argc, 1);
fake_argv[0] = argv[0]; fake_argv[0] = argv[0];
grpc::testing::TestEnvironment env(&argc, argv); grpc::testing::TestEnvironment env(&argc, argv);

@ -19,6 +19,7 @@
#include <fstream> #include <fstream>
#include <string> #include <string>
#include "absl/log/check.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -47,7 +48,7 @@ long GetMemUsage(absl::optional<int> pid) {
stat_stream.close(); stat_stream.close();
// pid does not connect to an existing process // pid does not connect to an existing process
GPR_ASSERT(!state.empty()); CHECK(!state.empty());
// Calculations in case x86-64 is configured to use 2MB pages // Calculations in case x86-64 is configured to use 2MB pages
long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024;

@ -33,6 +33,7 @@
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/flags/parse.h" #include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
@ -107,9 +108,8 @@ static void send_initial_metadata_unary(void* tag) {
metadata_ops[0].op = GRPC_OP_SEND_INITIAL_METADATA; metadata_ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
metadata_ops[0].data.send_initial_metadata.count = 0; metadata_ops[0].data.send_initial_metadata.count = 0;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call*)tag).call, CHECK(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call*)tag).call,
metadata_ops, 1, tag, metadata_ops, 1, tag, nullptr));
nullptr));
} }
static void send_status(void* tag) { static void send_status(void* tag) {
@ -119,9 +119,8 @@ static void send_status(void* tag) {
grpc_slice details = grpc_slice_from_static_string(""); grpc_slice details = grpc_slice_from_static_string("");
status_op.data.send_status_from_server.status_details = &details; status_op.data.send_status_from_server.status_details = &details;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call*)tag).call, CHECK(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call*)tag).call,
&status_op, 1, tag, &status_op, 1, tag, nullptr));
nullptr));
} }
static void send_snapshot(void* tag, MemStats* snapshot) { static void send_snapshot(void* tag, MemStats* snapshot) {
@ -153,7 +152,7 @@ static void send_snapshot(void* tag, MemStats* snapshot) {
op->data.recv_close_on_server.cancelled = &was_cancelled; op->data.recv_close_on_server.cancelled = &was_cancelled;
op++; op++;
GPR_ASSERT(GRPC_CALL_OK == CHECK(GRPC_CALL_OK ==
grpc_call_start_batch((*(fling_call*)tag).call, snapshot_ops, grpc_call_start_batch((*(fling_call*)tag).call, snapshot_ops,
(size_t)(op - snapshot_ops), tag, nullptr)); (size_t)(op - snapshot_ops), tag, nullptr));
} }
@ -179,7 +178,7 @@ int main(int argc, char** argv) {
char* fake_argv[1]; char* fake_argv[1];
GPR_ASSERT(argc >= 1); CHECK_GE(argc, 1);
fake_argv[0] = argv[0]; fake_argv[0] = argv[0];
grpc::testing::TestEnvironment env(&argc, argv); grpc::testing::TestEnvironment env(&argc, argv);
@ -226,10 +225,10 @@ int main(int argc, char** argv) {
test_server1_cert}; test_server1_cert};
grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create( grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
nullptr, &pem_key_cert_pair, 1, 0, nullptr); nullptr, &pem_key_cert_pair, 1, 0, nullptr);
GPR_ASSERT(grpc_server_add_http2_port(server, addr.c_str(), ssl_creds)); CHECK(grpc_server_add_http2_port(server, addr.c_str(), ssl_creds));
grpc_server_credentials_release(ssl_creds); grpc_server_credentials_release(ssl_creds);
} else { } else {
GPR_ASSERT(grpc_server_add_http2_port( CHECK(grpc_server_add_http2_port(
server, addr.c_str(), grpc_insecure_server_credentials_create())); server, addr.c_str(), grpc_insecure_server_credentials_create()));
} }
@ -258,9 +257,9 @@ int main(int argc, char** argv) {
shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000)); grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck( CHECK(grpc_completion_queue_pluck(shutdown_cq, tag(1000),
shutdown_cq, tag(1000), grpc_timeout_seconds_to_deadline(5),
grpc_timeout_seconds_to_deadline(5), nullptr) nullptr)
.type == GRPC_OP_COMPLETE); .type == GRPC_OP_COMPLETE);
grpc_completion_queue_destroy(shutdown_cq); grpc_completion_queue_destroy(shutdown_cq);
grpc_completion_queue_shutdown(cq); grpc_completion_queue_shutdown(cq);
@ -339,7 +338,7 @@ int main(int argc, char** argv) {
} }
break; break;
case GRPC_QUEUE_SHUTDOWN: case GRPC_QUEUE_SHUTDOWN:
GPR_ASSERT(shutdown_started); CHECK(shutdown_started);
shutdown_finished = 1; shutdown_finished = 1;
break; break;
case GRPC_QUEUE_TIMEOUT: case GRPC_QUEUE_TIMEOUT:

@ -27,6 +27,7 @@ grpc_cc_test(
"//src/core/tsi/test_creds:server1.pem", "//src/core/tsi/test_creds:server1.pem",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"gtest", "gtest",
], ],
deps = [ deps = [

@ -21,6 +21,8 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_crl_provider.h> #include <grpc/grpc_crl_provider.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
@ -275,7 +277,7 @@ TEST(CredentialsTest, TlsChannelCredentialsWithDefaultRootsAndDefaultVerifier) {
grpc::experimental::TlsChannelCredentialsOptions options; grpc::experimental::TlsChannelCredentialsOptions options;
options.set_verify_server_certs(true); options.set_verify_server_certs(true);
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST( TEST(
@ -295,21 +297,21 @@ TEST(
options.watch_identity_key_cert_pairs(); options.watch_identity_key_cert_pairs();
options.set_identity_cert_name(kIdentityCertName); options.set_identity_cert_name(kIdentityCertName);
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TEST(CredentialsTest,
TlsChannelCredentialsWithStaticDataCertificateProviderLoadingRootOnly) { TlsChannelCredentialsWithStaticDataCertificateProviderLoadingRootOnly) {
auto certificate_provider = auto certificate_provider =
std::make_shared<StaticDataCertificateProvider>(kRootCertContents); std::make_shared<StaticDataCertificateProvider>(kRootCertContents);
GPR_ASSERT(certificate_provider != nullptr); CHECK_NE(certificate_provider, nullptr);
GPR_ASSERT(certificate_provider->c_provider() != nullptr); CHECK_NE(certificate_provider->c_provider(), nullptr);
grpc::experimental::TlsChannelCredentialsOptions options; grpc::experimental::TlsChannelCredentialsOptions options;
options.set_certificate_provider(certificate_provider); options.set_certificate_provider(certificate_provider);
options.watch_root_certs(); options.watch_root_certs();
options.set_root_cert_name(kRootCertName); options.set_root_cert_name(kRootCertName);
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST( TEST(
@ -327,7 +329,7 @@ TEST(
options.watch_identity_key_cert_pairs(); options.watch_identity_key_cert_pairs();
options.set_identity_cert_name(kIdentityCertName); options.set_identity_cert_name(kIdentityCertName);
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST( TEST(
@ -342,7 +344,7 @@ TEST(
options.watch_identity_key_cert_pairs(); options.watch_identity_key_cert_pairs();
options.set_identity_cert_name(kIdentityCertName); options.set_identity_cert_name(kIdentityCertName);
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TEST(CredentialsTest,
@ -354,7 +356,7 @@ TEST(CredentialsTest,
options.watch_root_certs(); options.watch_root_certs();
options.set_root_cert_name(kRootCertName); options.set_root_cert_name(kRootCertName);
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsChannelCredentialsWithHostNameVerifier) { TEST(CredentialsTest, TlsChannelCredentialsWithHostNameVerifier) {
@ -363,7 +365,7 @@ TEST(CredentialsTest, TlsChannelCredentialsWithHostNameVerifier) {
options.set_verify_server_certs(true); options.set_verify_server_certs(true);
options.set_certificate_verifier(verifier); options.set_certificate_verifier(verifier);
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsChannelCredentialsWithSyncExternalVerifier) { TEST(CredentialsTest, TlsChannelCredentialsWithSyncExternalVerifier) {
@ -374,7 +376,7 @@ TEST(CredentialsTest, TlsChannelCredentialsWithSyncExternalVerifier) {
options.set_certificate_verifier(verifier); options.set_certificate_verifier(verifier);
options.set_check_call_host(false); options.set_check_call_host(false);
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsChannelCredentialsWithAsyncExternalVerifier) { TEST(CredentialsTest, TlsChannelCredentialsWithAsyncExternalVerifier) {
@ -385,7 +387,7 @@ TEST(CredentialsTest, TlsChannelCredentialsWithAsyncExternalVerifier) {
options.set_certificate_verifier(verifier); options.set_certificate_verifier(verifier);
options.set_check_call_host(false); options.set_check_call_host(false);
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsChannelCredentialsWithCrlDirectory) { TEST(CredentialsTest, TlsChannelCredentialsWithCrlDirectory) {
@ -399,7 +401,7 @@ TEST(CredentialsTest, TlsChannelCredentialsWithCrlDirectory) {
options.set_identity_cert_name(kIdentityCertName); options.set_identity_cert_name(kIdentityCertName);
options.set_crl_directory(CRL_DIR_PATH); options.set_crl_directory(CRL_DIR_PATH);
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsChannelCredentialsWithCrlProvider) { TEST(CredentialsTest, TlsChannelCredentialsWithCrlProvider) {
@ -408,7 +410,7 @@ TEST(CredentialsTest, TlsChannelCredentialsWithCrlProvider) {
grpc::experimental::TlsChannelCredentialsOptions options; grpc::experimental::TlsChannelCredentialsOptions options;
options.set_crl_provider(*provider); options.set_crl_provider(*provider);
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsChannelCredentialsWithCrlProviderAndDirectory) { TEST(CredentialsTest, TlsChannelCredentialsWithCrlProviderAndDirectory) {
@ -420,7 +422,7 @@ TEST(CredentialsTest, TlsChannelCredentialsWithCrlProviderAndDirectory) {
auto channel_credentials = grpc::experimental::TlsCredentials(options); auto channel_credentials = grpc::experimental::TlsCredentials(options);
// TODO(gtcooke94) - behavior might change to make this return nullptr in the // TODO(gtcooke94) - behavior might change to make this return nullptr in the
// future // future
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsCredentialsOptionsCopyConstructor) { TEST(CredentialsTest, TlsCredentialsOptionsCopyConstructor) {
@ -437,8 +439,7 @@ TEST(CredentialsTest, TlsCredentialsOptionsCopyConstructor) {
TlsTestCredentialsOptions copied_options = options; TlsTestCredentialsOptions copied_options = options;
// Make sure the copy constructor cloned the internal pointer // Make sure the copy constructor cloned the internal pointer
GPR_ASSERT(options.internal_cred_opts() != CHECK(options.internal_cred_opts() != copied_options.internal_cred_opts());
copied_options.internal_cred_opts());
} }
TEST(CredentialsTest, TlsCredentialsOptionsDoesNotLeak) { TEST(CredentialsTest, TlsCredentialsOptionsDoesNotLeak) {

@ -36,6 +36,7 @@ grpc_cc_test(
name = "timer_test", name = "timer_test",
srcs = ["timer_test.cc"], srcs = ["timer_test.cc"],
external_deps = [ external_deps = [
"absl/log:check",
"gtest", "gtest",
], ],
flaky = True, flaky = True,
@ -50,6 +51,7 @@ grpc_cc_test(
name = "time_jump_test", name = "time_jump_test",
srcs = ["time_jump_test.cc"], srcs = ["time_jump_test.cc"],
external_deps = [ external_deps = [
"absl/log:check",
"gtest", "gtest",
], ],
tags = [ tags = [

@ -25,6 +25,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/time/time.h" #include "absl/time/time.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
@ -95,7 +96,7 @@ TEST_P(TimeJumpTest, TimerRunning) {
grpc_core::Timestamp::Now() + grpc_core::Duration::Seconds(3), grpc_core::Timestamp::Now() + grpc_core::Duration::Seconds(3),
GRPC_CLOSURE_CREATE( GRPC_CLOSURE_CREATE(
[](void*, grpc_error_handle error) { [](void*, grpc_error_handle error) {
GPR_ASSERT(error == absl::CancelledError()); CHECK(error == absl::CancelledError());
}, },
nullptr, grpc_schedule_on_exec_ctx)); nullptr, grpc_schedule_on_exec_ctx));
gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100)); gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100));
@ -106,7 +107,7 @@ TEST_P(TimeJumpTest, TimerRunning) {
// We expect 1 wakeup/sec when there are not timer expiries // We expect 1 wakeup/sec when there are not timer expiries
int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); int64_t wakeups = grpc_timer_manager_get_wakeups_testonly();
gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups);
GPR_ASSERT(wakeups <= 3); CHECK_LE(wakeups, 3);
grpc_timer_cancel(&timer); grpc_timer_cancel(&timer);
} }
@ -127,9 +128,8 @@ TEST_P(TimeJumpTest, TimedWait) {
int32_t elapsed_ms = gpr_time_to_millis(gpr_time_sub(after, before)); int32_t elapsed_ms = gpr_time_to_millis(gpr_time_sub(after, before));
gpr_log(GPR_DEBUG, "After wait, timedout = %d elapsed_ms = %d", timedout, gpr_log(GPR_DEBUG, "After wait, timedout = %d elapsed_ms = %d", timedout,
elapsed_ms); elapsed_ms);
GPR_ASSERT(1 == timedout); CHECK_EQ(timedout, 1);
GPR_ASSERT(1 == CHECK(1 == gpr_time_similar(gpr_time_sub(after, before),
gpr_time_similar(gpr_time_sub(after, before),
gpr_time_from_millis(kWaitTimeMs, GPR_TIMESPAN), gpr_time_from_millis(kWaitTimeMs, GPR_TIMESPAN),
gpr_time_from_millis(50, GPR_TIMESPAN))); gpr_time_from_millis(50, GPR_TIMESPAN)));
@ -138,7 +138,7 @@ TEST_P(TimeJumpTest, TimedWait) {
// We expect 1 wakeup/sec when there are not timer expiries // We expect 1 wakeup/sec when there are not timer expiries
int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); int64_t wakeups = grpc_timer_manager_get_wakeups_testonly();
gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups);
GPR_ASSERT(wakeups <= 3); CHECK_LE(wakeups, 3);
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {

@ -20,6 +20,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -77,7 +79,7 @@ TEST_F(TimerTest, NoTimers) {
// We expect to get 1 wakeup per second. Sometimes we also get a wakeup // We expect to get 1 wakeup per second. Sometimes we also get a wakeup
// during initialization, so in 1.5 seconds we expect to get 1 or 2 wakeups. // during initialization, so in 1.5 seconds we expect to get 1 or 2 wakeups.
int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); int64_t wakeups = grpc_timer_manager_get_wakeups_testonly();
GPR_ASSERT(wakeups == 1 || wakeups == 2); CHECK(wakeups == 1 || wakeups == 2);
} }
#endif #endif
@ -96,7 +98,7 @@ TEST_F(TimerTest, OneTimerExpires) {
}, },
&timer_fired, grpc_schedule_on_exec_ctx)); &timer_fired, grpc_schedule_on_exec_ctx));
gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1500)); gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1500));
GPR_ASSERT(1 == timer_fired); CHECK_EQ(timer_fired, 1);
// We expect to get 1 wakeup/second + 1 wakeup for the expired timer + maybe 1 // We expect to get 1 wakeup/second + 1 wakeup for the expired timer + maybe 1
// wakeup during initialization. i.e. in 1.5 seconds we expect 2 or 3 wakeups. // wakeup during initialization. i.e. in 1.5 seconds we expect 2 or 3 wakeups.
@ -126,7 +128,7 @@ TEST_F(TimerTest, MultipleTimersExpire) {
} }
gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1500)); gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1500));
GPR_ASSERT(kNumTimers == timer_fired); CHECK(kNumTimers == timer_fired);
// We expect to get 1 wakeup/second + 1 wakeup for per timer fired + maybe 1 // We expect to get 1 wakeup/second + 1 wakeup for per timer fired + maybe 1
// wakeup during initialization. i.e. in 1.5 seconds we expect 11 or 12 // wakeup during initialization. i.e. in 1.5 seconds we expect 11 or 12
@ -168,7 +170,7 @@ TEST_F(TimerTest, CancelSomeTimers) {
} }
gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1500)); gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1500));
GPR_ASSERT(kNumTimers / 2 == timer_fired); CHECK(kNumTimers / 2 == timer_fired);
// We expect to get 1 wakeup/second + 1 wakeup per timer fired + maybe 1 // We expect to get 1 wakeup/second + 1 wakeup per timer fired + maybe 1
// wakeup during initialization. i.e. in 1.5 seconds we expect 6 or 7 wakeups. // wakeup during initialization. i.e. in 1.5 seconds we expect 6 or 7 wakeups.

@ -46,7 +46,7 @@ class GrpclbTest : public ::testing::Test {
std::string Ip4ToPackedString(const char* ip_str) { std::string Ip4ToPackedString(const char* ip_str) {
struct in_addr ip4; struct in_addr ip4;
CHECK(inet_pton(AF_INET, ip_str, &ip4) == 1); CHECK_EQ(inet_pton(AF_INET, ip_str, &ip4), 1);
return std::string(reinterpret_cast<const char*>(&ip4), sizeof(ip4)); return std::string(reinterpret_cast<const char*>(&ip4), sizeof(ip4));
} }
@ -60,7 +60,7 @@ std::string PackedStringToIp(const grpc_core::GrpcLbServer& server) {
} else { } else {
abort(); abort();
} }
CHECK(inet_ntop(af, (void*)server.ip_addr, ip_str, 46) != nullptr); CHECK_NE(inet_ntop(af, (void*)server.ip_addr, ip_str, 46), nullptr);
return ip_str; return ip_str;
} }

@ -138,6 +138,7 @@ grpc_cc_library(
grpc_cc_binary( grpc_cc_binary(
name = "interop_client", name = "interop_client",
external_deps = ["absl/log:check"],
language = "C++", language = "C++",
deps = [ deps = [
":interop_client_main", ":interop_client_main",
@ -280,6 +281,7 @@ grpc_cc_binary(
], ],
external_deps = [ external_deps = [
"absl/flags:flag", "absl/flags:flag",
"absl/log:check",
"otel/exporters/prometheus:prometheus_exporter", "otel/exporters/prometheus:prometheus_exporter",
"otel/sdk/src/metrics", "otel/sdk/src/metrics",
], ],

@ -67,7 +67,7 @@ class BackendMetricsLbPolicy : public LoadBalancingPolicy {
: LoadBalancingPolicy(std::move(args), /*initial_refcount=*/2) { : LoadBalancingPolicy(std::move(args), /*initial_refcount=*/2) {
load_report_tracker_ = load_report_tracker_ =
channel_args().GetPointer<LoadReportTracker>(kMetricsTrackerArgument); channel_args().GetPointer<LoadReportTracker>(kMetricsTrackerArgument);
CHECK(load_report_tracker_ != nullptr); CHECK_NE(load_report_tracker_, nullptr);
Args delegate_args; Args delegate_args;
delegate_args.work_serializer = work_serializer(); delegate_args.work_serializer = work_serializer();
delegate_args.args = channel_args(); delegate_args.args = channel_args();

@ -1328,7 +1328,7 @@ bool InteropClient::DoRpcSoakTest(
int32_t soak_min_time_ms_between_rpcs, int32_t overall_timeout_seconds, int32_t soak_min_time_ms_between_rpcs, int32_t overall_timeout_seconds,
int32_t request_size, int32_t response_size) { int32_t request_size, int32_t response_size) {
gpr_log(GPR_DEBUG, "Sending %d RPCs...", soak_iterations); gpr_log(GPR_DEBUG, "Sending %d RPCs...", soak_iterations);
CHECK(soak_iterations > 0); CHECK_GT(soak_iterations, 0);
PerformSoakTest(server_uri, false /* reset channel per iteration */, PerformSoakTest(server_uri, false /* reset channel per iteration */,
soak_iterations, max_failures, soak_iterations, max_failures,
max_acceptable_per_iteration_latency_ms, max_acceptable_per_iteration_latency_ms,
@ -1345,7 +1345,7 @@ bool InteropClient::DoChannelSoakTest(
int32_t request_size, int32_t response_size) { int32_t request_size, int32_t response_size) {
gpr_log(GPR_DEBUG, "Sending %d RPCs, tearing down the channel each time...", gpr_log(GPR_DEBUG, "Sending %d RPCs, tearing down the channel each time...",
soak_iterations); soak_iterations);
CHECK(soak_iterations > 0); CHECK_GT(soak_iterations, 0);
PerformSoakTest(server_uri, true /* reset channel per iteration */, PerformSoakTest(server_uri, true /* reset channel per iteration */,
soak_iterations, max_failures, soak_iterations, max_failures,
max_acceptable_per_iteration_latency_ms, max_acceptable_per_iteration_latency_ms,
@ -1358,8 +1358,8 @@ bool InteropClient::DoChannelSoakTest(
bool InteropClient::DoLongLivedChannelTest(int32_t soak_iterations, bool InteropClient::DoLongLivedChannelTest(int32_t soak_iterations,
int32_t iteration_interval) { int32_t iteration_interval) {
gpr_log(GPR_DEBUG, "Sending %d RPCs...", soak_iterations); gpr_log(GPR_DEBUG, "Sending %d RPCs...", soak_iterations);
CHECK(soak_iterations > 0); CHECK_GT(soak_iterations, 0);
CHECK(iteration_interval > 0); CHECK_GT(iteration_interval, 0);
SimpleRequest request; SimpleRequest request;
SimpleResponse response; SimpleResponse response;
int num_failures = 0; int num_failures = 0;

@ -76,8 +76,8 @@ const char kEchoUserAgentKey[] = "x-grpc-test-echo-useragent";
void MaybeEchoMetadata(ServerContext* context) { void MaybeEchoMetadata(ServerContext* context) {
const auto& client_metadata = context->client_metadata(); const auto& client_metadata = context->client_metadata();
CHECK(client_metadata.count(kEchoInitialMetadataKey) <= 1); CHECK_LE(client_metadata.count(kEchoInitialMetadataKey), 1u);
CHECK(client_metadata.count(kEchoTrailingBinMetadataKey) <= 1); CHECK_LE(client_metadata.count(kEchoTrailingBinMetadataKey), 1u);
auto iter = client_metadata.find(kEchoInitialMetadataKey); auto iter = client_metadata.find(kEchoInitialMetadataKey);
if (iter != client_metadata.end()) { if (iter != client_metadata.end()) {
@ -420,7 +420,7 @@ void grpc::testing::interop::RunServer(
ServerStartedCondition* server_started_condition, ServerStartedCondition* server_started_condition,
std::unique_ptr<std::vector<std::unique_ptr<ServerBuilderOption>>> std::unique_ptr<std::vector<std::unique_ptr<ServerBuilderOption>>>
server_options) { server_options) {
CHECK(port != 0); CHECK_NE(port, 0);
std::ostringstream server_address; std::ostringstream server_address;
server_address << "0.0.0.0:" << port; server_address << "0.0.0.0:" << port;
auto server_metric_recorder = auto server_metric_recorder =

@ -180,8 +180,8 @@ int main(int argc, char** argv) {
grpc::testing::InitTest(&argc, &argv, true); grpc::testing::InitTest(&argc, &argv, true);
signal(SIGINT, sigint_handler); signal(SIGINT, sigint_handler);
CHECK(absl::GetFlag(FLAGS_control_port) != 0); CHECK_NE(absl::GetFlag(FLAGS_control_port), 0);
CHECK(absl::GetFlag(FLAGS_retry_port) != 0); CHECK_NE(absl::GetFlag(FLAGS_retry_port), 0);
RunServer(); RunServer();
return 0; return 0;

@ -93,7 +93,7 @@ class RpcBehaviorLbPolicy : public LoadBalancingPolicy {
grpc_core::Json::FromArray({grpc_core::Json::FromObject( grpc_core::Json::FromArray({grpc_core::Json::FromObject(
{{std::string(delegate_->name()), {{std::string(delegate_->name()),
grpc_core::Json::FromObject({})}})})); grpc_core::Json::FromObject({})}})}));
CHECK(delegate_config.ok()); CHECK_OK(delegate_config);
args.config = std::move(*delegate_config); args.config = std::move(*delegate_config);
return delegate_->UpdateLocked(std::move(args)); return delegate_->UpdateLocked(std::move(args));
} }

@ -342,8 +342,8 @@ class XdsUpdateClientConfigureServiceImpl
std::vector<RpcConfig> configs; std::vector<RpcConfig> configs;
int request_payload_size = absl::GetFlag(FLAGS_request_payload_size); int request_payload_size = absl::GetFlag(FLAGS_request_payload_size);
int response_payload_size = absl::GetFlag(FLAGS_response_payload_size); int response_payload_size = absl::GetFlag(FLAGS_response_payload_size);
CHECK(request_payload_size >= 0); CHECK_GE(request_payload_size, 0);
CHECK(response_payload_size >= 0); CHECK_GE(response_payload_size, 0);
for (const auto& rpc : request->types()) { for (const auto& rpc : request->types()) {
RpcConfig config; RpcConfig config;
config.timeout_sec = request->timeout_sec(); config.timeout_sec = request->timeout_sec();
@ -448,7 +448,7 @@ grpc::CsmObservability EnableCsmObservability() {
void RunServer(const int port, StatsWatchers* stats_watchers, void RunServer(const int port, StatsWatchers* stats_watchers,
RpcConfigurationsQueue* rpc_configs_queue) { RpcConfigurationsQueue* rpc_configs_queue) {
CHECK(port != 0); CHECK_NE(port, 0);
std::ostringstream server_address; std::ostringstream server_address;
server_address << "0.0.0.0:" << port; server_address << "0.0.0.0:" << port;
@ -480,7 +480,7 @@ void BuildRpcConfigsFromFlags(RpcConfigurationsQueue* rpc_configs_queue) {
for (auto& data : rpc_metadata) { for (auto& data : rpc_metadata) {
std::vector<std::string> metadata = std::vector<std::string> metadata =
absl::StrSplit(data, ':', absl::SkipEmpty()); absl::StrSplit(data, ':', absl::SkipEmpty());
CHECK(metadata.size() == 3); CHECK_EQ(metadata.size(), 3u);
if (metadata[0] == "EmptyCall") { if (metadata[0] == "EmptyCall") {
metadata_map[ClientConfigureRequest::EMPTY_CALL].push_back( metadata_map[ClientConfigureRequest::EMPTY_CALL].push_back(
{metadata[1], metadata[2]}); {metadata[1], metadata[2]});
@ -496,8 +496,8 @@ void BuildRpcConfigsFromFlags(RpcConfigurationsQueue* rpc_configs_queue) {
absl::StrSplit(absl::GetFlag(FLAGS_rpc), ',', absl::SkipEmpty()); absl::StrSplit(absl::GetFlag(FLAGS_rpc), ',', absl::SkipEmpty());
int request_payload_size = absl::GetFlag(FLAGS_request_payload_size); int request_payload_size = absl::GetFlag(FLAGS_request_payload_size);
int response_payload_size = absl::GetFlag(FLAGS_response_payload_size); int response_payload_size = absl::GetFlag(FLAGS_response_payload_size);
CHECK(request_payload_size >= 0); CHECK_GE(request_payload_size, 0);
CHECK(response_payload_size >= 0); CHECK_GE(response_payload_size, 0);
for (const std::string& rpc_method : rpc_methods) { for (const std::string& rpc_method : rpc_methods) {
RpcConfig config; RpcConfig config;
if (rpc_method == "EmptyCall") { if (rpc_method == "EmptyCall") {

@ -38,7 +38,10 @@ grpc_py_binary(
grpc_cc_test( grpc_cc_test(
name = "cancel_ares_query_test", name = "cancel_ares_query_test",
srcs = ["cancel_ares_query_test.cc"], srcs = ["cancel_ares_query_test.cc"],
external_deps = ["gtest"], external_deps = [
"absl/log:check",
"gtest",
],
tags = ["cancel_ares_query_test"], tags = ["cancel_ares_query_test"],
deps = [ deps = [
"//:gpr", "//:gpr",

@ -24,6 +24,8 @@
#include <address_sorting/address_sorting.h> #include <address_sorting/address_sorting.h>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -74,16 +76,16 @@ grpc_resolved_address TestAddressToGrpcResolvedAddress(TestAddress test_addr) {
memset(&in_dest, 0, sizeof(sockaddr_in)); memset(&in_dest, 0, sizeof(sockaddr_in));
in_dest.sin_port = htons(atoi(port.c_str())); in_dest.sin_port = htons(atoi(port.c_str()));
in_dest.sin_family = AF_INET; in_dest.sin_family = AF_INET;
GPR_ASSERT(inet_pton(AF_INET, host.c_str(), &in_dest.sin_addr) == 1); CHECK_EQ(inet_pton(AF_INET, host.c_str(), &in_dest.sin_addr), 1);
memcpy(&resolved_addr.addr, &in_dest, sizeof(sockaddr_in)); memcpy(&resolved_addr.addr, &in_dest, sizeof(sockaddr_in));
resolved_addr.len = sizeof(sockaddr_in); resolved_addr.len = sizeof(sockaddr_in);
} else { } else {
GPR_ASSERT(test_addr.family == AF_INET6); CHECK(test_addr.family == AF_INET6);
sockaddr_in6 in6_dest; sockaddr_in6 in6_dest;
memset(&in6_dest, 0, sizeof(sockaddr_in6)); memset(&in6_dest, 0, sizeof(sockaddr_in6));
in6_dest.sin6_port = htons(atoi(port.c_str())); in6_dest.sin6_port = htons(atoi(port.c_str()));
in6_dest.sin6_family = AF_INET6; in6_dest.sin6_family = AF_INET6;
GPR_ASSERT(inet_pton(AF_INET6, host.c_str(), &in6_dest.sin6_addr) == 1); CHECK_EQ(inet_pton(AF_INET6, host.c_str(), &in6_dest.sin6_addr), 1);
memcpy(&resolved_addr.addr, &in6_dest, sizeof(sockaddr_in6)); memcpy(&resolved_addr.addr, &in6_dest, sizeof(sockaddr_in6));
resolved_addr.len = sizeof(sockaddr_in6); resolved_addr.len = sizeof(sockaddr_in6);
} }

@ -23,6 +23,7 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "absl/log/check.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -295,7 +296,7 @@ void TestCancelDuringActiveQuery(
grpc_call* call = grpc_channel_create_call( grpc_call* call = grpc_channel_create_call(
client, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, client, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/foo"), nullptr, rpc_deadline, nullptr); grpc_slice_from_static_string("/foo"), nullptr, rpc_deadline, nullptr);
GPR_ASSERT(call); CHECK(call);
grpc_metadata_array initial_metadata_recv; grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv; grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv; grpc_metadata_array request_metadata_recv;

@ -32,6 +32,7 @@ def generate_resolver_component_tests():
"address_sorting_test.cc", "address_sorting_test.cc",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"gtest", "gtest",
], ],
deps = [ deps = [
@ -53,6 +54,7 @@ def generate_resolver_component_tests():
"resolver_component_test.cc", "resolver_component_test.cc",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"gtest", "gtest",
], ],
deps = [ deps = [
@ -75,6 +77,7 @@ def generate_resolver_component_tests():
], ],
external_deps = [ external_deps = [
"absl/flags:flag", "absl/flags:flag",
"absl/log:check",
"absl/strings", "absl/strings",
], ],
deps = [ deps = [

@ -27,6 +27,7 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -209,7 +210,7 @@ void ArgsInit(ArgsStruct* args) {
void DoNothing(void* /*arg*/, grpc_error_handle /*error*/) {} void DoNothing(void* /*arg*/, grpc_error_handle /*error*/) {}
void ArgsFinish(ArgsStruct* args) { void ArgsFinish(ArgsStruct* args) {
GPR_ASSERT(gpr_event_wait(&args->ev, TestDeadline())); CHECK(gpr_event_wait(&args->ev, TestDeadline()));
grpc_pollset_set_del_pollset(args->pollset_set, args->pollset); grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
grpc_pollset_set_destroy(args->pollset_set); grpc_pollset_set_destroy(args->pollset_set);
grpc_closure DoNothing_cb; grpc_closure DoNothing_cb;
@ -242,7 +243,7 @@ void PollPollsetUntilRequestDone(ArgsStruct* args) {
gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME)); gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME));
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", args->done, gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", args->done,
time_left.tv_sec, time_left.tv_nsec); time_left.tv_sec, time_left.tv_nsec);
GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0); CHECK_GE(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)), 0);
grpc_pollset_worker* worker = nullptr; grpc_pollset_worker* worker = nullptr;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
if (grpc_core::IsEventEngineDnsEnabled()) { if (grpc_core::IsEventEngineDnsEnabled()) {
@ -304,7 +305,7 @@ class ResultHandler : public grpc_core::Resolver::ResultHandler {
void ReportResult(grpc_core::Resolver::Result result) override { void ReportResult(grpc_core::Resolver::Result result) override {
CheckResult(result); CheckResult(result);
grpc_core::MutexLockForGprMu lock(args_->mu); grpc_core::MutexLockForGprMu lock(args_->mu);
GPR_ASSERT(!args_->done); CHECK(!args_->done);
args_->done = true; args_->done = true;
GRPC_LOG_IF_ERROR("pollset_kick", GRPC_LOG_IF_ERROR("pollset_kick",
grpc_pollset_kick(args_->pollset, nullptr)); grpc_pollset_kick(args_->pollset, nullptr));
@ -362,7 +363,7 @@ class CheckingResultHandler : public ResultHandler {
"Invalid for setting for --do_ordered_address_comparison. " "Invalid for setting for --do_ordered_address_comparison. "
"Have %s, want True or False", "Have %s, want True or False",
absl::GetFlag(FLAGS_do_ordered_address_comparison).c_str()); absl::GetFlag(FLAGS_do_ordered_address_comparison).c_str());
GPR_ASSERT(0); CHECK(0);
} }
if (!result.service_config.ok()) { if (!result.service_config.ok()) {
CheckServiceConfigResultLocked(nullptr, result.service_config.status(), CheckServiceConfigResultLocked(nullptr, result.service_config.status(),
@ -405,7 +406,7 @@ void InjectBrokenNameServerList(ares_channel* channel) {
memset(dns_server_addrs, 0, sizeof(dns_server_addrs)); memset(dns_server_addrs, 0, sizeof(dns_server_addrs));
std::string unused_host; std::string unused_host;
std::string local_dns_server_port; std::string local_dns_server_port;
GPR_ASSERT(grpc_core::SplitHostPort( CHECK(grpc_core::SplitHostPort(
absl::GetFlag(FLAGS_local_dns_server_address).c_str(), &unused_host, absl::GetFlag(FLAGS_local_dns_server_address).c_str(), &unused_host,
&local_dns_server_port)); &local_dns_server_port));
gpr_log(GPR_DEBUG, gpr_log(GPR_DEBUG,
@ -429,8 +430,7 @@ void InjectBrokenNameServerList(ares_channel* channel) {
dns_server_addrs[1].tcp_port = atoi(local_dns_server_port.c_str()); dns_server_addrs[1].tcp_port = atoi(local_dns_server_port.c_str());
dns_server_addrs[1].udp_port = atoi(local_dns_server_port.c_str()); dns_server_addrs[1].udp_port = atoi(local_dns_server_port.c_str());
dns_server_addrs[1].next = nullptr; dns_server_addrs[1].next = nullptr;
GPR_ASSERT(ares_set_servers_ports(*channel, dns_server_addrs) == CHECK(ares_set_servers_ports(*channel, dns_server_addrs) == ARES_SUCCESS);
ARES_SUCCESS);
} }
void StartResolvingLocked(grpc_core::Resolver* r) { r->StartLocked(); } void StartResolvingLocked(grpc_core::Resolver* r) { r->StartLocked(); }

@ -27,6 +27,7 @@
#include <vector> #include <vector>
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
@ -99,11 +100,11 @@ int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(&argc, argv); grpc::testing::TestEnvironment env(&argc, argv);
grpc::testing::InitTest(&argc, &argv, true); grpc::testing::InitTest(&argc, &argv, true);
grpc_init(); grpc_init();
GPR_ASSERT(!absl::GetFlag(FLAGS_test_bin_name).empty()); CHECK(!absl::GetFlag(FLAGS_test_bin_name).empty());
std::string my_bin = argv[0]; std::string my_bin = argv[0];
int result = 0; int result = 0;
if (absl::GetFlag(FLAGS_running_under_bazel)) { if (absl::GetFlag(FLAGS_running_under_bazel)) {
GPR_ASSERT(!absl::GetFlag(FLAGS_grpc_test_directory_relative_to_test_srcdir) CHECK(!absl::GetFlag(FLAGS_grpc_test_directory_relative_to_test_srcdir)
.empty()); .empty());
// Use bazel's TEST_SRCDIR environment variable to locate the "test data" // Use bazel's TEST_SRCDIR environment variable to locate the "test data"
// binaries. // binaries.

@ -22,6 +22,7 @@ grpc_cc_test(
name = "writes_per_rpc_test", name = "writes_per_rpc_test",
srcs = ["writes_per_rpc_test.cc"], srcs = ["writes_per_rpc_test.cc"],
external_deps = [ external_deps = [
"absl/log:check",
"gtest", "gtest",
], ],
tags = ["no_windows"], tags = ["no_windows"],

@ -20,6 +20,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/channel.h> #include <grpcpp/channel.h>
#include <grpcpp/create_channel.h> #include <grpcpp/create_channel.h>
@ -79,16 +81,16 @@ class InProcessCHTTP2 {
listener_endpoint = std::move(ep); listener_endpoint = std::move(ep);
listener_started.Notify(); listener_started.Notify();
}, },
[](absl::Status status) { GPR_ASSERT(status.ok()); }, config, [](absl::Status status) { CHECK_OK(status); }, config,
std::make_unique<grpc_core::MemoryQuota>("foo")); std::make_unique<grpc_core::MemoryQuota>("foo"));
if (!listener.ok()) { if (!listener.ok()) {
grpc_core::Crash(absl::StrCat("failed to start listener: ", grpc_core::Crash(absl::StrCat("failed to start listener: ",
listener.status().ToString())); listener.status().ToString()));
} }
auto target_addr = URIToResolvedAddress(addr); auto target_addr = URIToResolvedAddress(addr);
GPR_ASSERT(target_addr.ok()); CHECK_OK(target_addr);
GPR_ASSERT((*listener)->Bind(*target_addr).ok()); CHECK_OK((*listener)->Bind(*target_addr));
GPR_ASSERT((*listener)->Start().ok()); CHECK_OK((*listener)->Start());
// Creating the client // Creating the client
std::unique_ptr<EventEngine::Endpoint> client_endpoint; std::unique_ptr<EventEngine::Endpoint> client_endpoint;
grpc_core::Notification client_connected; grpc_core::Notification client_connected;
@ -96,7 +98,7 @@ class InProcessCHTTP2 {
std::make_unique<grpc_core::MemoryQuota>("client"); std::make_unique<grpc_core::MemoryQuota>("client");
std::ignore = fuzzing_engine->Connect( std::ignore = fuzzing_engine->Connect(
[&](absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> endpoint) { [&](absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> endpoint) {
GPR_ASSERT(endpoint.ok()); CHECK_OK(endpoint);
client_endpoint = std::move(*endpoint); client_endpoint = std::move(*endpoint);
client_connected.Notify(); client_connected.Notify();
}, },
@ -124,7 +126,7 @@ class InProcessCHTTP2 {
for (grpc_pollset* pollset : core_server->pollsets()) { for (grpc_pollset* pollset : core_server->pollsets()) {
grpc_endpoint_add_to_pollset(iomgr_server_endpoint, pollset); grpc_endpoint_add_to_pollset(iomgr_server_endpoint, pollset);
} }
GPR_ASSERT(GRPC_LOG_IF_ERROR( CHECK(GRPC_LOG_IF_ERROR(
"SetupTransport", "SetupTransport",
core_server->SetupTransport(transport, nullptr, core_server->SetupTransport(transport, nullptr,
core_server->channel_args(), nullptr))); core_server->channel_args(), nullptr)));
@ -143,7 +145,7 @@ class InProcessCHTTP2 {
grpc_core::Transport* transport = grpc_create_chttp2_transport( grpc_core::Transport* transport = grpc_create_chttp2_transport(
args, grpc_event_engine_endpoint_create(std::move(client_endpoint)), args, grpc_event_engine_endpoint_create(std::move(client_endpoint)),
/*is_client=*/true); /*is_client=*/true);
GPR_ASSERT(transport); CHECK(transport);
grpc_channel* channel = grpc_channel* channel =
grpc_core::ChannelCreate("target", args, GRPC_CLIENT_DIRECT_CHANNEL, grpc_core::ChannelCreate("target", args, GRPC_CLIENT_DIRECT_CHANNEL,
transport) transport)
@ -234,20 +236,20 @@ static double UnaryPingPong(ThreadedFuzzingEventEngine* fuzzing_engine,
void* t; void* t;
bool ok; bool ok;
response_reader->Finish(&recv_response, &recv_status, tag(4)); response_reader->Finish(&recv_response, &recv_status, tag(4));
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok); CHECK(ok);
GPR_ASSERT(t == tag(0) || t == tag(1)); CHECK(t == tag(0) || t == tag(1));
intptr_t slot = reinterpret_cast<intptr_t>(t); intptr_t slot = reinterpret_cast<intptr_t>(t);
ServerEnv* senv = server_env[slot]; ServerEnv* senv = server_env[slot];
senv->response_writer.Finish(send_response, Status::OK, tag(3)); senv->response_writer.Finish(send_response, Status::OK, tag(3));
for (int i = (1 << 3) | (1 << 4); i != 0;) { for (int i = (1 << 3) | (1 << 4); i != 0;) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok); CHECK(ok);
int tagnum = static_cast<int>(reinterpret_cast<intptr_t>(t)); int tagnum = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(i & (1 << tagnum)); CHECK(i & (1 << tagnum));
i -= 1 << tagnum; i -= 1 << tagnum;
} }
GPR_ASSERT(recv_status.ok()); CHECK(recv_status.ok());
senv->~ServerEnv(); senv->~ServerEnv();
senv = new (senv) ServerEnv(); senv = new (senv) ServerEnv();

@ -57,7 +57,7 @@ std::string SerializeJson(const GRPC_CUSTOM_MESSAGE& msg,
msg.SerializeToString(&binary); msg.SerializeToString(&binary);
auto status = auto status =
BinaryToJsonString(type_resolver.get(), type, binary, &json_string); BinaryToJsonString(type_resolver.get(), type, binary, &json_string);
CHECK(status.ok()); CHECK_OK(status);
return json_string; return json_string;
} }

@ -72,6 +72,7 @@ grpc_cc_test(
"//src/core/tsi/test_creds:server1.pem", "//src/core/tsi/test_creds:server1.pem",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"gtest", "gtest",
], ],
deps = [ deps = [

@ -18,6 +18,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_crl_provider.h> #include <grpc/grpc_crl_provider.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
@ -73,7 +75,7 @@ TEST(
options.set_cert_request_type( options.set_cert_request_type(
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY); GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY);
auto server_credentials = grpc::experimental::TlsServerCredentials(options); auto server_credentials = grpc::experimental::TlsServerCredentials(options);
GPR_ASSERT(server_credentials.get() != nullptr); CHECK_NE(server_credentials.get(), nullptr);
} }
// ServerCredentials should always have identity credential presented. // ServerCredentials should always have identity credential presented.
@ -95,7 +97,7 @@ TEST(CredentialsTest,
options.set_cert_request_type( options.set_cert_request_type(
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY); GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY);
auto server_credentials = grpc::experimental::TlsServerCredentials(options); auto server_credentials = grpc::experimental::TlsServerCredentials(options);
GPR_ASSERT(server_credentials.get() != nullptr); CHECK_NE(server_credentials.get(), nullptr);
} }
TEST( TEST(
@ -111,7 +113,7 @@ TEST(
options.set_cert_request_type( options.set_cert_request_type(
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY); GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY);
auto server_credentials = grpc::experimental::TlsServerCredentials(options); auto server_credentials = grpc::experimental::TlsServerCredentials(options);
GPR_ASSERT(server_credentials.get() != nullptr); CHECK_NE(server_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsServerCredentialsWithCrlChecking) { TEST(CredentialsTest, TlsServerCredentialsWithCrlChecking) {
@ -126,7 +128,7 @@ TEST(CredentialsTest, TlsServerCredentialsWithCrlChecking) {
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY); GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY);
options.set_crl_directory(CRL_DIR_PATH); options.set_crl_directory(CRL_DIR_PATH);
auto server_credentials = grpc::experimental::TlsServerCredentials(options); auto server_credentials = grpc::experimental::TlsServerCredentials(options);
GPR_ASSERT(server_credentials.get() != nullptr); CHECK_NE(server_credentials.get(), nullptr);
} }
// ServerCredentials should always have identity credential presented. // ServerCredentials should always have identity credential presented.
@ -142,7 +144,7 @@ TEST(
options.set_cert_request_type( options.set_cert_request_type(
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY); GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY);
auto server_credentials = grpc::experimental::TlsServerCredentials(options); auto server_credentials = grpc::experimental::TlsServerCredentials(options);
GPR_ASSERT(server_credentials.get() != nullptr); CHECK_NE(server_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsServerCredentialsWithSyncExternalVerifier) { TEST(CredentialsTest, TlsServerCredentialsWithSyncExternalVerifier) {
@ -159,7 +161,7 @@ TEST(CredentialsTest, TlsServerCredentialsWithSyncExternalVerifier) {
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY); GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY);
options.set_certificate_verifier(verifier); options.set_certificate_verifier(verifier);
auto server_credentials = grpc::experimental::TlsServerCredentials(options); auto server_credentials = grpc::experimental::TlsServerCredentials(options);
GPR_ASSERT(server_credentials.get() != nullptr); CHECK_NE(server_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsServerCredentialsWithAsyncExternalVerifier) { TEST(CredentialsTest, TlsServerCredentialsWithAsyncExternalVerifier) {
@ -176,7 +178,7 @@ TEST(CredentialsTest, TlsServerCredentialsWithAsyncExternalVerifier) {
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY); GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY);
options.set_certificate_verifier(verifier); options.set_certificate_verifier(verifier);
auto server_credentials = grpc::experimental::TlsServerCredentials(options); auto server_credentials = grpc::experimental::TlsServerCredentials(options);
GPR_ASSERT(server_credentials.get() != nullptr); CHECK_NE(server_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsServerCredentialsWithCrlProvider) { TEST(CredentialsTest, TlsServerCredentialsWithCrlProvider) {
@ -187,7 +189,7 @@ TEST(CredentialsTest, TlsServerCredentialsWithCrlProvider) {
grpc::experimental::TlsServerCredentialsOptions options(certificate_provider); grpc::experimental::TlsServerCredentialsOptions options(certificate_provider);
options.set_crl_provider(*provider); options.set_crl_provider(*provider);
auto channel_credentials = grpc::experimental::TlsServerCredentials(options); auto channel_credentials = grpc::experimental::TlsServerCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr); CHECK_NE(channel_credentials.get(), nullptr);
} }
TEST(CredentialsTest, TlsServerCredentialsWithCrlProviderAndDirectory) { TEST(CredentialsTest, TlsServerCredentialsWithCrlProviderAndDirectory) {
@ -201,7 +203,7 @@ TEST(CredentialsTest, TlsServerCredentialsWithCrlProviderAndDirectory) {
auto server_credentials = grpc::experimental::TlsServerCredentials(options); auto server_credentials = grpc::experimental::TlsServerCredentials(options);
// TODO(gtcooke94) - behavior might change to make this return nullptr in // TODO(gtcooke94) - behavior might change to make this return nullptr in
// the future // the future
GPR_ASSERT(server_credentials != nullptr); CHECK_NE(server_credentials, nullptr);
} }
TEST(CredentialsTest, TlsCredentialsOptionsDoesNotLeak) { TEST(CredentialsTest, TlsCredentialsOptionsDoesNotLeak) {

@ -34,6 +34,8 @@ grpc_cc_test(
name = "lb_load_reporter_test", name = "lb_load_reporter_test",
srcs = ["load_reporter_test.cc"], srcs = ["load_reporter_test.cc"],
external_deps = [ external_deps = [
"absl/flags:flag",
"absl/log:check",
"gtest", "gtest",
"opencensus-stats-test", "opencensus-stats-test",
], ],

@ -24,6 +24,7 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "opencensus/stats/testing/test_utils.h" #include "opencensus/stats/testing/test_utils.h"
@ -59,7 +60,7 @@ class MockCensusViewProvider : public CensusViewProvider {
const ViewDescriptor& FindViewDescriptor(const std::string& view_name) { const ViewDescriptor& FindViewDescriptor(const std::string& view_name) {
auto it = view_descriptor_map().find(view_name); auto it = view_descriptor_map().find(view_name);
GPR_ASSERT(it != view_descriptor_map().end()); CHECK(it != view_descriptor_map().end());
return it->second; return it->second;
} }
}; };

Loading…
Cancel
Save