From 70a311b7363e4cf2c03e27ef2c0397afb156a723 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 6 Jul 2022 22:10:46 -0700 Subject: [PATCH] gtestify test/core/tsi (#30211) * Fix * test/core/tsi/alts/frame_protector * Fix * Fix --- CMakeLists.txt | 2538 +++++++++-------- build_autogenerated.yaml | 319 ++- test/core/tsi/BUILD | 3 + test/core/tsi/alts/crypt/BUILD | 1 + test/core/tsi/alts/crypt/aes_gcm_test.cc | 167 +- test/core/tsi/alts/frame_protector/BUILD | 4 + .../alts/frame_protector/alts_counter_test.cc | 89 +- .../alts/frame_protector/alts_crypter_test.cc | 132 +- .../alts_frame_protector_test.cc | 67 +- .../frame_protector/frame_handler_test.cc | 106 +- test/core/tsi/alts/handshaker/BUILD | 4 + .../handshaker/alts_handshaker_client_test.cc | 164 +- .../handshaker/alts_tsi_handshaker_test.cc | 460 +-- .../alts/handshaker/alts_tsi_utils_test.cc | 42 +- .../transport_security_common_api_test.cc | 150 +- .../tsi/alts/zero_copy_frame_protector/BUILD | 3 + .../alts_grpc_record_protocol_test.cc | 183 +- .../alts_iovec_record_protocol_test.cc | 192 +- .../alts_zero_copy_grpc_protector_test.cc | 108 +- test/core/tsi/fake_transport_security_test.cc | 41 +- test/core/tsi/ssl_transport_security_test.cc | 391 +-- test/core/tsi/transport_security_test.cc | 97 +- tools/run_tests/generated/tests.json | 742 ++--- 23 files changed, 3135 insertions(+), 2868 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a590302c748..434876ce9fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -777,17 +777,7 @@ if(gRPC_BUILD_TESTS) add_custom_target(buildtests_c) add_dependencies(buildtests_c alloc_test) add_dependencies(buildtests_c alpn_test) - add_dependencies(buildtests_c alts_counter_test) - add_dependencies(buildtests_c alts_crypt_test) - add_dependencies(buildtests_c alts_crypter_test) - add_dependencies(buildtests_c alts_frame_protector_test) - add_dependencies(buildtests_c alts_grpc_record_protocol_test) - add_dependencies(buildtests_c alts_handshaker_client_test) - add_dependencies(buildtests_c alts_iovec_record_protocol_test) add_dependencies(buildtests_c alts_security_connector_test) - add_dependencies(buildtests_c alts_tsi_handshaker_test) - add_dependencies(buildtests_c alts_tsi_utils_test) - add_dependencies(buildtests_c alts_zero_copy_grpc_protector_test) add_dependencies(buildtests_c auth_context_test) add_dependencies(buildtests_c b64_test) add_dependencies(buildtests_c bad_server_response_test) @@ -819,7 +809,6 @@ if(gRPC_BUILD_TESTS) endif() add_dependencies(buildtests_c endpoint_pair_test) add_dependencies(buildtests_c env_test) - add_dependencies(buildtests_c fake_transport_security_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_c fd_conservation_posix_test) endif() @@ -836,7 +825,6 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_c fork_test) endif() add_dependencies(buildtests_c format_request_test) - add_dependencies(buildtests_c frame_handler_test) add_dependencies(buildtests_c goaway_server_test) add_dependencies(buildtests_c grpc_alts_credentials_options_test) add_dependencies(buildtests_c grpc_ipv6_loopback_available_test) @@ -880,9 +868,6 @@ if(gRPC_BUILD_TESTS) endif() add_dependencies(buildtests_c spinlock_test) add_dependencies(buildtests_c ssl_credentials_test) - if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_dependencies(buildtests_c ssl_transport_security_test) - endif() add_dependencies(buildtests_c status_conversion_test) add_dependencies(buildtests_c stream_map_test) add_dependencies(buildtests_c string_test) @@ -902,8 +887,6 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_c test_core_iomgr_timer_list_test) add_dependencies(buildtests_c thd_test) add_dependencies(buildtests_c threadpool_test) - add_dependencies(buildtests_c transport_security_common_api_test) - add_dependencies(buildtests_c transport_security_test) add_dependencies(buildtests_c varint_test) add_custom_target(buildtests_cxx) @@ -921,7 +904,17 @@ if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx alts_concurrent_connectivity_test) endif() + add_dependencies(buildtests_cxx alts_counter_test) + add_dependencies(buildtests_cxx alts_crypt_test) + add_dependencies(buildtests_cxx alts_crypter_test) + add_dependencies(buildtests_cxx alts_frame_protector_test) + add_dependencies(buildtests_cxx alts_grpc_record_protocol_test) + add_dependencies(buildtests_cxx alts_handshaker_client_test) + add_dependencies(buildtests_cxx alts_iovec_record_protocol_test) + add_dependencies(buildtests_cxx alts_tsi_handshaker_test) + add_dependencies(buildtests_cxx alts_tsi_utils_test) add_dependencies(buildtests_cxx alts_util_test) + add_dependencies(buildtests_cxx alts_zero_copy_grpc_protector_test) add_dependencies(buildtests_cxx arena_promise_test) add_dependencies(buildtests_cxx arena_test) add_dependencies(buildtests_cxx async_end2end_test) @@ -1004,11 +997,13 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_cxx exec_ctx_wakeup_scheduler_test) add_dependencies(buildtests_cxx fake_binder_test) add_dependencies(buildtests_cxx fake_resolver_test) + add_dependencies(buildtests_cxx fake_transport_security_test) add_dependencies(buildtests_cxx file_watcher_certificate_provider_factory_test) add_dependencies(buildtests_cxx filter_end2end_test) add_dependencies(buildtests_cxx flaky_network_test) add_dependencies(buildtests_cxx flow_control_test) add_dependencies(buildtests_cxx for_each_test) + add_dependencies(buildtests_cxx frame_handler_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx fuzzing_event_engine_test) endif() @@ -1155,6 +1150,9 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_cxx smoke_test) add_dependencies(buildtests_cxx sockaddr_resolver_test) add_dependencies(buildtests_cxx sockaddr_utils_test) + if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + add_dependencies(buildtests_cxx ssl_transport_security_test) + endif() if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx stack_tracer_test) endif() @@ -1200,6 +1198,8 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_cxx tls_security_connector_test) add_dependencies(buildtests_cxx tls_test) add_dependencies(buildtests_cxx too_many_pings_test) + add_dependencies(buildtests_cxx transport_security_common_api_test) + add_dependencies(buildtests_cxx transport_security_test) add_dependencies(buildtests_cxx transport_stream_receiver_test) add_dependencies(buildtests_cxx try_join_test) add_dependencies(buildtests_cxx try_seq_metadata_test) @@ -4335,12 +4335,11 @@ target_link_libraries(alpn_test endif() if(gRPC_BUILD_TESTS) -add_executable(alts_counter_test - test/core/tsi/alts/crypt/gsec_test_util.cc - test/core/tsi/alts/frame_protector/alts_counter_test.cc +add_executable(alts_security_connector_test + test/core/security/alts_security_connector_test.cc ) -target_include_directories(alts_counter_test +target_include_directories(alts_security_connector_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4354,7 +4353,7 @@ target_include_directories(alts_counter_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(alts_counter_test +target_link_libraries(alts_security_connector_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4363,12 +4362,11 @@ target_link_libraries(alts_counter_test endif() if(gRPC_BUILD_TESTS) -add_executable(alts_crypt_test - test/core/tsi/alts/crypt/aes_gcm_test.cc - test/core/tsi/alts/crypt/gsec_test_util.cc +add_executable(auth_context_test + test/core/security/auth_context_test.cc ) -target_include_directories(alts_crypt_test +target_include_directories(auth_context_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4382,7 +4380,7 @@ target_include_directories(alts_crypt_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(alts_crypt_test +target_link_libraries(auth_context_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4391,12 +4389,11 @@ target_link_libraries(alts_crypt_test endif() if(gRPC_BUILD_TESTS) -add_executable(alts_crypter_test - test/core/tsi/alts/crypt/gsec_test_util.cc - test/core/tsi/alts/frame_protector/alts_crypter_test.cc +add_executable(b64_test + test/core/slice/b64_test.cc ) -target_include_directories(alts_crypter_test +target_include_directories(b64_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4410,7 +4407,7 @@ target_include_directories(alts_crypter_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(alts_crypter_test +target_link_libraries(b64_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4419,13 +4416,12 @@ target_link_libraries(alts_crypter_test endif() if(gRPC_BUILD_TESTS) -add_executable(alts_frame_protector_test - test/core/tsi/alts/crypt/gsec_test_util.cc - test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc - test/core/tsi/transport_security_test_lib.cc +add_executable(bad_server_response_test + test/core/end2end/bad_server_response_test.cc + test/core/end2end/cq_verifier.cc ) -target_include_directories(alts_frame_protector_test +target_include_directories(bad_server_response_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4439,7 +4435,7 @@ target_include_directories(alts_frame_protector_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(alts_frame_protector_test +target_link_libraries(bad_server_response_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4447,13 +4443,72 @@ target_link_libraries(alts_frame_protector_test endif() if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) -add_executable(alts_grpc_record_protocol_test - test/core/tsi/alts/crypt/gsec_test_util.cc - test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc + add_executable(bad_ssl_alpn_test + test/core/bad_ssl/bad_ssl_test.cc + test/core/end2end/cq_verifier.cc + ) + + target_include_directories(bad_ssl_alpn_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(bad_ssl_alpn_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + + add_executable(bad_ssl_cert_test + test/core/bad_ssl/bad_ssl_test.cc + test/core/end2end/cq_verifier.cc + ) + + target_include_directories(bad_ssl_cert_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(bad_ssl_cert_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) + +add_executable(bin_decoder_test + test/core/transport/chttp2/bin_decoder_test.cc ) -target_include_directories(alts_grpc_record_protocol_test +target_include_directories(bin_decoder_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4467,7 +4522,7 @@ target_include_directories(alts_grpc_record_protocol_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(alts_grpc_record_protocol_test +target_link_libraries(bin_decoder_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4476,12 +4531,11 @@ target_link_libraries(alts_grpc_record_protocol_test endif() if(gRPC_BUILD_TESTS) -add_executable(alts_handshaker_client_test - test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc +add_executable(bin_encoder_test + test/core/transport/chttp2/bin_encoder_test.cc ) -target_include_directories(alts_handshaker_client_test +target_include_directories(bin_encoder_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4495,7 +4549,7 @@ target_include_directories(alts_handshaker_client_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(alts_handshaker_client_test +target_link_libraries(bin_encoder_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4504,12 +4558,11 @@ target_link_libraries(alts_handshaker_client_test endif() if(gRPC_BUILD_TESTS) -add_executable(alts_iovec_record_protocol_test - test/core/tsi/alts/crypt/gsec_test_util.cc - test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc +add_executable(buffer_list_test + test/core/iomgr/buffer_list_test.cc ) -target_include_directories(alts_iovec_record_protocol_test +target_include_directories(buffer_list_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4523,7 +4576,7 @@ target_include_directories(alts_iovec_record_protocol_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(alts_iovec_record_protocol_test +target_link_libraries(buffer_list_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4532,11 +4585,11 @@ target_link_libraries(alts_iovec_record_protocol_test endif() if(gRPC_BUILD_TESTS) -add_executable(alts_security_connector_test - test/core/security/alts_security_connector_test.cc +add_executable(c_slice_buffer_test + test/core/slice/c_slice_buffer_test.cc ) -target_include_directories(alts_security_connector_test +target_include_directories(c_slice_buffer_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4550,7 +4603,7 @@ target_include_directories(alts_security_connector_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(alts_security_connector_test +target_link_libraries(c_slice_buffer_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4559,12 +4612,11 @@ target_link_libraries(alts_security_connector_test endif() if(gRPC_BUILD_TESTS) -add_executable(alts_tsi_handshaker_test - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc - test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc +add_executable(channel_stack_test + test/core/channel/channel_stack_test.cc ) -target_include_directories(alts_tsi_handshaker_test +target_include_directories(channel_stack_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4578,7 +4630,7 @@ target_include_directories(alts_tsi_handshaker_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(alts_tsi_handshaker_test +target_link_libraries(channel_stack_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4587,12 +4639,11 @@ target_link_libraries(alts_tsi_handshaker_test endif() if(gRPC_BUILD_TESTS) -add_executable(alts_tsi_utils_test - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc - test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc +add_executable(check_gcp_environment_linux_test + test/core/security/check_gcp_environment_linux_test.cc ) -target_include_directories(alts_tsi_utils_test +target_include_directories(check_gcp_environment_linux_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4606,7 +4657,7 @@ target_include_directories(alts_tsi_utils_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(alts_tsi_utils_test +target_link_libraries(check_gcp_environment_linux_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4615,12 +4666,11 @@ target_link_libraries(alts_tsi_utils_test endif() if(gRPC_BUILD_TESTS) -add_executable(alts_zero_copy_grpc_protector_test - test/core/tsi/alts/crypt/gsec_test_util.cc - test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc +add_executable(check_gcp_environment_windows_test + test/core/security/check_gcp_environment_windows_test.cc ) -target_include_directories(alts_zero_copy_grpc_protector_test +target_include_directories(check_gcp_environment_windows_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4634,7 +4684,7 @@ target_include_directories(alts_zero_copy_grpc_protector_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(alts_zero_copy_grpc_protector_test +target_link_libraries(check_gcp_environment_windows_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4642,12 +4692,41 @@ target_link_libraries(alts_zero_copy_grpc_protector_test endif() if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) -add_executable(auth_context_test - test/core/security/auth_context_test.cc + add_executable(client_ssl_test + test/core/handshake/client_ssl.cc + ) + + target_include_directories(client_ssl_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(client_ssl_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) + +add_executable(cmdline_test + test/core/util/cmdline_test.cc ) -target_include_directories(auth_context_test +target_include_directories(cmdline_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4661,7 +4740,7 @@ target_include_directories(auth_context_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(auth_context_test +target_link_libraries(cmdline_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4669,12 +4748,42 @@ target_link_libraries(auth_context_test endif() if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) -add_executable(b64_test - test/core/slice/b64_test.cc + add_executable(combiner_test + test/core/iomgr/combiner_test.cc + ) + + target_include_directories(combiner_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(combiner_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) + +add_executable(compression_test + test/core/compression/args_utils.cc + test/core/compression/compression_test.cc ) -target_include_directories(b64_test +target_include_directories(compression_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4688,7 +4797,7 @@ target_include_directories(b64_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(b64_test +target_link_libraries(compression_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4697,12 +4806,12 @@ target_link_libraries(b64_test endif() if(gRPC_BUILD_TESTS) -add_executable(bad_server_response_test - test/core/end2end/bad_server_response_test.cc +add_executable(connection_refused_test + test/core/end2end/connection_refused_test.cc test/core/end2end/cq_verifier.cc ) -target_include_directories(bad_server_response_test +target_include_directories(connection_refused_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4716,7 +4825,7 @@ target_include_directories(bad_server_response_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(bad_server_response_test +target_link_libraries(connection_refused_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4724,44 +4833,41 @@ target_link_libraries(bad_server_response_test endif() if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(bad_ssl_alpn_test - test/core/bad_ssl/bad_ssl_test.cc - test/core/end2end/cq_verifier.cc - ) +add_executable(cpu_test + test/core/gpr/cpu_test.cc +) - target_include_directories(bad_ssl_alpn_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) +target_include_directories(cpu_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} +) - target_link_libraries(bad_ssl_alpn_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) +target_link_libraries(cpu_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) -endif() endif() if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(bad_ssl_cert_test - test/core/bad_ssl/bad_ssl_test.cc + add_executable(dualstack_socket_test test/core/end2end/cq_verifier.cc + test/core/end2end/dualstack_socket_test.cc ) - target_include_directories(bad_ssl_cert_test + target_include_directories(dualstack_socket_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4775,7 +4881,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_ZLIB_INCLUDE_DIR} ) - target_link_libraries(bad_ssl_cert_test + target_link_libraries(dualstack_socket_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4785,11 +4891,12 @@ endif() endif() if(gRPC_BUILD_TESTS) -add_executable(bin_decoder_test - test/core/transport/chttp2/bin_decoder_test.cc +add_executable(endpoint_pair_test + test/core/iomgr/endpoint_pair_test.cc + test/core/iomgr/endpoint_tests.cc ) -target_include_directories(bin_decoder_test +target_include_directories(endpoint_pair_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4803,7 +4910,7 @@ target_include_directories(bin_decoder_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(bin_decoder_test +target_link_libraries(endpoint_pair_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4812,11 +4919,11 @@ target_link_libraries(bin_decoder_test endif() if(gRPC_BUILD_TESTS) -add_executable(bin_encoder_test - test/core/transport/chttp2/bin_encoder_test.cc +add_executable(env_test + test/core/gpr/env_test.cc ) -target_include_directories(bin_encoder_test +target_include_directories(env_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4830,7 +4937,7 @@ target_include_directories(bin_encoder_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(bin_encoder_test +target_link_libraries(env_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4838,12 +4945,169 @@ target_link_libraries(bin_encoder_test endif() if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) -add_executable(buffer_list_test - test/core/iomgr/buffer_list_test.cc + add_executable(fd_conservation_posix_test + test/core/iomgr/fd_conservation_posix_test.cc + ) + + target_include_directories(fd_conservation_posix_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(fd_conservation_posix_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + + add_executable(fd_posix_test + test/core/iomgr/fd_posix_test.cc + ) + + target_include_directories(fd_posix_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(fd_posix_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + + add_executable(fling_stream_test + test/core/end2end/data/client_certs.cc + test/core/end2end/data/server1_cert.cc + test/core/end2end/data/server1_key.cc + test/core/end2end/data/test_root_cert.cc + test/core/fling/fling_stream_test.cc + ) + + target_include_directories(fling_stream_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(fling_stream_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + + add_executable(fling_test + test/core/end2end/data/client_certs.cc + test/core/end2end/data/server1_cert.cc + test/core/end2end/data/server1_key.cc + test/core/end2end/data/test_root_cert.cc + test/core/fling/fling_test.cc + ) + + target_include_directories(fling_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(fling_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + + add_executable(fork_test + test/core/gprpp/fork_test.cc + ) + + target_include_directories(fork_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(fork_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) + +add_executable(format_request_test + test/core/end2end/data/client_certs.cc + test/core/end2end/data/server1_cert.cc + test/core/end2end/data/server1_key.cc + test/core/end2end/data/test_root_cert.cc + test/core/http/format_request_test.cc ) -target_include_directories(buffer_list_test +target_include_directories(format_request_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4857,7 +5121,7 @@ target_include_directories(buffer_list_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(buffer_list_test +target_link_libraries(format_request_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4866,11 +5130,12 @@ target_link_libraries(buffer_list_test endif() if(gRPC_BUILD_TESTS) -add_executable(c_slice_buffer_test - test/core/slice/c_slice_buffer_test.cc +add_executable(goaway_server_test + test/core/end2end/cq_verifier.cc + test/core/end2end/goaway_server_test.cc ) -target_include_directories(c_slice_buffer_test +target_include_directories(goaway_server_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4884,7 +5149,7 @@ target_include_directories(c_slice_buffer_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(c_slice_buffer_test +target_link_libraries(goaway_server_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4893,11 +5158,11 @@ target_link_libraries(c_slice_buffer_test endif() if(gRPC_BUILD_TESTS) -add_executable(channel_stack_test - test/core/channel/channel_stack_test.cc +add_executable(grpc_alts_credentials_options_test + test/core/security/grpc_alts_credentials_options_test.cc ) -target_include_directories(channel_stack_test +target_include_directories(grpc_alts_credentials_options_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4911,7 +5176,7 @@ target_include_directories(channel_stack_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(channel_stack_test +target_link_libraries(grpc_alts_credentials_options_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4920,11 +5185,11 @@ target_link_libraries(channel_stack_test endif() if(gRPC_BUILD_TESTS) -add_executable(check_gcp_environment_linux_test - test/core/security/check_gcp_environment_linux_test.cc +add_executable(grpc_ipv6_loopback_available_test + test/core/iomgr/grpc_ipv6_loopback_available_test.cc ) -target_include_directories(check_gcp_environment_linux_test +target_include_directories(grpc_ipv6_loopback_available_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4938,7 +5203,7 @@ target_include_directories(check_gcp_environment_linux_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(check_gcp_environment_linux_test +target_link_libraries(grpc_ipv6_loopback_available_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -4946,40 +5211,14 @@ target_link_libraries(check_gcp_environment_linux_test endif() if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) -add_executable(check_gcp_environment_windows_test - test/core/security/check_gcp_environment_windows_test.cc -) - -target_include_directories(check_gcp_environment_windows_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(check_gcp_environment_windows_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util -) - - -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(client_ssl_test - test/core/handshake/client_ssl.cc + add_executable(handshake_server_with_readahead_handshaker_test + test/core/handshake/readahead_handshaker_server_ssl.cc + test/core/handshake/server_ssl_common.cc ) - target_include_directories(client_ssl_test + target_include_directories(handshake_server_with_readahead_handshaker_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -4993,7 +5232,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_ZLIB_INCLUDE_DIR} ) - target_link_libraries(client_ssl_test + target_link_libraries(handshake_server_with_readahead_handshaker_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5003,11 +5242,11 @@ endif() endif() if(gRPC_BUILD_TESTS) -add_executable(cmdline_test - test/core/util/cmdline_test.cc +add_executable(histogram_test + test/core/util/histogram_test.cc ) -target_include_directories(cmdline_test +target_include_directories(histogram_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5021,7 +5260,7 @@ target_include_directories(cmdline_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(cmdline_test +target_link_libraries(histogram_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5029,42 +5268,39 @@ target_link_libraries(cmdline_test endif() if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(combiner_test - test/core/iomgr/combiner_test.cc - ) +add_executable(host_port_test + test/core/gprpp/host_port_test.cc +) - target_include_directories(combiner_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) +target_include_directories(host_port_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} +) - target_link_libraries(combiner_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) +target_link_libraries(host_port_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) -endif() endif() if(gRPC_BUILD_TESTS) -add_executable(compression_test - test/core/compression/args_utils.cc - test/core/compression/compression_test.cc +add_executable(hpack_encoder_test + test/core/transport/chttp2/hpack_encoder_test.cc ) -target_include_directories(compression_test +target_include_directories(hpack_encoder_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5078,7 +5314,7 @@ target_include_directories(compression_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(compression_test +target_link_libraries(hpack_encoder_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5087,12 +5323,39 @@ target_link_libraries(compression_test endif() if(gRPC_BUILD_TESTS) -add_executable(connection_refused_test - test/core/end2end/connection_refused_test.cc +add_executable(inproc_callback_test + test/core/end2end/inproc_callback_test.cc +) + +target_include_directories(inproc_callback_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} +) + +target_link_libraries(inproc_callback_test + ${_gRPC_ALLTARGETS_LIBRARIES} + end2end_tests +) + + +endif() +if(gRPC_BUILD_TESTS) + +add_executable(invalid_call_argument_test test/core/end2end/cq_verifier.cc + test/core/end2end/invalid_call_argument_test.cc ) -target_include_directories(connection_refused_test +target_include_directories(invalid_call_argument_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5106,7 +5369,7 @@ target_include_directories(connection_refused_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(connection_refused_test +target_link_libraries(invalid_call_argument_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5115,11 +5378,11 @@ target_link_libraries(connection_refused_test endif() if(gRPC_BUILD_TESTS) -add_executable(cpu_test - test/core/gpr/cpu_test.cc +add_executable(json_token_test + test/core/security/json_token_test.cc ) -target_include_directories(cpu_test +target_include_directories(json_token_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5133,7 +5396,7 @@ target_include_directories(cpu_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(cpu_test +target_link_libraries(json_token_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5141,43 +5404,39 @@ target_link_libraries(cpu_test endif() if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(dualstack_socket_test - test/core/end2end/cq_verifier.cc - test/core/end2end/dualstack_socket_test.cc - ) +add_executable(jwt_verifier_test + test/core/security/jwt_verifier_test.cc +) - target_include_directories(dualstack_socket_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) +target_include_directories(jwt_verifier_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} +) - target_link_libraries(dualstack_socket_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) +target_link_libraries(jwt_verifier_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) -endif() endif() if(gRPC_BUILD_TESTS) -add_executable(endpoint_pair_test - test/core/iomgr/endpoint_pair_test.cc - test/core/iomgr/endpoint_tests.cc +add_executable(load_file_test + test/core/iomgr/load_file_test.cc ) -target_include_directories(endpoint_pair_test +target_include_directories(load_file_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5191,7 +5450,7 @@ target_include_directories(endpoint_pair_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(endpoint_pair_test +target_link_libraries(load_file_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5200,11 +5459,11 @@ target_link_libraries(endpoint_pair_test endif() if(gRPC_BUILD_TESTS) -add_executable(env_test - test/core/gpr/env_test.cc +add_executable(message_compress_test + test/core/compression/message_compress_test.cc ) -target_include_directories(env_test +target_include_directories(message_compress_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5218,7 +5477,7 @@ target_include_directories(env_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(env_test +target_link_libraries(message_compress_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5227,12 +5486,11 @@ target_link_libraries(env_test endif() if(gRPC_BUILD_TESTS) -add_executable(fake_transport_security_test - test/core/tsi/fake_transport_security_test.cc - test/core/tsi/transport_security_test_lib.cc +add_executable(minimal_stack_is_minimal_test + test/core/channel/minimal_stack_is_minimal_test.cc ) -target_include_directories(fake_transport_security_test +target_include_directories(minimal_stack_is_minimal_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5246,7 +5504,7 @@ target_include_directories(fake_transport_security_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(fake_transport_security_test +target_link_libraries(minimal_stack_is_minimal_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5254,42 +5512,40 @@ target_link_libraries(fake_transport_security_test endif() if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(fd_conservation_posix_test - test/core/iomgr/fd_conservation_posix_test.cc - ) +add_executable(mpmcqueue_test + test/core/iomgr/mpmcqueue_test.cc +) - target_include_directories(fd_conservation_posix_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) +target_include_directories(mpmcqueue_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} +) - target_link_libraries(fd_conservation_posix_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) +target_link_libraries(mpmcqueue_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) -endif() endif() if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(fd_posix_test - test/core/iomgr/fd_posix_test.cc + add_executable(mpscq_test + test/core/gprpp/mpscq_test.cc ) - target_include_directories(fd_posix_test + target_include_directories(mpscq_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5303,7 +5559,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_ZLIB_INCLUDE_DIR} ) - target_link_libraries(fd_posix_test + target_link_libraries(mpscq_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5312,111 +5568,40 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) endif() endif() if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(fling_stream_test - test/core/end2end/data/client_certs.cc - test/core/end2end/data/server1_cert.cc - test/core/end2end/data/server1_key.cc - test/core/end2end/data/test_root_cert.cc - test/core/fling/fling_stream_test.cc - ) - - target_include_directories(fling_stream_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) - - target_link_libraries(fling_stream_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) - - -endif() -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(fling_test - test/core/end2end/data/client_certs.cc - test/core/end2end/data/server1_cert.cc - test/core/end2end/data/server1_key.cc - test/core/end2end/data/test_root_cert.cc - test/core/fling/fling_test.cc - ) - - target_include_directories(fling_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) - - target_link_libraries(fling_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) - - -endif() -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(fork_test - test/core/gprpp/fork_test.cc - ) +add_executable(multiple_server_queues_test + test/core/end2end/cq_verifier.cc + test/core/end2end/multiple_server_queues_test.cc +) - target_include_directories(fork_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) +target_include_directories(multiple_server_queues_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} +) - target_link_libraries(fork_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) +target_link_libraries(multiple_server_queues_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) -endif() endif() if(gRPC_BUILD_TESTS) -add_executable(format_request_test - test/core/end2end/data/client_certs.cc - test/core/end2end/data/server1_cert.cc - test/core/end2end/data/server1_key.cc - test/core/end2end/data/test_root_cert.cc - test/core/http/format_request_test.cc +add_executable(murmur_hash_test + test/core/gpr/murmur_hash_test.cc ) -target_include_directories(format_request_test +target_include_directories(murmur_hash_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5430,7 +5615,7 @@ target_include_directories(format_request_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(format_request_test +target_link_libraries(murmur_hash_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5439,12 +5624,12 @@ target_link_libraries(format_request_test endif() if(gRPC_BUILD_TESTS) -add_executable(frame_handler_test - test/core/tsi/alts/crypt/gsec_test_util.cc - test/core/tsi/alts/frame_protector/frame_handler_test.cc +add_executable(no_server_test + test/core/end2end/cq_verifier.cc + test/core/end2end/no_server_test.cc ) -target_include_directories(frame_handler_test +target_include_directories(no_server_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5458,7 +5643,7 @@ target_include_directories(frame_handler_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(frame_handler_test +target_link_libraries(no_server_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5467,12 +5652,15 @@ target_link_libraries(frame_handler_test endif() if(gRPC_BUILD_TESTS) -add_executable(goaway_server_test - test/core/end2end/cq_verifier.cc - test/core/end2end/goaway_server_test.cc +add_executable(parser_test + test/core/end2end/data/client_certs.cc + test/core/end2end/data/server1_cert.cc + test/core/end2end/data/server1_key.cc + test/core/end2end/data/test_root_cert.cc + test/core/http/parser_test.cc ) -target_include_directories(goaway_server_test +target_include_directories(parser_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5486,7 +5674,7 @@ target_include_directories(goaway_server_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(goaway_server_test +target_link_libraries(parser_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5495,11 +5683,11 @@ target_link_libraries(goaway_server_test endif() if(gRPC_BUILD_TESTS) -add_executable(grpc_alts_credentials_options_test - test/core/security/grpc_alts_credentials_options_test.cc +add_executable(percent_encoding_test + test/core/slice/percent_encoding_test.cc ) -target_include_directories(grpc_alts_credentials_options_test +target_include_directories(percent_encoding_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5513,7 +5701,7 @@ target_include_directories(grpc_alts_credentials_options_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(grpc_alts_credentials_options_test +target_link_libraries(percent_encoding_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5522,11 +5710,13 @@ target_link_libraries(grpc_alts_credentials_options_test endif() if(gRPC_BUILD_TESTS) -add_executable(grpc_ipv6_loopback_available_test - test/core/iomgr/grpc_ipv6_loopback_available_test.cc +add_executable(public_headers_must_be_c89 + src/core/lib/security/authorization/grpc_authorization_policy_provider.cc + src/core/lib/security/authorization/rbac_translator.cc + test/core/surface/public_headers_must_be_c89.c ) -target_include_directories(grpc_ipv6_loopback_available_test +target_include_directories(public_headers_must_be_c89 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5540,7 +5730,7 @@ target_include_directories(grpc_ipv6_loopback_available_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(grpc_ipv6_loopback_available_test +target_link_libraries(public_headers_must_be_c89 ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5550,12 +5740,11 @@ endif() if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(handshake_server_with_readahead_handshaker_test - test/core/handshake/readahead_handshaker_server_ssl.cc - test/core/handshake/server_ssl_common.cc + add_executable(resolve_address_using_ares_resolver_posix_test + test/core/iomgr/resolve_address_posix_test.cc ) - target_include_directories(handshake_server_with_readahead_handshaker_test + target_include_directories(resolve_address_using_ares_resolver_posix_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5569,7 +5758,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_ZLIB_INCLUDE_DIR} ) - target_link_libraries(handshake_server_with_readahead_handshaker_test + target_link_libraries(resolve_address_using_ares_resolver_posix_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5578,12 +5767,42 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) endif() endif() if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) -add_executable(histogram_test - test/core/util/histogram_test.cc + add_executable(resolve_address_using_native_resolver_posix_test + test/core/iomgr/resolve_address_posix_test.cc + ) + + target_include_directories(resolve_address_using_native_resolver_posix_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(resolve_address_using_native_resolver_posix_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) + +add_executable(secure_endpoint_test + test/core/iomgr/endpoint_tests.cc + test/core/security/secure_endpoint_test.cc ) -target_include_directories(histogram_test +target_include_directories(secure_endpoint_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5597,7 +5816,7 @@ target_include_directories(histogram_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(histogram_test +target_link_libraries(secure_endpoint_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5606,11 +5825,11 @@ target_link_libraries(histogram_test endif() if(gRPC_BUILD_TESTS) -add_executable(host_port_test - test/core/gprpp/host_port_test.cc +add_executable(security_connector_test + test/core/security/security_connector_test.cc ) -target_include_directories(host_port_test +target_include_directories(security_connector_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5624,7 +5843,7 @@ target_include_directories(host_port_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(host_port_test +target_link_libraries(security_connector_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5632,12 +5851,45 @@ target_link_libraries(host_port_test endif() if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) -add_executable(hpack_encoder_test - test/core/transport/chttp2/hpack_encoder_test.cc + add_executable(server_ssl_test + test/core/handshake/server_ssl.cc + test/core/handshake/server_ssl_common.cc + ) + + target_include_directories(server_ssl_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(server_ssl_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) + +add_executable(slice_string_helpers_test + src/core/lib/slice/slice.cc + src/core/lib/slice/slice_refcount.cc + src/core/lib/slice/slice_string_helpers.cc + test/core/slice/slice_string_helpers_test.cc ) -target_include_directories(hpack_encoder_test +target_include_directories(slice_string_helpers_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5651,48 +5903,49 @@ target_include_directories(hpack_encoder_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(hpack_encoder_test +target_link_libraries(slice_string_helpers_test ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util + gpr ) endif() if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) -add_executable(inproc_callback_test - test/core/end2end/inproc_callback_test.cc -) + add_executable(socket_utils_test + test/core/iomgr/socket_utils_test.cc + ) -target_include_directories(inproc_callback_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) + target_include_directories(socket_utils_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) -target_link_libraries(inproc_callback_test - ${_gRPC_ALLTARGETS_LIBRARIES} - end2end_tests -) + target_link_libraries(socket_utils_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) +endif() endif() if(gRPC_BUILD_TESTS) -add_executable(invalid_call_argument_test - test/core/end2end/cq_verifier.cc - test/core/end2end/invalid_call_argument_test.cc +add_executable(spinlock_test + test/core/gpr/spinlock_test.cc ) -target_include_directories(invalid_call_argument_test +target_include_directories(spinlock_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5706,7 +5959,7 @@ target_include_directories(invalid_call_argument_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(invalid_call_argument_test +target_link_libraries(spinlock_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5715,11 +5968,11 @@ target_link_libraries(invalid_call_argument_test endif() if(gRPC_BUILD_TESTS) -add_executable(json_token_test - test/core/security/json_token_test.cc +add_executable(ssl_credentials_test + test/core/security/ssl_credentials_test.cc ) -target_include_directories(json_token_test +target_include_directories(ssl_credentials_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5733,7 +5986,7 @@ target_include_directories(json_token_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(json_token_test +target_link_libraries(ssl_credentials_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5742,11 +5995,11 @@ target_link_libraries(json_token_test endif() if(gRPC_BUILD_TESTS) -add_executable(jwt_verifier_test - test/core/security/jwt_verifier_test.cc +add_executable(status_conversion_test + test/core/transport/status_conversion_test.cc ) -target_include_directories(jwt_verifier_test +target_include_directories(status_conversion_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5760,7 +6013,7 @@ target_include_directories(jwt_verifier_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(jwt_verifier_test +target_link_libraries(status_conversion_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5769,11 +6022,11 @@ target_link_libraries(jwt_verifier_test endif() if(gRPC_BUILD_TESTS) -add_executable(load_file_test - test/core/iomgr/load_file_test.cc +add_executable(stream_map_test + test/core/transport/chttp2/stream_map_test.cc ) -target_include_directories(load_file_test +target_include_directories(stream_map_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5787,7 +6040,7 @@ target_include_directories(load_file_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(load_file_test +target_link_libraries(stream_map_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5796,11 +6049,11 @@ target_link_libraries(load_file_test endif() if(gRPC_BUILD_TESTS) -add_executable(message_compress_test - test/core/compression/message_compress_test.cc +add_executable(string_test + test/core/gpr/string_test.cc ) -target_include_directories(message_compress_test +target_include_directories(string_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5814,7 +6067,7 @@ target_include_directories(message_compress_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(message_compress_test +target_link_libraries(string_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5823,11 +6076,11 @@ target_link_libraries(message_compress_test endif() if(gRPC_BUILD_TESTS) -add_executable(minimal_stack_is_minimal_test - test/core/channel/minimal_stack_is_minimal_test.cc +add_executable(sync_test + test/core/gpr/sync_test.cc ) -target_include_directories(minimal_stack_is_minimal_test +target_include_directories(sync_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5841,7 +6094,7 @@ target_include_directories(minimal_stack_is_minimal_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(minimal_stack_is_minimal_test +target_link_libraries(sync_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5849,40 +6102,72 @@ target_link_libraries(minimal_stack_is_minimal_test endif() if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) -add_executable(mpmcqueue_test - test/core/iomgr/mpmcqueue_test.cc -) + add_executable(tcp_client_posix_test + test/core/iomgr/tcp_client_posix_test.cc + ) -target_include_directories(mpmcqueue_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) + target_include_directories(tcp_client_posix_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) -target_link_libraries(mpmcqueue_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util -) + target_link_libraries(tcp_client_posix_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) + + add_executable(tcp_posix_test + test/core/iomgr/endpoint_tests.cc + test/core/iomgr/tcp_posix_test.cc + ) + + target_include_directories(tcp_posix_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + ) + + target_link_libraries(tcp_posix_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) +endif() endif() if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(mpscq_test - test/core/gprpp/mpscq_test.cc + add_executable(tcp_server_posix_test + test/core/iomgr/tcp_server_posix_test.cc ) - target_include_directories(mpscq_test + target_include_directories(tcp_server_posix_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5896,7 +6181,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_ZLIB_INCLUDE_DIR} ) - target_link_libraries(mpscq_test + target_link_libraries(tcp_server_posix_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5906,12 +6191,11 @@ endif() endif() if(gRPC_BUILD_TESTS) -add_executable(multiple_server_queues_test - test/core/end2end/cq_verifier.cc - test/core/end2end/multiple_server_queues_test.cc +add_executable(test_core_gpr_time_test + test/core/gpr/time_test.cc ) -target_include_directories(multiple_server_queues_test +target_include_directories(test_core_gpr_time_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5925,7 +6209,7 @@ target_include_directories(multiple_server_queues_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(multiple_server_queues_test +target_link_libraries(test_core_gpr_time_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5934,11 +6218,11 @@ target_link_libraries(multiple_server_queues_test endif() if(gRPC_BUILD_TESTS) -add_executable(murmur_hash_test - test/core/gpr/murmur_hash_test.cc +add_executable(test_core_iomgr_time_averaged_stats_test + test/core/iomgr/time_averaged_stats_test.cc ) -target_include_directories(murmur_hash_test +target_include_directories(test_core_iomgr_time_averaged_stats_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5952,7 +6236,7 @@ target_include_directories(murmur_hash_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(murmur_hash_test +target_link_libraries(test_core_iomgr_time_averaged_stats_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5961,12 +6245,11 @@ target_link_libraries(murmur_hash_test endif() if(gRPC_BUILD_TESTS) -add_executable(no_server_test - test/core/end2end/cq_verifier.cc - test/core/end2end/no_server_test.cc +add_executable(test_core_iomgr_timer_heap_test + test/core/iomgr/timer_heap_test.cc ) -target_include_directories(no_server_test +target_include_directories(test_core_iomgr_timer_heap_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -5980,7 +6263,7 @@ target_include_directories(no_server_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(no_server_test +target_link_libraries(test_core_iomgr_timer_heap_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -5989,15 +6272,11 @@ target_link_libraries(no_server_test endif() if(gRPC_BUILD_TESTS) -add_executable(parser_test - test/core/end2end/data/client_certs.cc - test/core/end2end/data/server1_cert.cc - test/core/end2end/data/server1_key.cc - test/core/end2end/data/test_root_cert.cc - test/core/http/parser_test.cc +add_executable(test_core_iomgr_timer_list_test + test/core/iomgr/timer_list_test.cc ) -target_include_directories(parser_test +target_include_directories(test_core_iomgr_timer_list_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6011,7 +6290,7 @@ target_include_directories(parser_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(parser_test +target_link_libraries(test_core_iomgr_timer_list_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -6020,11 +6299,11 @@ target_link_libraries(parser_test endif() if(gRPC_BUILD_TESTS) -add_executable(percent_encoding_test - test/core/slice/percent_encoding_test.cc +add_executable(thd_test + test/core/gprpp/thd_test.cc ) -target_include_directories(percent_encoding_test +target_include_directories(thd_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6038,7 +6317,7 @@ target_include_directories(percent_encoding_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(percent_encoding_test +target_link_libraries(thd_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -6047,13 +6326,11 @@ target_link_libraries(percent_encoding_test endif() if(gRPC_BUILD_TESTS) -add_executable(public_headers_must_be_c89 - src/core/lib/security/authorization/grpc_authorization_policy_provider.cc - src/core/lib/security/authorization/rbac_translator.cc - test/core/surface/public_headers_must_be_c89.c +add_executable(threadpool_test + test/core/iomgr/threadpool_test.cc ) -target_include_directories(public_headers_must_be_c89 +target_include_directories(threadpool_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6067,7 +6344,7 @@ target_include_directories(public_headers_must_be_c89 ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(public_headers_must_be_c89 +target_link_libraries(threadpool_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -6075,71 +6352,12 @@ target_link_libraries(public_headers_must_be_c89 endif() if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(resolve_address_using_ares_resolver_posix_test - test/core/iomgr/resolve_address_posix_test.cc - ) - - target_include_directories(resolve_address_using_ares_resolver_posix_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) - - target_link_libraries(resolve_address_using_ares_resolver_posix_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) +add_executable(varint_test + test/core/transport/chttp2/varint_test.cc +) -endif() -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(resolve_address_using_native_resolver_posix_test - test/core/iomgr/resolve_address_posix_test.cc - ) - - target_include_directories(resolve_address_using_native_resolver_posix_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) - - target_link_libraries(resolve_address_using_native_resolver_posix_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) - - -endif() -endif() -if(gRPC_BUILD_TESTS) - -add_executable(secure_endpoint_test - test/core/iomgr/endpoint_tests.cc - test/core/security/secure_endpoint_test.cc -) - -target_include_directories(secure_endpoint_test +target_include_directories(varint_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6153,7 +6371,7 @@ target_include_directories(secure_endpoint_test ${_gRPC_ZLIB_INCLUDE_DIR} ) -target_link_libraries(secure_endpoint_test +target_link_libraries(varint_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -6162,11 +6380,57 @@ target_link_libraries(secure_endpoint_test endif() if(gRPC_BUILD_TESTS) -add_executable(security_connector_test - test/core/security/security_connector_test.cc +add_executable(activity_test + src/core/lib/gpr/alloc.cc + src/core/lib/gpr/atm.cc + src/core/lib/gpr/cpu_iphone.cc + src/core/lib/gpr/cpu_linux.cc + src/core/lib/gpr/cpu_posix.cc + src/core/lib/gpr/cpu_windows.cc + src/core/lib/gpr/env_linux.cc + src/core/lib/gpr/env_posix.cc + src/core/lib/gpr/env_windows.cc + src/core/lib/gpr/log.cc + src/core/lib/gpr/log_android.cc + src/core/lib/gpr/log_linux.cc + src/core/lib/gpr/log_posix.cc + src/core/lib/gpr/log_windows.cc + src/core/lib/gpr/murmur_hash.cc + src/core/lib/gpr/string.cc + src/core/lib/gpr/string_posix.cc + src/core/lib/gpr/string_util_windows.cc + src/core/lib/gpr/string_windows.cc + src/core/lib/gpr/sync.cc + src/core/lib/gpr/sync_abseil.cc + src/core/lib/gpr/sync_posix.cc + src/core/lib/gpr/sync_windows.cc + src/core/lib/gpr/time.cc + src/core/lib/gpr/time_posix.cc + src/core/lib/gpr/time_precise.cc + src/core/lib/gpr/time_windows.cc + src/core/lib/gpr/tmpfile_msys.cc + src/core/lib/gpr/tmpfile_posix.cc + src/core/lib/gpr/tmpfile_windows.cc + src/core/lib/gpr/wrap_memcpy.cc + src/core/lib/gprpp/examine_stack.cc + src/core/lib/gprpp/fork.cc + src/core/lib/gprpp/global_config_env.cc + src/core/lib/gprpp/host_port.cc + src/core/lib/gprpp/mpscq.cc + src/core/lib/gprpp/stat_posix.cc + src/core/lib/gprpp/stat_windows.cc + src/core/lib/gprpp/thd_posix.cc + src/core/lib/gprpp/thd_windows.cc + src/core/lib/gprpp/time_util.cc + src/core/lib/profiling/basic_timers.cc + src/core/lib/profiling/stap_timers.cc + src/core/lib/promise/activity.cc + test/core/promise/activity_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(security_connector_test +target_include_directories(activity_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6178,11 +6442,33 @@ target_include_directories(security_connector_test ${_gRPC_UPB_INCLUDE_DIR} ${_gRPC_XXHASH_INCLUDE_DIR} ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(security_connector_test +target_link_libraries(activity_test + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util + absl::base + absl::core_headers + absl::flat_hash_set + absl::hash + absl::memory + absl::type_traits + absl::random_random + absl::status + absl::statusor + absl::cord + absl::str_format + absl::strings + absl::synchronization + absl::time + absl::optional + absl::variant + absl::utility ) @@ -6190,12 +6476,13 @@ endif() if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(server_ssl_test - test/core/handshake/server_ssl.cc - test/core/handshake/server_ssl_common.cc + add_executable(address_sorting_test + test/cpp/naming/address_sorting_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) - target_include_directories(server_ssl_test + target_include_directories(address_sorting_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6207,54 +6494,36 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_UPB_INCLUDE_DIR} ${_gRPC_XXHASH_INCLUDE_DIR} ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} ) - target_link_libraries(server_ssl_test + target_link_libraries(address_sorting_test + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util + grpc++_test_config + grpc++_test_util ) endif() -endif() -if(gRPC_BUILD_TESTS) - -add_executable(slice_string_helpers_test - src/core/lib/slice/slice.cc - src/core/lib/slice/slice_refcount.cc - src/core/lib/slice/slice_string_helpers.cc - test/core/slice/slice_string_helpers_test.cc -) - -target_include_directories(slice_string_helpers_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(slice_string_helpers_test - ${_gRPC_ALLTARGETS_LIBRARIES} - gpr -) - - endif() if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(socket_utils_test - test/core/iomgr/socket_utils_test.cc + add_executable(address_sorting_test_unsecure + test/cpp/naming/address_sorting_test.cc + test/cpp/util/byte_buffer_proto_helper.cc + test/cpp/util/string_ref_helper.cc + test/cpp/util/subprocess.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) - target_include_directories(socket_utils_test + target_include_directories(address_sorting_test_unsecure PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6266,11 +6535,19 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_UPB_INCLUDE_DIR} ${_gRPC_XXHASH_INCLUDE_DIR} ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} ) - target_link_libraries(socket_utils_test + target_link_libraries(address_sorting_test_unsecure + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util + grpc++_unsecure + grpc_test_util_unsecure + grpc++_test_config ) @@ -6278,38 +6555,31 @@ endif() endif() if(gRPC_BUILD_TESTS) -add_executable(spinlock_test - test/core/gpr/spinlock_test.cc -) - -target_include_directories(spinlock_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(spinlock_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util -) - - -endif() -if(gRPC_BUILD_TESTS) - -add_executable(ssl_credentials_test - test/core/security/ssl_credentials_test.cc +add_executable(admin_services_end2end_test + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.grpc.pb.h + src/cpp/server/admin/admin_services.cc + src/cpp/server/csds/csds.cc + test/cpp/end2end/admin_services_end2end_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(ssl_credentials_test +target_include_directories(admin_services_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6321,11 +6591,19 @@ target_include_directories(ssl_credentials_test ${_gRPC_UPB_INCLUDE_DIR} ${_gRPC_XXHASH_INCLUDE_DIR} ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(ssl_credentials_test +target_link_libraries(admin_services_end2end_test + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util + grpc++_reflection + grpcpp_channelz + grpc++_test_util ) @@ -6333,12 +6611,13 @@ endif() if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_executable(ssl_transport_security_test - test/core/tsi/ssl_transport_security_test.cc - test/core/tsi/transport_security_test_lib.cc + add_executable(alarm_test + test/cpp/common/alarm_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) - target_include_directories(ssl_transport_security_test + target_include_directories(alarm_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6350,10 +6629,66 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_UPB_INCLUDE_DIR} ${_gRPC_XXHASH_INCLUDE_DIR} ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} ) - target_link_libraries(ssl_transport_security_test + target_link_libraries(alarm_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++_unsecure + grpc_test_util_unsecure + ) + + +endif() +endif() +if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) + + add_executable(alts_concurrent_connectivity_test + ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/handshaker.pb.cc + ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/handshaker.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/handshaker.pb.h + ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/handshaker.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/transport_security_common.pb.cc + ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/transport_security_common.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/transport_security_common.pb.h + ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/transport_security_common.grpc.pb.h + test/core/end2end/cq_verifier.cc + test/core/tsi/alts/fake_handshaker/fake_handshaker_server.cc + test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc + test/core/util/fake_udp_and_tcp_server.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc + ) + + target_include_directories(alts_concurrent_connectivity_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} + ) + + target_link_libraries(alts_concurrent_connectivity_test + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++ grpc_test_util ) @@ -6362,11 +6697,14 @@ endif() endif() if(gRPC_BUILD_TESTS) -add_executable(status_conversion_test - test/core/transport/status_conversion_test.cc +add_executable(alts_counter_test + test/core/tsi/alts/crypt/gsec_test_util.cc + test/core/tsi/alts/frame_protector/alts_counter_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(status_conversion_test +target_include_directories(alts_counter_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6378,9 +6716,15 @@ target_include_directories(status_conversion_test ${_gRPC_UPB_INCLUDE_DIR} ${_gRPC_XXHASH_INCLUDE_DIR} ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(status_conversion_test +target_link_libraries(alts_counter_test + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -6389,11 +6733,14 @@ target_link_libraries(status_conversion_test endif() if(gRPC_BUILD_TESTS) -add_executable(stream_map_test - test/core/transport/chttp2/stream_map_test.cc +add_executable(alts_crypt_test + test/core/tsi/alts/crypt/aes_gcm_test.cc + test/core/tsi/alts/crypt/gsec_test_util.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(stream_map_test +target_include_directories(alts_crypt_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6405,9 +6752,15 @@ target_include_directories(stream_map_test ${_gRPC_UPB_INCLUDE_DIR} ${_gRPC_XXHASH_INCLUDE_DIR} ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(stream_map_test +target_link_libraries(alts_crypt_test + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -6416,11 +6769,14 @@ target_link_libraries(stream_map_test endif() if(gRPC_BUILD_TESTS) -add_executable(string_test - test/core/gpr/string_test.cc +add_executable(alts_crypter_test + test/core/tsi/alts/crypt/gsec_test_util.cc + test/core/tsi/alts/frame_protector/alts_crypter_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(string_test +target_include_directories(alts_crypter_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6432,9 +6788,15 @@ target_include_directories(string_test ${_gRPC_UPB_INCLUDE_DIR} ${_gRPC_XXHASH_INCLUDE_DIR} ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(string_test +target_link_libraries(alts_crypter_test + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -6443,11 +6805,15 @@ target_link_libraries(string_test endif() if(gRPC_BUILD_TESTS) -add_executable(sync_test - test/core/gpr/sync_test.cc +add_executable(alts_frame_protector_test + test/core/tsi/alts/crypt/gsec_test_util.cc + test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc + test/core/tsi/transport_security_test_lib.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(sync_test +target_include_directories(alts_frame_protector_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6459,110 +6825,31 @@ target_include_directories(sync_test ${_gRPC_UPB_INCLUDE_DIR} ${_gRPC_XXHASH_INCLUDE_DIR} ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(sync_test +target_link_libraries(alts_frame_protector_test + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(tcp_client_posix_test - test/core/iomgr/tcp_client_posix_test.cc - ) - - target_include_directories(tcp_client_posix_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) - - target_link_libraries(tcp_client_posix_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) - - -endif() -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) - - add_executable(tcp_posix_test - test/core/iomgr/endpoint_tests.cc - test/core/iomgr/tcp_posix_test.cc - ) - - target_include_directories(tcp_posix_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) - - target_link_libraries(tcp_posix_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) - - -endif() -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(tcp_server_posix_test - test/core/iomgr/tcp_server_posix_test.cc - ) - - target_include_directories(tcp_server_posix_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - ) - - target_link_libraries(tcp_server_posix_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) - - -endif() endif() if(gRPC_BUILD_TESTS) -add_executable(test_core_gpr_time_test - test/core/gpr/time_test.cc +add_executable(alts_grpc_record_protocol_test + test/core/tsi/alts/crypt/gsec_test_util.cc + test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(test_core_gpr_time_test +target_include_directories(alts_grpc_record_protocol_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6574,9 +6861,15 @@ target_include_directories(test_core_gpr_time_test ${_gRPC_UPB_INCLUDE_DIR} ${_gRPC_XXHASH_INCLUDE_DIR} ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(test_core_gpr_time_test +target_link_libraries(alts_grpc_record_protocol_test + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -6585,11 +6878,14 @@ target_link_libraries(test_core_gpr_time_test endif() if(gRPC_BUILD_TESTS) -add_executable(test_core_iomgr_time_averaged_stats_test - test/core/iomgr/time_averaged_stats_test.cc +add_executable(alts_handshaker_client_test + test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc + test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(test_core_iomgr_time_averaged_stats_test +target_include_directories(alts_handshaker_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6601,198 +6897,15 @@ target_include_directories(test_core_iomgr_time_averaged_stats_test ${_gRPC_UPB_INCLUDE_DIR} ${_gRPC_XXHASH_INCLUDE_DIR} ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(test_core_iomgr_time_averaged_stats_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util -) - - -endif() -if(gRPC_BUILD_TESTS) - -add_executable(test_core_iomgr_timer_heap_test - test/core/iomgr/timer_heap_test.cc -) - -target_include_directories(test_core_iomgr_timer_heap_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(test_core_iomgr_timer_heap_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util -) - - -endif() -if(gRPC_BUILD_TESTS) - -add_executable(test_core_iomgr_timer_list_test - test/core/iomgr/timer_list_test.cc -) - -target_include_directories(test_core_iomgr_timer_list_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(test_core_iomgr_timer_list_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util -) - - -endif() -if(gRPC_BUILD_TESTS) - -add_executable(thd_test - test/core/gprpp/thd_test.cc -) - -target_include_directories(thd_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(thd_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util -) - - -endif() -if(gRPC_BUILD_TESTS) - -add_executable(threadpool_test - test/core/iomgr/threadpool_test.cc -) - -target_include_directories(threadpool_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(threadpool_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util -) - - -endif() -if(gRPC_BUILD_TESTS) - -add_executable(transport_security_common_api_test - test/core/tsi/alts/handshaker/transport_security_common_api_test.cc -) - -target_include_directories(transport_security_common_api_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(transport_security_common_api_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util -) - - -endif() -if(gRPC_BUILD_TESTS) - -add_executable(transport_security_test - test/core/tsi/transport_security_test.cc -) - -target_include_directories(transport_security_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(transport_security_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util -) - - -endif() -if(gRPC_BUILD_TESTS) - -add_executable(varint_test - test/core/transport/chttp2/varint_test.cc -) - -target_include_directories(varint_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(varint_test +target_link_libraries(alts_handshaker_client_test + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util ) @@ -6801,57 +6914,14 @@ target_link_libraries(varint_test endif() if(gRPC_BUILD_TESTS) -add_executable(activity_test - src/core/lib/gpr/alloc.cc - src/core/lib/gpr/atm.cc - src/core/lib/gpr/cpu_iphone.cc - src/core/lib/gpr/cpu_linux.cc - src/core/lib/gpr/cpu_posix.cc - src/core/lib/gpr/cpu_windows.cc - src/core/lib/gpr/env_linux.cc - src/core/lib/gpr/env_posix.cc - src/core/lib/gpr/env_windows.cc - src/core/lib/gpr/log.cc - src/core/lib/gpr/log_android.cc - src/core/lib/gpr/log_linux.cc - src/core/lib/gpr/log_posix.cc - src/core/lib/gpr/log_windows.cc - src/core/lib/gpr/murmur_hash.cc - src/core/lib/gpr/string.cc - src/core/lib/gpr/string_posix.cc - src/core/lib/gpr/string_util_windows.cc - src/core/lib/gpr/string_windows.cc - src/core/lib/gpr/sync.cc - src/core/lib/gpr/sync_abseil.cc - src/core/lib/gpr/sync_posix.cc - src/core/lib/gpr/sync_windows.cc - src/core/lib/gpr/time.cc - src/core/lib/gpr/time_posix.cc - src/core/lib/gpr/time_precise.cc - src/core/lib/gpr/time_windows.cc - src/core/lib/gpr/tmpfile_msys.cc - src/core/lib/gpr/tmpfile_posix.cc - src/core/lib/gpr/tmpfile_windows.cc - src/core/lib/gpr/wrap_memcpy.cc - src/core/lib/gprpp/examine_stack.cc - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc - src/core/lib/gprpp/host_port.cc - src/core/lib/gprpp/mpscq.cc - src/core/lib/gprpp/stat_posix.cc - src/core/lib/gprpp/stat_windows.cc - src/core/lib/gprpp/thd_posix.cc - src/core/lib/gprpp/thd_windows.cc - src/core/lib/gprpp/time_util.cc - src/core/lib/profiling/basic_timers.cc - src/core/lib/profiling/stap_timers.cc - src/core/lib/promise/activity.cc - test/core/promise/activity_test.cc +add_executable(alts_iovec_record_protocol_test + test/core/tsi/alts/crypt/gsec_test_util.cc + test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(activity_test +target_include_directories(alts_iovec_record_protocol_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -6870,137 +6940,24 @@ target_include_directories(activity_test ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(activity_test +target_link_libraries(alts_iovec_record_protocol_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::base - absl::core_headers - absl::flat_hash_set - absl::hash - absl::memory - absl::type_traits - absl::random_random - absl::status - absl::statusor - absl::cord - absl::str_format - absl::strings - absl::synchronization - absl::time - absl::optional - absl::variant - absl::utility + grpc_test_util ) endif() if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(address_sorting_test - test/cpp/naming/address_sorting_test.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc - ) - - target_include_directories(address_sorting_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - third_party/googletest/googletest/include - third_party/googletest/googletest - third_party/googletest/googlemock/include - third_party/googletest/googlemock - ${_gRPC_PROTO_GENS_DIR} - ) - target_link_libraries(address_sorting_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc++_test_config - grpc++_test_util - ) - - -endif() -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(address_sorting_test_unsecure - test/cpp/naming/address_sorting_test.cc - test/cpp/util/byte_buffer_proto_helper.cc - test/cpp/util/string_ref_helper.cc - test/cpp/util/subprocess.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc - ) - - target_include_directories(address_sorting_test_unsecure - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - third_party/googletest/googletest/include - third_party/googletest/googletest - third_party/googletest/googlemock/include - third_party/googletest/googlemock - ${_gRPC_PROTO_GENS_DIR} - ) - - target_link_libraries(address_sorting_test_unsecure - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc++_unsecure - grpc_test_util_unsecure - grpc++_test_config - ) - - -endif() -endif() -if(gRPC_BUILD_TESTS) - -add_executable(admin_services_end2end_test - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.grpc.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.grpc.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.grpc.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.grpc.pb.h - src/cpp/server/admin/admin_services.cc - src/cpp/server/csds/csds.cc - test/cpp/end2end/admin_services_end2end_test.cc +add_executable(alts_tsi_handshaker_test + test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc + test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(admin_services_end2end_test +target_include_directories(alts_tsi_handshaker_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -7019,102 +6976,49 @@ target_include_directories(admin_services_end2end_test ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(admin_services_end2end_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc++_reflection - grpcpp_channelz - grpc++_test_util -) - - -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(alarm_test - test/cpp/common/alarm_test.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc - ) - - target_include_directories(alarm_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - third_party/googletest/googletest/include - third_party/googletest/googletest - third_party/googletest/googlemock/include - third_party/googletest/googlemock - ${_gRPC_PROTO_GENS_DIR} - ) - - target_link_libraries(alarm_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc++_unsecure - grpc_test_util_unsecure - ) - - -endif() -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) - - add_executable(alts_concurrent_connectivity_test - ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/handshaker.pb.cc - ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/handshaker.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/handshaker.pb.h - ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/handshaker.grpc.pb.h - ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/transport_security_common.pb.cc - ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/transport_security_common.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/transport_security_common.pb.h - ${_gRPC_PROTO_GENS_DIR}/test/core/tsi/alts/fake_handshaker/transport_security_common.grpc.pb.h - test/core/end2end/cq_verifier.cc - test/core/tsi/alts/fake_handshaker/fake_handshaker_server.cc - test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc - test/core/util/fake_udp_and_tcp_server.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc - ) - - target_include_directories(alts_concurrent_connectivity_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - third_party/googletest/googletest/include - third_party/googletest/googletest - third_party/googletest/googlemock/include - third_party/googletest/googlemock - ${_gRPC_PROTO_GENS_DIR} - ) - - target_link_libraries(alts_concurrent_connectivity_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc++ - grpc_test_util - ) +target_link_libraries(alts_tsi_handshaker_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) endif() +if(gRPC_BUILD_TESTS) + +add_executable(alts_tsi_utils_test + test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc + test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + +target_include_directories(alts_tsi_utils_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(alts_tsi_utils_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) + + endif() if(gRPC_BUILD_TESTS) @@ -7151,6 +7055,42 @@ target_link_libraries(alts_util_test ) +endif() +if(gRPC_BUILD_TESTS) + +add_executable(alts_zero_copy_grpc_protector_test + test/core/tsi/alts/crypt/gsec_test_util.cc + test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + +target_include_directories(alts_zero_copy_grpc_protector_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(alts_zero_copy_grpc_protector_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) + + endif() if(gRPC_BUILD_TESTS) @@ -10257,6 +10197,42 @@ target_link_libraries(fake_resolver_test ) +endif() +if(gRPC_BUILD_TESTS) + +add_executable(fake_transport_security_test + test/core/tsi/fake_transport_security_test.cc + test/core/tsi/transport_security_test_lib.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + +target_include_directories(fake_transport_security_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(fake_transport_security_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) + + endif() if(gRPC_BUILD_TESTS) @@ -10526,6 +10502,42 @@ target_link_libraries(for_each_test ) +endif() +if(gRPC_BUILD_TESTS) + +add_executable(frame_handler_test + test/core/tsi/alts/crypt/gsec_test_util.cc + test/core/tsi/alts/frame_protector/frame_handler_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + +target_include_directories(frame_handler_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(frame_handler_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) + + endif() if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) @@ -15995,6 +16007,44 @@ target_link_libraries(sockaddr_utils_test ) +endif() +if(gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + + add_executable(ssl_transport_security_test + test/core/tsi/ssl_transport_security_test.cc + test/core/tsi/transport_security_test_lib.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc + ) + + target_include_directories(ssl_transport_security_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} + ) + + target_link_libraries(ssl_transport_security_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + ) + + +endif() endif() if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) @@ -17582,6 +17632,76 @@ target_link_libraries(too_many_pings_test ) +endif() +if(gRPC_BUILD_TESTS) + +add_executable(transport_security_common_api_test + test/core/tsi/alts/handshaker/transport_security_common_api_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + +target_include_directories(transport_security_common_api_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(transport_security_common_api_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) + + +endif() +if(gRPC_BUILD_TESTS) + +add_executable(transport_security_test + test/core/tsi/transport_security_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + +target_include_directories(transport_security_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(transport_security_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) + + endif() if(gRPC_BUILD_TESTS) diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index e5227540bd6..ed2ae34c113 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -3210,78 +3210,6 @@ targets: - test/core/transport/chttp2/alpn_test.cc deps: - grpc_test_util -- name: alts_counter_test - build: test - language: c - headers: - - test/core/tsi/alts/crypt/gsec_test_util.h - src: - - test/core/tsi/alts/crypt/gsec_test_util.cc - - test/core/tsi/alts/frame_protector/alts_counter_test.cc - deps: - - grpc_test_util -- name: alts_crypt_test - build: test - language: c - headers: - - test/core/tsi/alts/crypt/gsec_test_util.h - src: - - test/core/tsi/alts/crypt/aes_gcm_test.cc - - test/core/tsi/alts/crypt/gsec_test_util.cc - deps: - - grpc_test_util -- name: alts_crypter_test - build: test - language: c - headers: - - test/core/tsi/alts/crypt/gsec_test_util.h - src: - - test/core/tsi/alts/crypt/gsec_test_util.cc - - test/core/tsi/alts/frame_protector/alts_crypter_test.cc - deps: - - grpc_test_util -- name: alts_frame_protector_test - build: test - language: c - headers: - - test/core/tsi/alts/crypt/gsec_test_util.h - - test/core/tsi/transport_security_test_lib.h - src: - - test/core/tsi/alts/crypt/gsec_test_util.cc - - test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc - - test/core/tsi/transport_security_test_lib.cc - deps: - - grpc_test_util -- name: alts_grpc_record_protocol_test - build: test - language: c - headers: - - test/core/tsi/alts/crypt/gsec_test_util.h - src: - - test/core/tsi/alts/crypt/gsec_test_util.cc - - test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc - deps: - - grpc_test_util -- name: alts_handshaker_client_test - build: test - language: c - headers: - - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h - src: - - test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc - - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc - deps: - - grpc_test_util -- name: alts_iovec_record_protocol_test - build: test - language: c - headers: - - test/core/tsi/alts/crypt/gsec_test_util.h - src: - - test/core/tsi/alts/crypt/gsec_test_util.cc - - test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc - deps: - - grpc_test_util - name: alts_security_connector_test build: test language: c @@ -3290,36 +3218,6 @@ targets: - test/core/security/alts_security_connector_test.cc deps: - grpc_test_util -- name: alts_tsi_handshaker_test - build: test - language: c - headers: - - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h - src: - - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc - - test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc - deps: - - grpc_test_util -- name: alts_tsi_utils_test - build: test - language: c - headers: - - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h - src: - - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc - - test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc - deps: - - grpc_test_util -- name: alts_zero_copy_grpc_protector_test - build: test - language: c - headers: - - test/core/tsi/alts/crypt/gsec_test_util.h - src: - - test/core/tsi/alts/crypt/gsec_test_util.cc - - test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc - deps: - - grpc_test_util - name: auth_context_test build: test language: c @@ -3532,16 +3430,6 @@ targets: deps: - grpc_test_util uses_polling: false -- name: fake_transport_security_test - build: test - language: c - headers: - - test/core/tsi/transport_security_test_lib.h - src: - - test/core/tsi/fake_transport_security_test.cc - - test/core/tsi/transport_security_test_lib.cc - deps: - - grpc_test_util - name: fd_conservation_posix_test build: test language: c @@ -3626,16 +3514,6 @@ targets: - test/core/http/format_request_test.cc deps: - grpc_test_util -- name: frame_handler_test - build: test - language: c - headers: - - test/core/tsi/alts/crypt/gsec_test_util.h - src: - - test/core/tsi/alts/crypt/gsec_test_util.cc - - test/core/tsi/alts/frame_protector/frame_handler_test.cc - deps: - - grpc_test_util - name: goaway_server_test build: test language: c @@ -3959,20 +3837,6 @@ targets: - test/core/security/ssl_credentials_test.cc deps: - grpc_test_util -- name: ssl_transport_security_test - build: test - language: c - headers: - - test/core/tsi/transport_security_test_lib.h - src: - - test/core/tsi/ssl_transport_security_test.cc - - test/core/tsi/transport_security_test_lib.cc - deps: - - grpc_test_util - platforms: - - linux - - posix - - mac - name: status_conversion_test build: test language: c @@ -4099,22 +3963,6 @@ targets: deps: - grpc_test_util uses_polling: false -- name: transport_security_common_api_test - build: test - language: c - headers: [] - src: - - test/core/tsi/alts/handshaker/transport_security_common_api_test.cc - deps: - - grpc_test_util -- name: transport_security_test - build: test - language: c - headers: [] - src: - - test/core/tsi/transport_security_test.cc - deps: - - grpc_test_util - name: varint_test build: test language: c @@ -4328,6 +4176,107 @@ targets: platforms: - linux - posix +- name: alts_counter_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/alts/crypt/gsec_test_util.h + src: + - test/core/tsi/alts/crypt/gsec_test_util.cc + - test/core/tsi/alts/frame_protector/alts_counter_test.cc + deps: + - grpc_test_util +- name: alts_crypt_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/alts/crypt/gsec_test_util.h + src: + - test/core/tsi/alts/crypt/aes_gcm_test.cc + - test/core/tsi/alts/crypt/gsec_test_util.cc + deps: + - grpc_test_util +- name: alts_crypter_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/alts/crypt/gsec_test_util.h + src: + - test/core/tsi/alts/crypt/gsec_test_util.cc + - test/core/tsi/alts/frame_protector/alts_crypter_test.cc + deps: + - grpc_test_util +- name: alts_frame_protector_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/alts/crypt/gsec_test_util.h + - test/core/tsi/transport_security_test_lib.h + src: + - test/core/tsi/alts/crypt/gsec_test_util.cc + - test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc + - test/core/tsi/transport_security_test_lib.cc + deps: + - grpc_test_util +- name: alts_grpc_record_protocol_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/alts/crypt/gsec_test_util.h + src: + - test/core/tsi/alts/crypt/gsec_test_util.cc + - test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc + deps: + - grpc_test_util +- name: alts_handshaker_client_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h + src: + - test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc + - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc + deps: + - grpc_test_util +- name: alts_iovec_record_protocol_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/alts/crypt/gsec_test_util.h + src: + - test/core/tsi/alts/crypt/gsec_test_util.cc + - test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc + deps: + - grpc_test_util +- name: alts_tsi_handshaker_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h + src: + - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc + - test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc + deps: + - grpc_test_util +- name: alts_tsi_utils_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h + src: + - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc + - test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc + deps: + - grpc_test_util - name: alts_util_test gtest: true build: test @@ -4338,6 +4287,17 @@ targets: deps: - grpc++_alts - grpc++_test_util +- name: alts_zero_copy_grpc_protector_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/alts/crypt/gsec_test_util.h + src: + - test/core/tsi/alts/crypt/gsec_test_util.cc + - test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc + deps: + - grpc_test_util - name: arena_promise_test gtest: true build: test @@ -5678,6 +5638,17 @@ targets: - test/core/client_channel/resolvers/fake_resolver_test.cc deps: - grpc_test_util +- name: fake_transport_security_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/transport_security_test_lib.h + src: + - test/core/tsi/fake_transport_security_test.cc + - test/core/tsi/transport_security_test_lib.cc + deps: + - grpc_test_util - name: file_watcher_certificate_provider_factory_test gtest: true build: test @@ -5888,6 +5859,17 @@ targets: - gpr - upb uses_polling: false +- name: frame_handler_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/alts/crypt/gsec_test_util.h + src: + - test/core/tsi/alts/crypt/gsec_test_util.cc + - test/core/tsi/alts/frame_protector/frame_handler_test.cc + deps: + - grpc_test_util - name: fuzzing_event_engine_test gtest: true build: test @@ -8131,6 +8113,21 @@ targets: - test/core/address_utils/sockaddr_utils_test.cc deps: - grpc_test_util +- name: ssl_transport_security_test + gtest: true + build: test + language: c++ + headers: + - test/core/tsi/transport_security_test_lib.h + src: + - test/core/tsi/ssl_transport_security_test.cc + - test/core/tsi/transport_security_test_lib.cc + deps: + - grpc_test_util + platforms: + - linux + - posix + - mac - name: stack_tracer_test gtest: true build: test @@ -8956,6 +8953,24 @@ targets: deps: - grpc++_test_config - grpc++_test_util +- name: transport_security_common_api_test + gtest: true + build: test + language: c++ + headers: [] + src: + - test/core/tsi/alts/handshaker/transport_security_common_api_test.cc + deps: + - grpc_test_util +- name: transport_security_test + gtest: true + build: test + language: c++ + headers: [] + src: + - test/core/tsi/transport_security_test.cc + deps: + - grpc_test_util - name: transport_stream_receiver_test gtest: true build: test diff --git a/test/core/tsi/BUILD b/test/core/tsi/BUILD index 37d742075f8..6beaebce6dc 100644 --- a/test/core/tsi/BUILD +++ b/test/core/tsi/BUILD @@ -33,6 +33,7 @@ grpc_cc_library( grpc_cc_test( name = "fake_transport_security_test", srcs = ["fake_transport_security_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ ":transport_security_test_lib", @@ -74,6 +75,7 @@ grpc_cc_test( "//src/core/tsi/test_creds:server1.key", "//src/core/tsi/test_creds:server1.pem", ], + external_deps = ["gtest"], language = "C++", tags = ["no_windows"], deps = [ @@ -112,6 +114,7 @@ grpc_cc_test( grpc_cc_test( name = "transport_security_test", srcs = ["transport_security_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ "//:gpr", diff --git a/test/core/tsi/alts/crypt/BUILD b/test/core/tsi/alts/crypt/BUILD index e2ae53bdffd..48ef03623b0 100644 --- a/test/core/tsi/alts/crypt/BUILD +++ b/test/core/tsi/alts/crypt/BUILD @@ -24,6 +24,7 @@ grpc_package( grpc_cc_test( name = "alts_crypt_test", srcs = ["aes_gcm_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ ":alts_crypt_test_util", diff --git a/test/core/tsi/alts/crypt/aes_gcm_test.cc b/test/core/tsi/alts/crypt/aes_gcm_test.cc index 61abc477e25..5fc951f65ca 100644 --- a/test/core/tsi/alts/crypt/aes_gcm_test.cc +++ b/test/core/tsi/alts/crypt/aes_gcm_test.cc @@ -16,6 +16,8 @@ * */ +#include + #include #include @@ -74,13 +76,13 @@ static void gsec_assert_ok(grpc_status_code status, const char* error_detail) { if (status != GRPC_STATUS_OK) { fprintf(stderr, "Status is not ok: %s\n", error_detail); } - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); } static void gsec_test_random_encrypt_decrypt(gsec_aead_crypter* crypter, size_t aad_length, size_t message_length) { - GPR_ASSERT(crypter != nullptr); + ASSERT_NE(crypter, nullptr); size_t nonce_length, tag_length; uint8_t *nonce, *aad, *message; gsec_aead_crypter_nonce_length(crypter, &nonce_length, nullptr); @@ -105,8 +107,8 @@ static void gsec_test_random_encrypt_decrypt(gsec_aead_crypter* crypter, ciphertext_and_tag_length, &ciphertext_bytes_written, &error_buffer), error_buffer); - GPR_ASSERT(message_length + tag_length == ciphertext_and_tag_length); - GPR_ASSERT(ciphertext_bytes_written == ciphertext_and_tag_length); + ASSERT_EQ(message_length + tag_length, ciphertext_and_tag_length); + ASSERT_EQ(ciphertext_bytes_written, ciphertext_and_tag_length); /* Test decryption */ size_t plaintext_length, plaintext_bytes_written = 0; @@ -118,10 +120,10 @@ static void gsec_test_random_encrypt_decrypt(gsec_aead_crypter* crypter, ciphertext_bytes_written, plaintext, plaintext_length, &plaintext_bytes_written, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(message_length == plaintext_bytes_written); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(message_length, plaintext_bytes_written); if (message_length != 0) { - GPR_ASSERT(memcmp(message, plaintext, message_length) == 0); + ASSERT_EQ(memcmp(message, plaintext, message_length), 0); } /** @@ -140,12 +142,12 @@ static void gsec_test_random_encrypt_decrypt(gsec_aead_crypter* crypter, ciphertext_and_tag, ciphertext_bytes_written, plaintext, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, "Checking tag failed.", error_message)); - GPR_ASSERT(plaintext_bytes_written == 0); + ASSERT_EQ(plaintext_bytes_written, 0); if (plaintext_length != 0) { - GPR_ASSERT(memcmp(zero_message, plaintext, plaintext_length) == 0); + ASSERT_EQ(memcmp(zero_message, plaintext, plaintext_length), 0); } gpr_free(corrupt_nonce); gpr_free(error_message); @@ -162,12 +164,12 @@ static void gsec_test_random_encrypt_decrypt(gsec_aead_crypter* crypter, corrupt_ciphertext_and_tag, ciphertext_bytes_written, plaintext, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Checking tag failed")); - GPR_ASSERT(plaintext_bytes_written == 0); + ASSERT_EQ(plaintext_bytes_written, 0); if (plaintext_length != 0) { - GPR_ASSERT(memcmp(zero_message, plaintext, plaintext_length) == 0); + ASSERT_EQ(memcmp(zero_message, plaintext, plaintext_length), 0); } gpr_free(error_message); gpr_free(corrupt_ciphertext_and_tag); @@ -181,11 +183,11 @@ static void gsec_test_random_encrypt_decrypt(gsec_aead_crypter* crypter, crypter, nonce, nonce_length, aad, aad_length, corrupt_ciphertext_and_tag, ciphertext_bytes_written, plaintext, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(plaintext_bytes_written == 0); + ASSERT_EQ(plaintext_bytes_written, 0); if (plaintext_length != 0) { - GPR_ASSERT(memcmp(zero_message, plaintext, plaintext_length) == 0); + ASSERT_EQ(memcmp(zero_message, plaintext, plaintext_length), 0); } - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Checking tag failed")); gpr_free(error_message); @@ -202,12 +204,12 @@ static void gsec_test_random_encrypt_decrypt(gsec_aead_crypter* crypter, corrupt_ciphertext_and_tag, ciphertext_bytes_written, plaintext, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Checking tag failed")); - GPR_ASSERT(plaintext_bytes_written == 0); + ASSERT_EQ(plaintext_bytes_written, 0); if (plaintext_length != 0) { - GPR_ASSERT(memcmp(zero_message, plaintext, plaintext_length) == 0); + ASSERT_EQ(memcmp(zero_message, plaintext, plaintext_length), 0); } gpr_free(error_message); gpr_free(corrupt_ciphertext_and_tag); @@ -222,7 +224,7 @@ static void gsec_test_random_encrypt_decrypt(gsec_aead_crypter* crypter, } static void gsec_test_encrypt_decrypt(gsec_aead_crypter* crypter) { - GPR_ASSERT(crypter != nullptr); + ASSERT_NE(crypter, nullptr); size_t aad_length, message_length; aad_length = gsec_test_bias_random_uint32(kTestMaxLength); message_length = gsec_test_bias_random_uint32(kTestMaxLength); @@ -234,7 +236,7 @@ static void gsec_test_encrypt_decrypt(gsec_aead_crypter* crypter) { static void gsec_test_multiple_random_encrypt_decrypt( gsec_aead_crypter* crypter, size_t* aad_lengths, size_t* message_lengths, size_t count) { - GPR_ASSERT(crypter != nullptr); + ASSERT_NE(crypter, nullptr); size_t nonce_length, tag_length; uint8_t **nonces, **aads, **messages; nonces = static_cast(gpr_malloc(sizeof(uint8_t*) * count)); @@ -281,10 +283,9 @@ static void gsec_test_multiple_random_encrypt_decrypt( messages[ind], message_length, ciphertext_and_tags[ind], ciphertext_and_tag_lengths[ind], &(ciphertext_bytes_writtens[ind]), nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(message_length + tag_length == ciphertext_and_tag_lengths[ind]); - GPR_ASSERT(ciphertext_bytes_writtens[ind] == - ciphertext_and_tag_lengths[ind]); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(message_length + tag_length, ciphertext_and_tag_lengths[ind]); + ASSERT_EQ(ciphertext_bytes_writtens[ind], ciphertext_and_tag_lengths[ind]); } /* Do Decryption */ for (ind = 0; ind < count; ind++) { @@ -300,10 +301,10 @@ static void gsec_test_multiple_random_encrypt_decrypt( ciphertext_and_tags[ind], ciphertext_bytes_writtens[ind], plaintexts[ind], plaintext_lengths[ind], &(plaintext_bytes_writtens[ind]), nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(message_length == plaintext_bytes_writtens[ind]); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(message_length, plaintext_bytes_writtens[ind]); if (message_length != 0) { - GPR_ASSERT(memcmp(messages[ind], plaintexts[ind], message_length) == 0); + ASSERT_EQ(memcmp(messages[ind], plaintexts[ind], message_length), 0); } } @@ -334,8 +335,9 @@ static void gsec_test_multiple_random_encrypt_decrypt( message_vecs, message_vecs_length, another_ciphertext_vec, &ciphertext_bytes_written, &error_details), error_details); - GPR_ASSERT(memcmp(ciphertext_and_tags[ind], another_ciphertext_vec.iov_base, - ciphertext_length) == 0); + ASSERT_EQ(memcmp(ciphertext_and_tags[ind], another_ciphertext_vec.iov_base, + ciphertext_length), + 0); free(another_ciphertext); free(aad_vecs); free(message_vecs); @@ -369,10 +371,10 @@ static void gsec_test_multiple_random_encrypt_decrypt( aad_vecs_length, ciphertext_vecs, ciphertext_vecs_length, decrypted_vec, &decrypted_length, &error_details), error_details); - GPR_ASSERT(decrypted_vec.iov_len == message_length); + ASSERT_EQ(decrypted_vec.iov_len, message_length); if (message_length != 0) { - GPR_ASSERT( - memcmp(decrypted_vec.iov_base, messages[ind], message_length) == 0); + ASSERT_EQ(memcmp(decrypted_vec.iov_base, messages[ind], message_length), + 0); } free(decrypted); free(aad_vecs); @@ -398,7 +400,7 @@ static void gsec_test_multiple_random_encrypt_decrypt( } static void gsec_test_multiple_encrypt_decrypt(gsec_aead_crypter* crypter) { - GPR_ASSERT(crypter != nullptr); + ASSERT_NE(crypter, nullptr); size_t count = kTestNumEncryptions; size_t* aad_lengths = static_cast(gpr_malloc(sizeof(size_t) * count)); @@ -420,7 +422,7 @@ static void gsec_test_multiple_encrypt_decrypt(gsec_aead_crypter* crypter) { } static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) { - GPR_ASSERT(crypter != nullptr); + ASSERT_NE(crypter, nullptr); size_t aad_length = kTestMaxLength; size_t message_length = kTestMaxLength; size_t nonce_length; @@ -444,7 +446,7 @@ static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) { crypter, nullptr, nonce_length, aad, aad_length, message, message_length, ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Nonce buffer is nullptr.")); gpr_free(error_message); @@ -454,7 +456,7 @@ static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) { crypter, nonce, nonce_length + 1, aad, aad_length, message, message_length, ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Nonce buffer has the wrong length.")); gpr_free(error_message); @@ -464,7 +466,7 @@ static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) { crypter, nonce, nonce_length - 1, aad, aad_length, message, message_length, ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Nonce buffer has the wrong length.")); gpr_free(error_message); @@ -474,7 +476,7 @@ static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) { crypter, nonce, nonce_length, nullptr, aad_length, message, message_length, ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "aad is nullptr.")); gpr_free(error_message); @@ -491,7 +493,7 @@ static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) { crypter, nonce, nonce_length, aad, aad_length, nullptr, message_length, ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "plaintext is nullptr.")); gpr_free(error_message); @@ -501,7 +503,7 @@ static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) { aad_length, message, message_length, nullptr, ciphertext_and_tag_length, &ciphertext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "ciphertext is nullptr.")); gpr_free(error_message); @@ -511,7 +513,7 @@ static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) { crypter, nonce, nonce_length, aad, aad_length, message, message_length, ciphertext_and_tag, ciphertext_and_tag_length - 1, &ciphertext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "ciphertext is too small to hold a tag.")); gpr_free(error_message); @@ -520,7 +522,7 @@ static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) { status = gsec_aead_crypter_encrypt( crypter, nonce, nonce_length, aad, aad_length, message, message_length, ciphertext_and_tag, ciphertext_and_tag_length, nullptr, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "bytes_written is nullptr.")); gpr_free(error_message); @@ -537,7 +539,7 @@ static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) { crypter, nonce, nonce_length, aad, aad_length, message, message_length, ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written, &error_message); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); gpr_free(message); gpr_free(aad); @@ -546,7 +548,7 @@ static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) { } static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { - GPR_ASSERT(crypter != nullptr); + ASSERT_NE(crypter, nullptr); size_t aad_length = kTestMaxLength; size_t message_length = kTestMaxLength; size_t nonce_length, tag_length; @@ -569,8 +571,8 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { crypter, nonce, nonce_length, aad, aad_length, message, message_length, ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(ciphertext_bytes_written == ciphertext_and_tag_length); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(ciphertext_bytes_written, ciphertext_and_tag_length); size_t plaintext_length, plaintext_bytes_written = 0; gsec_aead_crypter_max_plaintext_length(crypter, ciphertext_bytes_written, @@ -583,7 +585,7 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { crypter, nullptr, nonce_length, aad, aad_length, ciphertext_and_tag, ciphertext_and_tag_length, plaintext, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Nonce buffer is nullptr.")); gpr_free(error_message); @@ -593,7 +595,7 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { crypter, nonce, nonce_length + 1, aad, aad_length, ciphertext_and_tag, ciphertext_and_tag_length, plaintext, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Nonce buffer has the wrong length.")); gpr_free(error_message); @@ -603,7 +605,7 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { crypter, nonce, nonce_length - 1, aad, aad_length, ciphertext_and_tag, ciphertext_and_tag_length, plaintext, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Nonce buffer has the wrong length.")); gpr_free(error_message); @@ -613,7 +615,7 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { crypter, nonce, nonce_length, nullptr, aad_length, ciphertext_and_tag, ciphertext_and_tag_length, plaintext, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "aad is nullptr.")); gpr_free(error_message); @@ -622,13 +624,13 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { crypter, nonce, nonce_length, nullptr, 0, message, message_length, ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written, &error_message); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); status = gsec_aead_crypter_decrypt( crypter, nonce, nonce_length, nullptr, 0, ciphertext_and_tag, ciphertext_and_tag_length, plaintext, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); /* Small ciphertext */ if (tag_length > 0) { @@ -637,7 +639,7 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { tag_length - 1, plaintext, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "ciphertext is too small to hold a tag.")); gpr_free(error_message); @@ -649,7 +651,7 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { ciphertext_and_tag_length, plaintext, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "ciphertext is nullptr.")); gpr_free(error_message); @@ -660,7 +662,7 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { ciphertext_and_tag_length, nullptr, plaintext_length, &plaintext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "plaintext is nullptr, but plaintext_length is positive.")); gpr_free(error_message); @@ -671,7 +673,7 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { ciphertext_and_tag_length, plaintext, plaintext_length - 1, &plaintext_bytes_written, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Not enough plaintext buffer to hold encrypted ciphertext.")); gpr_free(error_message); @@ -682,7 +684,7 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { ciphertext_and_tag_length, plaintext, plaintext_length, nullptr, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "bytes_written is nullptr.")); gpr_free(error_message); @@ -696,7 +698,7 @@ static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) { static void gsec_test_encrypt_decrypt_test_vector( gsec_aead_crypter* crypter, gsec_aead_test_vector* test_vector) { - GPR_ASSERT(crypter != nullptr); + ASSERT_NE(crypter, nullptr); /* Test byte-based encryption interface. */ size_t ciphertext_and_tag_length, ciphertext_bytes_written = 0; gsec_aead_crypter_max_ciphertext_and_tag_length( @@ -710,10 +712,11 @@ static void gsec_test_encrypt_decrypt_test_vector( test_vector->plaintext_length, ciphertext_and_tag_bytes, ciphertext_and_tag_length, &ciphertext_bytes_written, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(ciphertext_bytes_written == ciphertext_and_tag_length); - GPR_ASSERT(memcmp(test_vector->ciphertext_and_tag, ciphertext_and_tag_bytes, - ciphertext_and_tag_length) == 0); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(ciphertext_bytes_written, ciphertext_and_tag_length); + ASSERT_EQ(memcmp(test_vector->ciphertext_and_tag, ciphertext_and_tag_bytes, + ciphertext_and_tag_length), + 0); /* Test byte-based decryption interface */ size_t plaintext_length, plaintext_bytes_written = 0; @@ -726,10 +729,11 @@ static void gsec_test_encrypt_decrypt_test_vector( test_vector->aad_length, test_vector->ciphertext_and_tag, test_vector->ciphertext_and_tag_length, plaintext_bytes, plaintext_length, &plaintext_bytes_written, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); if (plaintext_bytes_written != 0) { - GPR_ASSERT(memcmp(test_vector->plaintext, plaintext_bytes, - plaintext_bytes_written) == 0); + ASSERT_EQ(memcmp(test_vector->plaintext, plaintext_bytes, + plaintext_bytes_written), + 0); } gpr_free(ciphertext_and_tag_bytes); @@ -740,14 +744,14 @@ static void gsec_test_get_crypter_from_test_vector( gsec_aead_crypter** crypter, gsec_aead_test_vector* test_vector, bool rekey = false) { size_t key_length = test_vector->key_length; - GPR_ASSERT(key_length == kAes128GcmKeyLength || - key_length == kAes256GcmKeyLength || - key_length == kAes128GcmRekeyKeyLength); + ASSERT_TRUE(key_length == kAes128GcmKeyLength || + key_length == kAes256GcmKeyLength || + key_length == kAes128GcmRekeyKeyLength); size_t nonce_length = test_vector->nonce_length; - GPR_ASSERT(nonce_length == kAesGcmNonceLength); + ASSERT_EQ(nonce_length, kAesGcmNonceLength); size_t plaintext_length = test_vector->plaintext_length; size_t ciphertext_and_tag_length = test_vector->ciphertext_and_tag_length; - GPR_ASSERT(ciphertext_and_tag_length == plaintext_length + kAesGcmTagLength); + ASSERT_EQ(ciphertext_and_tag_length, plaintext_length + kAesGcmTagLength); size_t tag_length = ciphertext_and_tag_length - plaintext_length; gsec_aes_gcm_aead_crypter_create(test_vector->key, key_length, nonce_length, tag_length, rekey, crypter, nullptr); @@ -817,7 +821,7 @@ static void gsec_test_get_random_aes_gcm_crypters( kAesGcmTagLength, /*rekey=*/true); } -static void gsec_test_do_generic_crypter_tests() { +TEST(AltsCryptTest, GsecTestDoGenericCrypterTests) { gsec_aead_crypter** crypters; gsec_test_get_random_aes_gcm_crypters(&crypters); size_t ind; @@ -833,7 +837,7 @@ static void gsec_test_do_generic_crypter_tests() { gpr_free(crypters); } -static void gsec_test_do_vector_tests_rekey_nist() { +TEST(AltsCryptTest, GsecTestDoVectorTestsRekeyNist) { // NIST vectors from: // http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf // @@ -1048,7 +1052,7 @@ static void gsec_test_do_vector_tests_rekey_nist() { gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true); } -static void gsec_test_do_vector_tests_rekey_ieee() { +TEST(AltsCryptTest, GsecTestDoVectorTestsRekeyIeee) { // IEEE vectors from: // http://www.ieee802.org/1/files/public/docs2011/bn-randall-test-vectors-0511-v1.pdf // @@ -1464,7 +1468,7 @@ static void gsec_test_do_vector_tests_rekey_ieee() { gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true); } -static void gsec_test_do_vector_tests_nist() { +TEST(AltsCryptTest, GsecTestDoVectorTestsNist) { /** * From: * http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/ @@ -1588,7 +1592,7 @@ static void gsec_test_do_vector_tests_nist() { gsec_aead_free_test_vector(test_vector_4); } -static void gsec_test_do_vector_tests_ieee() { +TEST(AltsCryptTest, GsecTestDoVectorTestsIeee) { /** * From: * http://www.ieee802.org/1/files/public/docs2011/ @@ -2112,12 +2116,7 @@ static void gsec_test_do_vector_tests_ieee() { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); - grpc_init(); - gsec_test_do_generic_crypter_tests(); - gsec_test_do_vector_tests_nist(); - gsec_test_do_vector_tests_ieee(); - gsec_test_do_vector_tests_rekey_nist(); - gsec_test_do_vector_tests_rekey_ieee(); - grpc_shutdown(); - return 0; + ::testing::InitGoogleTest(&argc, argv); + grpc::testing::TestGrpcScope grpc_scope; + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/alts/frame_protector/BUILD b/test/core/tsi/alts/frame_protector/BUILD index aa6322dc87a..fd639819e8e 100644 --- a/test/core/tsi/alts/frame_protector/BUILD +++ b/test/core/tsi/alts/frame_protector/BUILD @@ -21,6 +21,7 @@ grpc_package(name = "test/core/tsi/alts/frame_protector") grpc_cc_test( name = "alts_counter_test", srcs = ["alts_counter_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ "//:gpr", @@ -33,6 +34,7 @@ grpc_cc_test( grpc_cc_test( name = "alts_crypter_test", srcs = ["alts_crypter_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ "//:gpr", @@ -45,6 +47,7 @@ grpc_cc_test( grpc_cc_test( name = "alts_frame_protector_test", srcs = ["alts_frame_protector_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ "//:gpr", @@ -58,6 +61,7 @@ grpc_cc_test( grpc_cc_test( name = "frame_handler_test", srcs = ["frame_handler_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ "//:gpr", diff --git a/test/core/tsi/alts/frame_protector/alts_counter_test.cc b/test/core/tsi/alts/frame_protector/alts_counter_test.cc index 80fd95fb195..968b6f92f6e 100644 --- a/test/core/tsi/alts/frame_protector/alts_counter_test.cc +++ b/test/core/tsi/alts/frame_protector/alts_counter_test.cc @@ -18,6 +18,8 @@ #include "src/core/tsi/alts/frame_protector/alts_counter.h" +#include + #include #include @@ -42,14 +44,14 @@ static void alts_counter_test_input_sanity_check(size_t counter_size, /* Invalid counter size. */ grpc_status_code status = alts_counter_create(true, 0, overflow_size, &ctr, &error_details); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_details, "counter_size is invalid.")); gpr_free(error_details); /* Invalid overflow size. */ status = alts_counter_create(true, counter_size, 0, &ctr, &error_details); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_details, "overflow_size is invalid.")); gpr_free(error_details); @@ -57,26 +59,26 @@ static void alts_counter_test_input_sanity_check(size_t counter_size, /* alts_counter is nullptr. */ status = alts_counter_create(true, counter_size, overflow_size, nullptr, &error_details); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_details, "crypter_counter is nullptr.")); gpr_free(error_details); status = alts_counter_create(true, counter_size, overflow_size, &ctr, &error_details); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); /* Input sanity check on alts_counter_increment(). */ /* crypter_counter is nullptr. */ bool is_overflow = false; status = alts_counter_increment(nullptr, &is_overflow, &error_details); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_details, "crypter_counter is nullptr.")); gpr_free(error_details); /* is_overflow is nullptr. */ status = alts_counter_increment(ctr, nullptr, &error_details); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_details, "is_overflow is nullptr.")); gpr_free(error_details); @@ -90,21 +92,21 @@ static void alts_counter_test_overflow_full_range(bool is_client, char* error_details = nullptr; grpc_status_code status = alts_counter_create( is_client, counter_size, overflow_size, &ctr, &error_details); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); unsigned char* expected = static_cast(gpr_zalloc(counter_size)); if (is_client) { expected[counter_size - 1] = 0x80; } /* Do a single iteration to ensure the counter is initialized as expected. */ - GPR_ASSERT(do_bytes_represent_client(ctr, alts_counter_get_counter(ctr), - counter_size) == is_client); - GPR_ASSERT(memcmp(alts_counter_get_counter(ctr), expected, counter_size) == - 0); + ASSERT_EQ(do_bytes_represent_client(ctr, alts_counter_get_counter(ctr), + counter_size), + is_client); + ASSERT_EQ(memcmp(alts_counter_get_counter(ctr), expected, counter_size), 0); bool is_overflow = false; - GPR_ASSERT(alts_counter_increment(ctr, &is_overflow, &error_details) == - GRPC_STATUS_OK); - GPR_ASSERT(!is_overflow); + ASSERT_EQ(alts_counter_increment(ctr, &is_overflow, &error_details), + GRPC_STATUS_OK); + ASSERT_FALSE(is_overflow); /** * The counter can return 2^{overflow_size * 8} counters. The * high-order bit is fixed to the client/server. The last call will yield a @@ -113,17 +115,19 @@ static void alts_counter_test_overflow_full_range(bool is_client, int iterations = 1 << (overflow_size * 8); int ind = 1; for (ind = 1; ind < iterations - 1; ind++) { - GPR_ASSERT(do_bytes_represent_client(ctr, alts_counter_get_counter(ctr), - counter_size) == is_client); - GPR_ASSERT(alts_counter_increment(ctr, &is_overflow, &error_details) == - GRPC_STATUS_OK); - GPR_ASSERT(!is_overflow); + ASSERT_EQ(do_bytes_represent_client(ctr, alts_counter_get_counter(ctr), + counter_size), + is_client); + ASSERT_EQ(alts_counter_increment(ctr, &is_overflow, &error_details), + GRPC_STATUS_OK); + ASSERT_FALSE(is_overflow); } - GPR_ASSERT(do_bytes_represent_client(ctr, alts_counter_get_counter(ctr), - counter_size) == is_client); - GPR_ASSERT(alts_counter_increment(ctr, &is_overflow, &error_details) == - GRPC_STATUS_FAILED_PRECONDITION); - GPR_ASSERT(is_overflow); + ASSERT_EQ(do_bytes_represent_client(ctr, alts_counter_get_counter(ctr), + counter_size), + is_client); + ASSERT_EQ(alts_counter_increment(ctr, &is_overflow, &error_details), + GRPC_STATUS_FAILED_PRECONDITION); + ASSERT_TRUE(is_overflow); gpr_free(expected); alts_counter_destroy(ctr); } @@ -136,7 +140,7 @@ static void alts_counter_test_overflow_single_increment(bool is_client, char* error_details = nullptr; grpc_status_code status = alts_counter_create( is_client, counter_size, overflow_size, &ctr, &error_details); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); unsigned char* expected = static_cast(gpr_zalloc(counter_size)); memset(expected, 0xFF, overflow_size); @@ -146,27 +150,27 @@ static void alts_counter_test_overflow_single_increment(bool is_client, expected[counter_size - 1] = 0x80; } memcpy(ctr->counter, expected, counter_size); - GPR_ASSERT(do_bytes_represent_client(ctr, alts_counter_get_counter(ctr), - counter_size) == is_client); - GPR_ASSERT(memcmp(expected, alts_counter_get_counter(ctr), counter_size) == - 0); + ASSERT_EQ(do_bytes_represent_client(ctr, alts_counter_get_counter(ctr), + counter_size), + is_client); + ASSERT_EQ(memcmp(expected, alts_counter_get_counter(ctr), counter_size), 0); bool is_overflow = false; - GPR_ASSERT(alts_counter_increment(ctr, &is_overflow, &error_details) == - GRPC_STATUS_OK); - GPR_ASSERT(!is_overflow); - GPR_ASSERT(do_bytes_represent_client(ctr, alts_counter_get_counter(ctr), - counter_size) == is_client); + ASSERT_EQ(alts_counter_increment(ctr, &is_overflow, &error_details), + GRPC_STATUS_OK); + ASSERT_FALSE(is_overflow); + ASSERT_EQ(do_bytes_represent_client(ctr, alts_counter_get_counter(ctr), + counter_size), + is_client); expected[0] = static_cast(expected[0] + 1); - GPR_ASSERT(memcmp(expected, alts_counter_get_counter(ctr), counter_size) == - 0); - GPR_ASSERT(alts_counter_increment(ctr, &is_overflow, &error_details) == - GRPC_STATUS_FAILED_PRECONDITION); - GPR_ASSERT(is_overflow); + ASSERT_EQ(memcmp(expected, alts_counter_get_counter(ctr), counter_size), 0); + ASSERT_EQ(alts_counter_increment(ctr, &is_overflow, &error_details), + GRPC_STATUS_FAILED_PRECONDITION); + ASSERT_TRUE(is_overflow); gpr_free(expected); alts_counter_destroy(ctr); } -int main(int /*argc*/, char** /*argv*/) { +TEST(AltsCounterTest, MainTest) { alts_counter_test_input_sanity_check(kGcmCounterSize, kGcmOverflowSize); alts_counter_test_overflow_full_range(true, kSmallCounterSize, kSmallOverflowSize); @@ -176,6 +180,9 @@ int main(int /*argc*/, char** /*argv*/) { kGcmOverflowSize); alts_counter_test_overflow_single_increment(false, kGcmCounterSize, kGcmOverflowSize); +} - return 0; +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/alts/frame_protector/alts_crypter_test.cc b/test/core/tsi/alts/frame_protector/alts_crypter_test.cc index 05285442e71..2bbc4f394d9 100644 --- a/test/core/tsi/alts/frame_protector/alts_crypter_test.cc +++ b/test/core/tsi/alts/frame_protector/alts_crypter_test.cc @@ -22,6 +22,8 @@ #include #include +#include + #include #include @@ -43,23 +45,23 @@ static void alts_crypter_test_random_seal_unseal(alts_crypter* server_seal, size_t size = data_size; grpc_status_code status = alts_crypter_process_in_place( client_seal, data_buffer, protected_data_size, size, &size, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size, protected_data_size); status = alts_crypter_process_in_place( server_unseal, data_buffer, protected_data_size, size, &size, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(memcmp(data_buffer, duplicate_buffer, data_size) == 0); - GPR_ASSERT(size == data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(memcmp(data_buffer, duplicate_buffer, data_size), 0); + ASSERT_EQ(size, data_size); /* Server seal and client unseal */ status = alts_crypter_process_in_place( server_seal, data_buffer, protected_data_size, size, &size, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size, protected_data_size); status = alts_crypter_process_in_place( client_unseal, data_buffer, protected_data_size, size, &size, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(memcmp(data_buffer, duplicate_buffer, data_size) == 0); - GPR_ASSERT(size == data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(memcmp(data_buffer, duplicate_buffer, data_size), 0); + ASSERT_EQ(size, data_size); gpr_free(data_buffer); gpr_free(duplicate_buffer); } @@ -86,42 +88,42 @@ static void alts_crypter_test_multiple_random_seal_unseal( size_t size1 = data_size, size2 = data_size; grpc_status_code status = alts_crypter_process_in_place( client_seal, data_buffer1, protected_data_size, size1, &size1, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size1 == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size1, protected_data_size); status = alts_crypter_process_in_place( client_seal, data_buffer2, protected_data_size, size2, &size2, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size2 == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size2, protected_data_size); status = alts_crypter_process_in_place( server_unseal, data_buffer1, protected_data_size, size1, &size1, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(memcmp(data_buffer1, duplicate_buffer1, data_size) == 0); - GPR_ASSERT(size1 == data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(memcmp(data_buffer1, duplicate_buffer1, data_size), 0); + ASSERT_EQ(size1, data_size); status = alts_crypter_process_in_place( server_unseal, data_buffer2, protected_data_size, size2, &size2, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(memcmp(data_buffer2, duplicate_buffer2, data_size) == 0); - GPR_ASSERT(size2 == data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(memcmp(data_buffer2, duplicate_buffer2, data_size), 0); + ASSERT_EQ(size2, data_size); /* Server seal and client unseal */ status = alts_crypter_process_in_place( server_seal, data_buffer1, protected_data_size, size1, &size1, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size1 == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size1, protected_data_size); status = alts_crypter_process_in_place( server_seal, data_buffer2, protected_data_size, size2, &size2, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size2 == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size2, protected_data_size); status = alts_crypter_process_in_place( client_unseal, data_buffer1, protected_data_size, size1, &size1, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(memcmp(data_buffer1, duplicate_buffer1, data_size) == 0); - GPR_ASSERT(size1 == data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(memcmp(data_buffer1, duplicate_buffer1, data_size), 0); + ASSERT_EQ(size1, data_size); status = alts_crypter_process_in_place( client_unseal, data_buffer2, protected_data_size, size2, &size2, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(memcmp(data_buffer2, duplicate_buffer2, data_size) == 0); - GPR_ASSERT(size2 == data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(memcmp(data_buffer2, duplicate_buffer2, data_size), 0); + ASSERT_EQ(size2, data_size); gpr_free(data_buffer1); gpr_free(data_buffer2); @@ -143,8 +145,8 @@ static void alts_crypter_test_corrupted_unseal( gsec_test_random_bytes(data_buffer, data_size); grpc_status_code status = alts_crypter_process_in_place( client_seal, data_buffer, protected_data_size, size, &size, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size, protected_data_size); uint8_t* corrupted_data_buffer; char* error_message = nullptr; gsec_test_copy_and_alter_random_byte(data_buffer, &corrupted_data_buffer, @@ -152,10 +154,10 @@ static void alts_crypter_test_corrupted_unseal( status = alts_crypter_process_in_place(server_unseal, corrupted_data_buffer, protected_data_size, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Checking tag failed")); - GPR_ASSERT(memcmp(corrupted_data_buffer, zero_buffer, data_size) == 0); + ASSERT_EQ(memcmp(corrupted_data_buffer, zero_buffer, data_size), 0); gpr_free(corrupted_data_buffer); gpr_free(error_message); @@ -164,17 +166,17 @@ static void alts_crypter_test_corrupted_unseal( gsec_test_random_bytes(data_buffer, data_size); status = alts_crypter_process_in_place( client_seal, data_buffer, protected_data_size, size, &size, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size, protected_data_size); gsec_test_copy(data_buffer, &corrupted_data_buffer, protected_data_size); (*corrupted_data_buffer)++; status = alts_crypter_process_in_place(server_unseal, corrupted_data_buffer, protected_data_size, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Checking tag failed")); - GPR_ASSERT(memcmp(corrupted_data_buffer, zero_buffer, data_size) == 0); + ASSERT_EQ(memcmp(corrupted_data_buffer, zero_buffer, data_size), 0); gpr_free(corrupted_data_buffer); gpr_free(error_message); @@ -183,17 +185,17 @@ static void alts_crypter_test_corrupted_unseal( gsec_test_random_bytes(data_buffer, data_size); status = alts_crypter_process_in_place( client_seal, data_buffer, protected_data_size, size, &size, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size, protected_data_size); gsec_test_copy(data_buffer, &corrupted_data_buffer, protected_data_size); (*(corrupted_data_buffer + protected_data_size - 1))++; status = alts_crypter_process_in_place(server_unseal, corrupted_data_buffer, protected_data_size, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Checking tag failed")); - GPR_ASSERT(memcmp(corrupted_data_buffer, zero_buffer, data_size) == 0); + ASSERT_EQ(memcmp(corrupted_data_buffer, zero_buffer, data_size), 0); gpr_free(corrupted_data_buffer); gpr_free(error_message); @@ -216,24 +218,24 @@ static void alts_crypter_test_unsync_seal_unseal(alts_crypter* server_seal, gsec_test_random_bytes(data_buffer, data_size); grpc_status_code status = alts_crypter_process_in_place( client_seal, data_buffer, protected_data_size, size, &size, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size, protected_data_size); size = data_size; gsec_test_random_bytes(data_buffer, data_size); status = alts_crypter_process_in_place( client_seal, data_buffer, protected_data_size, size, &size, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size, protected_data_size); char* error_message = nullptr; status = alts_crypter_process_in_place(server_unseal, data_buffer, protected_data_size, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Checking tag failed")); - GPR_ASSERT(memcmp(data_buffer, zero_buffer, data_size) == 0); + ASSERT_EQ(memcmp(data_buffer, zero_buffer, data_size), 0); gpr_free(error_message); /* Perform two seals at server, one unseal at client. */ @@ -241,23 +243,23 @@ static void alts_crypter_test_unsync_seal_unseal(alts_crypter* server_seal, gsec_test_random_bytes(data_buffer, data_size); status = alts_crypter_process_in_place( server_seal, data_buffer, protected_data_size, size, &size, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size, protected_data_size); size = data_size; gsec_test_random_bytes(data_buffer, data_size); status = alts_crypter_process_in_place( server_seal, data_buffer, protected_data_size, size, &size, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(size == protected_data_size); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(size, protected_data_size); status = alts_crypter_process_in_place(client_unseal, data_buffer, protected_data_size, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Checking tag failed")); - GPR_ASSERT(memcmp(data_buffer, zero_buffer, data_size) == 0); + ASSERT_EQ(memcmp(data_buffer, zero_buffer, data_size), 0); gpr_free(error_message); gpr_free(data_buffer); gpr_free(zero_buffer); @@ -276,7 +278,7 @@ static void alts_crypter_test_input_sanity_check(alts_crypter* crypter_seal, /* Crypter is nullptr. */ grpc_status_code status = alts_crypter_process_in_place( nullptr, data_buffer, protected_data_size, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "crypter or crypter->vtable has not been initialized properly.")); gpr_free(error_message); @@ -285,7 +287,7 @@ static void alts_crypter_test_input_sanity_check(alts_crypter* crypter_seal, size = data_size; status = alts_crypter_process_in_place( crypter_seal, nullptr, protected_data_size, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "data is nullptr.")); gpr_free(error_message); @@ -294,7 +296,7 @@ static void alts_crypter_test_input_sanity_check(alts_crypter* crypter_seal, status = alts_crypter_process_in_place(crypter_seal, data_buffer, protected_data_size, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "data_size is zero.")); gpr_free(error_message); @@ -304,7 +306,7 @@ static void alts_crypter_test_input_sanity_check(alts_crypter* crypter_seal, status = alts_crypter_process_in_place(crypter_seal, data_buffer, protected_data_size - 1, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "data_allocated_size is smaller than sum of data_size and " "num_overhead_bytes.")); @@ -315,7 +317,7 @@ static void alts_crypter_test_input_sanity_check(alts_crypter* crypter_seal, status = alts_crypter_process_in_place(crypter_unseal, nullptr, protected_data_size, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "data is nullptr.")); gpr_free(error_message); @@ -324,7 +326,7 @@ static void alts_crypter_test_input_sanity_check(alts_crypter* crypter_seal, status = alts_crypter_process_in_place(crypter_unseal, data_buffer, protected_data_size, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "data_size is smaller than num_overhead_bytes.")); gpr_free(error_message); @@ -334,7 +336,7 @@ static void alts_crypter_test_input_sanity_check(alts_crypter* crypter_seal, status = alts_crypter_process_in_place(crypter_unseal, data_buffer, protected_data_size, size, &size, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "data_size is smaller than num_overhead_bytes.")); gpr_free(error_message); @@ -386,7 +388,7 @@ static void destroy_random_alts_seal_crypter(alts_crypter* server_seal, alts_crypter_destroy(client_unseal); } -static void alts_crypter_do_generic_tests() { +TEST(AltsCrypterTest, AltsCrypterDoGenericTests) { alts_crypter *server_seal = nullptr, *server_unseal = nullptr, *client_seal = nullptr, *client_unseal = nullptr; gsec_aead_crypter *server_crypter_seal = nullptr, @@ -487,7 +489,7 @@ static void alts_crypter_do_generic_tests() { client_unseal); } -int main(int /*argc*/, char** /*argv*/) { - alts_crypter_do_generic_tests(); - return 0; +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc b/test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc index 3b75ecf66c5..bf59e836366 100644 --- a/test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc +++ b/test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc @@ -20,6 +20,8 @@ #include +#include + #include #include @@ -37,8 +39,8 @@ static void alts_test_do_round_trip_check_frames( const size_t client_frame_size, const uint8_t* server_message, const size_t server_message_size, const uint8_t* server_expected_frames, const size_t server_frame_size) { - GPR_ASSERT(fixture != nullptr); - GPR_ASSERT(fixture->config != nullptr); + ASSERT_NE(fixture, nullptr); + ASSERT_NE(fixture->config, nullptr); tsi_frame_protector* client_frame_protector = nullptr; tsi_frame_protector* server_frame_protector = nullptr; tsi_test_frame_protector_config* config = fixture->config; @@ -46,21 +48,22 @@ static void alts_test_do_round_trip_check_frames( /* Create a client frame protector. */ size_t client_max_output_protected_frame_size = config->client_max_output_protected_frame_size; - GPR_ASSERT( + ASSERT_EQ( alts_create_frame_protector(key, key_size, /*is_client=*/true, rekey, client_max_output_protected_frame_size == 0 ? nullptr : &client_max_output_protected_frame_size, - &client_frame_protector) == TSI_OK); - /* Create a server frame protector. */ + &client_frame_protector), + TSI_OK); /* Create a server frame protector. */ size_t server_max_output_protected_frame_size = config->server_max_output_protected_frame_size; - GPR_ASSERT( + ASSERT_EQ( alts_create_frame_protector(key, key_size, /*is_client=*/false, rekey, server_max_output_protected_frame_size == 0 ? nullptr : &server_max_output_protected_frame_size, - &server_frame_protector) == TSI_OK); + &server_frame_protector), + TSI_OK); tsi_test_frame_protector_fixture_init(fixture, client_frame_protector, server_frame_protector); /* Client sends a message to server. */ @@ -71,18 +74,20 @@ static void alts_test_do_round_trip_check_frames( client_frame_protector, /*is_client=*/true); /* Verify if the generated frame is the same as the expected. */ - GPR_ASSERT(channel->bytes_written_to_server_channel == client_frame_size); - GPR_ASSERT(memcmp(client_expected_frames, channel->server_channel, - client_frame_size) == 0); + ASSERT_EQ(channel->bytes_written_to_server_channel, client_frame_size); + ASSERT_EQ(memcmp(client_expected_frames, channel->server_channel, + client_frame_size), + 0); unsigned char* server_received_message = static_cast(gpr_malloc(kChannelSize)); size_t server_received_message_size = 0; tsi_test_frame_protector_receive_message_from_peer( config, channel, server_frame_protector, server_received_message, &server_received_message_size, /*is_client=*/false); - GPR_ASSERT(config->client_message_size == server_received_message_size); - GPR_ASSERT(memcmp(config->client_message, server_received_message, - server_received_message_size) == 0); + ASSERT_EQ(config->client_message_size, server_received_message_size); + ASSERT_EQ(memcmp(config->client_message, server_received_message, + server_received_message_size), + 0); /* Server sends a message to client. */ uint8_t* saved_server_message = config->server_message; config->server_message = const_cast(server_message); @@ -91,9 +96,10 @@ static void alts_test_do_round_trip_check_frames( server_frame_protector, /*is_client=*/false); /* Verify if the generated frame is the same as the expected. */ - GPR_ASSERT(channel->bytes_written_to_client_channel == server_frame_size); - GPR_ASSERT(memcmp(server_expected_frames, channel->client_channel, - server_frame_size) == 0); + ASSERT_EQ(channel->bytes_written_to_client_channel, server_frame_size); + ASSERT_EQ(memcmp(server_expected_frames, channel->client_channel, + server_frame_size), + 0); unsigned char* client_received_message = static_cast(gpr_malloc(kChannelSize)); size_t client_received_message_size = 0; @@ -101,9 +107,10 @@ static void alts_test_do_round_trip_check_frames( config, channel, client_frame_protector, client_received_message, &client_received_message_size, /*is_client=*/true); - GPR_ASSERT(config->server_message_size == client_received_message_size); - GPR_ASSERT(memcmp(config->server_message, client_received_message, - client_received_message_size) == 0); + ASSERT_EQ(config->server_message_size, client_received_message_size); + ASSERT_EQ(memcmp(config->server_message, client_received_message, + client_received_message_size), + 0); config->client_message = saved_client_message; config->server_message = saved_server_message; /* Destroy server and client frame protectors. */ @@ -330,8 +337,8 @@ static void alts_test_do_round_trip_vector_tests() { static void alts_test_do_round_trip(tsi_test_frame_protector_fixture* fixture, bool rekey) { - GPR_ASSERT(fixture != nullptr); - GPR_ASSERT(fixture->config != nullptr); + ASSERT_NE(fixture, nullptr); + ASSERT_NE(fixture->config, nullptr); tsi_frame_protector* client_frame_protector = nullptr; tsi_frame_protector* server_frame_protector = nullptr; tsi_test_frame_protector_config* config = fixture->config; @@ -342,21 +349,23 @@ static void alts_test_do_round_trip(tsi_test_frame_protector_fixture* fixture, /* Create a client frame protector. */ size_t client_max_output_protected_frame_size = config->client_max_output_protected_frame_size; - GPR_ASSERT( + ASSERT_EQ( alts_create_frame_protector(key, key_length, /*is_client=*/true, rekey, client_max_output_protected_frame_size == 0 ? nullptr : &client_max_output_protected_frame_size, - &client_frame_protector) == TSI_OK); + &client_frame_protector), + TSI_OK); /* Create a server frame protector. */ size_t server_max_output_protected_frame_size = config->server_max_output_protected_frame_size; - GPR_ASSERT( + ASSERT_EQ( alts_create_frame_protector(key, key_length, /*is_client=*/false, rekey, server_max_output_protected_frame_size == 0 ? nullptr : &server_max_output_protected_frame_size, - &server_frame_protector) == TSI_OK); + &server_frame_protector), + TSI_OK); tsi_test_frame_protector_fixture_init(fixture, client_frame_protector, server_frame_protector); tsi_test_frame_protector_do_round_trip_no_handshake(fixture); @@ -387,9 +396,13 @@ static void alts_test_do_round_trip_all(bool rekey) { gpr_free(bit_array); } -int main(int /*argc*/, char** /*argv*/) { +TEST(AltsFrameProtectorTest, MainTest) { alts_test_do_round_trip_vector_tests(); alts_test_do_round_trip_all(/*rekey=*/false); alts_test_do_round_trip_all(/*rekey=*/true); - return 0; +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/alts/frame_protector/frame_handler_test.cc b/test/core/tsi/alts/frame_protector/frame_handler_test.cc index a8324aba9ec..468e9278661 100644 --- a/test/core/tsi/alts/frame_protector/frame_handler_test.cc +++ b/test/core/tsi/alts/frame_protector/frame_handler_test.cc @@ -24,6 +24,8 @@ #include +#include + #include #include @@ -67,33 +69,34 @@ static void frame(frame_handler* handler, unsigned char* payload, handler->buffer_size = frame_length(payload_length); handler->buffer = static_cast(gpr_malloc(handler->buffer_size)); - GPR_ASSERT(alts_reset_frame_writer(handler->writer, payload, payload_length)); + ASSERT_TRUE( + alts_reset_frame_writer(handler->writer, payload, payload_length)); size_t offset = 0; while (offset < handler->buffer_size && !alts_is_frame_writer_done(handler->writer)) { size_t bytes_written = std::min(write_length, handler->buffer_size - offset); - GPR_ASSERT(alts_write_frame_bytes(handler->writer, handler->buffer + offset, - &bytes_written)); + ASSERT_TRUE(alts_write_frame_bytes( + handler->writer, handler->buffer + offset, &bytes_written)); offset += bytes_written; } - GPR_ASSERT(alts_is_frame_writer_done(handler->writer)); - GPR_ASSERT(handler->buffer_size == offset); + ASSERT_TRUE(alts_is_frame_writer_done(handler->writer)); + ASSERT_EQ(handler->buffer_size, offset); } static size_t deframe(frame_handler* handler, unsigned char* bytes, size_t read_length) { - GPR_ASSERT(alts_reset_frame_reader(handler->reader, bytes)); + EXPECT_TRUE(alts_reset_frame_reader(handler->reader, bytes)); size_t offset = 0; while (offset < handler->buffer_size && !alts_is_frame_reader_done(handler->reader)) { size_t bytes_read = std::min(read_length, handler->buffer_size - offset); - GPR_ASSERT(alts_read_frame_bytes(handler->reader, handler->buffer + offset, - &bytes_read)); + EXPECT_TRUE(alts_read_frame_bytes(handler->reader, handler->buffer + offset, + &bytes_read)); offset += bytes_read; } - GPR_ASSERT(alts_is_frame_reader_done(handler->reader)); - GPR_ASSERT(handler->buffer_size == offset); + EXPECT_TRUE(alts_is_frame_reader_done(handler->reader)); + EXPECT_EQ(handler->buffer_size, offset); return offset - handler->reader->header_bytes_read; } @@ -104,12 +107,12 @@ static void frame_n_deframe(frame_handler* handler, unsigned char* payload, unsigned char* bytes = static_cast(gpr_malloc(kFrameHandlerTestBufferSize)); size_t deframed_payload_length = deframe(handler, bytes, read_length); - GPR_ASSERT(payload_length == deframed_payload_length); - GPR_ASSERT(memcmp(payload, bytes, payload_length) == 0); + ASSERT_EQ(payload_length, deframed_payload_length); + ASSERT_EQ(memcmp(payload, bytes, payload_length), 0); gpr_free(bytes); } -static void frame_handler_test_frame_deframe() { +TEST(FrameHandlerTest, FrameHandlerTestFrameDeframe) { unsigned char payload[] = "hello world"; size_t payload_length = strlen(reinterpret_cast(payload)) + 1; frame_handler* handler = create_frame_handler(); @@ -118,7 +121,7 @@ static void frame_handler_test_frame_deframe() { destroy_frame_handler(handler); } -static void frame_handler_test_small_buffer() { +TEST(FrameHandlerTest, FrameHandlerTestSmallBuffer) { unsigned char payload[] = "hello world"; size_t payload_length = strlen(reinterpret_cast(payload)) + 1; frame_handler* handler = create_frame_handler(); @@ -126,40 +129,42 @@ static void frame_handler_test_small_buffer() { destroy_frame_handler(handler); } -static void frame_handler_test_null_input_stream() { +TEST(FrameHandlerTest, FrameHandlerTestNullInputStream) { frame_handler* handler = create_frame_handler(); - GPR_ASSERT(!alts_reset_frame_writer(handler->writer, nullptr, 0)); + ASSERT_FALSE(alts_reset_frame_writer(handler->writer, nullptr, 0)); destroy_frame_handler(handler); } -static void frame_handler_test_bad_input_length() { +TEST(FrameHandlerTest, FrameHandlerTestBadInputLength) { unsigned char payload[] = "hello world"; frame_handler* handler = create_frame_handler(); - GPR_ASSERT(!alts_reset_frame_writer(handler->writer, payload, SIZE_MAX)); + ASSERT_FALSE(alts_reset_frame_writer(handler->writer, payload, SIZE_MAX)); destroy_frame_handler(handler); } -static void frame_handler_test_null_writer_byte_length() { +TEST(FrameHandlerTest, FrameHandlerTestNullWriterByteLength) { unsigned char payload[] = "hello world"; size_t payload_length = strlen(reinterpret_cast(payload)) + 1; frame_handler* handler = create_frame_handler(); - GPR_ASSERT(alts_reset_frame_writer(handler->writer, payload, payload_length)); - GPR_ASSERT( + ASSERT_TRUE( + alts_reset_frame_writer(handler->writer, payload, payload_length)); + ASSERT_TRUE( !alts_write_frame_bytes(handler->writer, handler->buffer, nullptr)); destroy_frame_handler(handler); } -static void frame_handler_test_null_writer_bytes() { +TEST(FrameHandlerTest, FrameHandlerTestNullWriterBytes) { unsigned char payload[] = "hello world"; size_t payload_length = strlen(reinterpret_cast(payload)) + 1; frame_handler* handler = create_frame_handler(); - GPR_ASSERT(alts_reset_frame_writer(handler->writer, payload, payload_length)); - GPR_ASSERT( + ASSERT_TRUE( + alts_reset_frame_writer(handler->writer, payload, payload_length)); + ASSERT_TRUE( !alts_write_frame_bytes(handler->writer, nullptr, &payload_length)); destroy_frame_handler(handler); } -static void frame_handler_test_bad_frame_length() { +TEST(FrameHandlerTest, FrameHandlerTestBadFrameLength) { unsigned char payload[] = "hello world"; size_t payload_length = strlen(reinterpret_cast(payload)) + 1; frame_handler* handler = create_frame_handler(); @@ -167,17 +172,17 @@ static void frame_handler_test_bad_frame_length() { memset(handler->buffer, 0x00, kFrameLengthFieldSize); unsigned char* bytes = static_cast(gpr_malloc(kFrameHandlerTestBufferSize)); - GPR_ASSERT(alts_reset_frame_reader(handler->reader, bytes)); + ASSERT_TRUE(alts_reset_frame_reader(handler->reader, bytes)); size_t bytes_read = handler->buffer_size; - GPR_ASSERT( + ASSERT_TRUE( !alts_read_frame_bytes(handler->reader, handler->buffer, &bytes_read)); - GPR_ASSERT(alts_is_frame_reader_done(handler->reader)); - GPR_ASSERT(bytes_read == 0); + ASSERT_TRUE(alts_is_frame_reader_done(handler->reader)); + ASSERT_EQ(bytes_read, 0); gpr_free(bytes); destroy_frame_handler(handler); } -static void frame_handler_test_unsupported_message_type() { +TEST(FrameHandlerTest, FrameHandlerTestUnsupportedMessageType) { unsigned char payload[] = "hello world"; size_t payload_length = strlen(reinterpret_cast(payload)) + 1; frame_handler* handler = create_frame_handler(); @@ -186,63 +191,54 @@ static void frame_handler_test_unsupported_message_type() { kFrameMessageTypeFieldSize); unsigned char* bytes = static_cast(gpr_malloc(kFrameHandlerTestBufferSize)); - GPR_ASSERT(alts_reset_frame_reader(handler->reader, bytes)); + ASSERT_TRUE(alts_reset_frame_reader(handler->reader, bytes)); size_t bytes_read = handler->buffer_size; - GPR_ASSERT( + ASSERT_TRUE( !alts_read_frame_bytes(handler->reader, handler->buffer, &bytes_read)); - GPR_ASSERT(alts_is_frame_reader_done(handler->reader)); - GPR_ASSERT(bytes_read == 0); + ASSERT_TRUE(alts_is_frame_reader_done(handler->reader)); + ASSERT_EQ(bytes_read, 0); gpr_free(bytes); destroy_frame_handler(handler); } -static void frame_handler_test_null_output_stream() { +TEST(FrameHandlerTest, FrameHandlerTestNullOutputStream) { unsigned char payload[] = "hello world"; size_t payload_length = strlen(reinterpret_cast(payload)) + 1; frame_handler* handler = create_frame_handler(); frame(handler, payload, payload_length, payload_length); - GPR_ASSERT(!alts_reset_frame_reader(handler->reader, nullptr)); + ASSERT_FALSE(alts_reset_frame_reader(handler->reader, nullptr)); destroy_frame_handler(handler); } -static void frame_handler_test_null_reader_byte_length() { +TEST(FrameHandlerTest, FrameHandlerTestNullReaderByteLength) { unsigned char payload[] = "hello world"; size_t payload_length = strlen(reinterpret_cast(payload)) + 1; frame_handler* handler = create_frame_handler(); frame(handler, payload, payload_length, payload_length); unsigned char* bytes = static_cast(gpr_malloc(kFrameHandlerTestBufferSize)); - GPR_ASSERT(alts_reset_frame_reader(handler->reader, bytes)); - GPR_ASSERT(!alts_read_frame_bytes(handler->reader, handler->buffer, nullptr)); + ASSERT_TRUE(alts_reset_frame_reader(handler->reader, bytes)); + ASSERT_FALSE( + alts_read_frame_bytes(handler->reader, handler->buffer, nullptr)); gpr_free(bytes); destroy_frame_handler(handler); } -static void frame_handler_test_null_reader_bytes() { +TEST(FrameHandlerTest, FrameHandlerTestNullReaderBytes) { unsigned char payload[] = "hello world"; size_t payload_length = strlen(reinterpret_cast(payload)) + 1; frame_handler* handler = create_frame_handler(); frame(handler, payload, payload_length, payload_length); unsigned char* bytes = static_cast(gpr_malloc(kFrameHandlerTestBufferSize)); - GPR_ASSERT(alts_reset_frame_reader(handler->reader, bytes)); + ASSERT_TRUE(alts_reset_frame_reader(handler->reader, bytes)); size_t bytes_read = handler->buffer_size; - GPR_ASSERT(!alts_read_frame_bytes(handler->reader, nullptr, &bytes_read)); + ASSERT_FALSE(alts_read_frame_bytes(handler->reader, nullptr, &bytes_read)); gpr_free(bytes); destroy_frame_handler(handler); } -int main(int /*argc*/, char** /*argv*/) { - frame_handler_test_frame_deframe(); - frame_handler_test_small_buffer(); - frame_handler_test_null_input_stream(); - frame_handler_test_bad_input_length(); - frame_handler_test_null_writer_byte_length(); - frame_handler_test_null_writer_bytes(); - frame_handler_test_bad_frame_length(); - frame_handler_test_unsupported_message_type(); - frame_handler_test_null_output_stream(); - frame_handler_test_null_reader_byte_length(); - frame_handler_test_null_reader_bytes(); - return 0; +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/alts/handshaker/BUILD b/test/core/tsi/alts/handshaker/BUILD index 77f6e8d3051..6122a0931d5 100644 --- a/test/core/tsi/alts/handshaker/BUILD +++ b/test/core/tsi/alts/handshaker/BUILD @@ -30,6 +30,7 @@ grpc_cc_library( grpc_cc_test( name = "alts_handshaker_client_test", srcs = ["alts_handshaker_client_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ ":alts_handshaker_service_api_test_lib", @@ -41,6 +42,7 @@ grpc_cc_test( grpc_cc_test( name = "alts_tsi_handshaker_test", srcs = ["alts_tsi_handshaker_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ ":alts_handshaker_service_api_test_lib", @@ -54,6 +56,7 @@ grpc_cc_test( grpc_cc_test( name = "alts_tsi_utils_test", srcs = ["alts_tsi_utils_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ ":alts_handshaker_service_api_test_lib", @@ -65,6 +68,7 @@ grpc_cc_test( grpc_cc_test( name = "transport_security_common_api_test", srcs = ["transport_security_common_api_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ "//:grpc", diff --git a/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc b/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc index 0c381139bd2..8c2227c4dc3 100644 --- a/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc +++ b/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc @@ -18,6 +18,8 @@ #include "src/core/tsi/alts/handshaker/alts_handshaker_client.h" +#include + #include "upb/upb.hpp" #include @@ -64,32 +66,32 @@ typedef struct alts_handshaker_client_test_config { static void validate_rpc_protocol_versions( const grpc_gcp_RpcProtocolVersions* versions) { - GPR_ASSERT(versions != nullptr); + ASSERT_NE(versions, nullptr); const grpc_gcp_RpcProtocolVersions_Version* max_version = grpc_gcp_RpcProtocolVersions_max_rpc_version(versions); const grpc_gcp_RpcProtocolVersions_Version* min_version = grpc_gcp_RpcProtocolVersions_min_rpc_version(versions); - GPR_ASSERT(grpc_gcp_RpcProtocolVersions_Version_major(max_version) == - kMaxRpcVersionMajor); - GPR_ASSERT(grpc_gcp_RpcProtocolVersions_Version_minor(max_version) == - kMaxRpcVersionMinor); - GPR_ASSERT(grpc_gcp_RpcProtocolVersions_Version_major(min_version) == - kMinRpcVersionMajor); - GPR_ASSERT(grpc_gcp_RpcProtocolVersions_Version_minor(min_version) == - kMinRpcVersionMinor); + ASSERT_EQ(grpc_gcp_RpcProtocolVersions_Version_major(max_version), + kMaxRpcVersionMajor); + ASSERT_EQ(grpc_gcp_RpcProtocolVersions_Version_minor(max_version), + kMaxRpcVersionMinor); + ASSERT_EQ(grpc_gcp_RpcProtocolVersions_Version_major(min_version), + kMinRpcVersionMajor); + ASSERT_EQ(grpc_gcp_RpcProtocolVersions_Version_minor(min_version), + kMinRpcVersionMinor); } static void validate_target_identities( const grpc_gcp_Identity* const* target_identities, size_t target_identities_count) { - GPR_ASSERT(target_identities_count == 2); + ASSERT_EQ(target_identities_count, 2); const grpc_gcp_Identity* identity1 = target_identities[1]; const grpc_gcp_Identity* identity2 = target_identities[0]; - GPR_ASSERT(upb_StringView_IsEqual( + ASSERT_TRUE(upb_StringView_IsEqual( grpc_gcp_Identity_service_account(identity1), upb_StringView_FromString( ALTS_HANDSHAKER_CLIENT_TEST_TARGET_SERVICE_ACCOUNT1))); - GPR_ASSERT(upb_StringView_IsEqual( + ASSERT_TRUE(upb_StringView_IsEqual( grpc_gcp_Identity_service_account(identity2), upb_StringView_FromString( ALTS_HANDSHAKER_CLIENT_TEST_TARGET_SERVICE_ACCOUNT2))); @@ -101,41 +103,41 @@ static void validate_target_identities( */ static bool validate_op(alts_handshaker_client* c, const grpc_op* op, size_t nops, bool is_start) { - GPR_ASSERT(c != nullptr && op != nullptr && nops != 0); + EXPECT_TRUE(c != nullptr && op != nullptr && nops != 0); bool ok = true; grpc_op* start_op = const_cast(op); if (is_start) { ok &= (op->op == GRPC_OP_SEND_INITIAL_METADATA); ok &= (op->data.send_initial_metadata.count == 0); op++; - GPR_ASSERT((size_t)(op - start_op) <= kHandshakerClientOpNum); + EXPECT_LE((size_t)(op - start_op), kHandshakerClientOpNum); ok &= (op->op == GRPC_OP_RECV_INITIAL_METADATA); ok &= (op->data.recv_initial_metadata.recv_initial_metadata == alts_handshaker_client_get_initial_metadata_for_testing(c)); op++; - GPR_ASSERT((size_t)(op - start_op) <= kHandshakerClientOpNum); + EXPECT_LE((size_t)(op - start_op), kHandshakerClientOpNum); } ok &= (op->op == GRPC_OP_SEND_MESSAGE); ok &= (op->data.send_message.send_message == alts_handshaker_client_get_send_buffer_for_testing(c)); op++; - GPR_ASSERT((size_t)(op - start_op) <= kHandshakerClientOpNum); + EXPECT_LE((size_t)(op - start_op), kHandshakerClientOpNum); ok &= (op->op == GRPC_OP_RECV_MESSAGE); ok &= (op->data.recv_message.recv_message == alts_handshaker_client_get_recv_buffer_addr_for_testing(c)); op++; - GPR_ASSERT((size_t)(op - start_op) <= kHandshakerClientOpNum); + EXPECT_LE((size_t)(op - start_op), kHandshakerClientOpNum); return ok; } static grpc_gcp_HandshakerReq* deserialize_handshaker_req( grpc_byte_buffer* buffer, upb_Arena* arena) { - GPR_ASSERT(buffer != nullptr); + EXPECT_NE(buffer, nullptr); grpc_byte_buffer_reader bbr; - GPR_ASSERT(grpc_byte_buffer_reader_init(&bbr, buffer)); + EXPECT_TRUE(grpc_byte_buffer_reader_init(&bbr, buffer)); grpc_slice slice = grpc_byte_buffer_reader_readall(&bbr); grpc_gcp_HandshakerReq* req = grpc_gcp_handshaker_req_decode(slice, arena); - GPR_ASSERT(req != nullptr); + EXPECT_NE(req, nullptr); grpc_slice_unref(slice); grpc_byte_buffer_reader_destroy(&bbr); return req; @@ -153,7 +155,7 @@ static grpc_call_error check_must_not_be_called(grpc_call* /*call*/, const grpc_op* /*ops*/, size_t /*nops*/, grpc_closure* /*tag*/) { - GPR_ASSERT(0); + abort(); } /** @@ -173,22 +175,23 @@ static grpc_call_error check_client_start_success(grpc_call* /*call*/, upb::Arena arena; alts_handshaker_client* client = static_cast(closure->cb_arg); - GPR_ASSERT(alts_handshaker_client_get_closure_for_testing(client) == closure); + EXPECT_EQ(alts_handshaker_client_get_closure_for_testing(client), closure); grpc_gcp_HandshakerReq* req = deserialize_handshaker_req( alts_handshaker_client_get_send_buffer_for_testing(client), arena.ptr()); const grpc_gcp_StartClientHandshakeReq* client_start = grpc_gcp_HandshakerReq_client_start(req); - GPR_ASSERT(grpc_gcp_StartClientHandshakeReq_handshake_security_protocol( - client_start) == grpc_gcp_ALTS); + EXPECT_EQ(grpc_gcp_StartClientHandshakeReq_handshake_security_protocol( + client_start), + grpc_gcp_ALTS); upb_StringView const* application_protocols = grpc_gcp_StartClientHandshakeReq_application_protocols(client_start, nullptr); - GPR_ASSERT(upb_StringView_IsEqual( + EXPECT_TRUE(upb_StringView_IsEqual( application_protocols[0], upb_StringView_FromString(ALTS_APPLICATION_PROTOCOL))); upb_StringView const* record_protocols = grpc_gcp_StartClientHandshakeReq_record_protocols(client_start, nullptr); - GPR_ASSERT(upb_StringView_IsEqual( + EXPECT_TRUE(upb_StringView_IsEqual( record_protocols[0], upb_StringView_FromString(ALTS_RECORD_PROTOCOL))); const grpc_gcp_RpcProtocolVersions* rpc_protocol_versions = grpc_gcp_StartClientHandshakeReq_rpc_versions(client_start); @@ -198,12 +201,12 @@ static grpc_call_error check_client_start_success(grpc_call* /*call*/, grpc_gcp_StartClientHandshakeReq_target_identities( client_start, &target_identities_count); validate_target_identities(target_identities, target_identities_count); - GPR_ASSERT(upb_StringView_IsEqual( + EXPECT_TRUE(upb_StringView_IsEqual( grpc_gcp_StartClientHandshakeReq_target_name(client_start), upb_StringView_FromString(ALTS_HANDSHAKER_CLIENT_TEST_TARGET_NAME))); - GPR_ASSERT(grpc_gcp_StartClientHandshakeReq_max_frame_size(client_start) == - ALTS_HANDSHAKER_CLIENT_TEST_MAX_FRAME_SIZE); - GPR_ASSERT(validate_op(client, op, nops, true /* is_start */)); + EXPECT_EQ(grpc_gcp_StartClientHandshakeReq_max_frame_size(client_start), + ALTS_HANDSHAKER_CLIENT_TEST_MAX_FRAME_SIZE); + EXPECT_TRUE(validate_op(client, op, nops, true /* is_start */)); return GRPC_CALL_OK; } @@ -224,7 +227,7 @@ static grpc_call_error check_server_start_success(grpc_call* /*call*/, upb::Arena arena; alts_handshaker_client* client = static_cast(closure->cb_arg); - GPR_ASSERT(alts_handshaker_client_get_closure_for_testing(client) == closure); + EXPECT_EQ(alts_handshaker_client_get_closure_for_testing(client), closure); grpc_gcp_HandshakerReq* req = deserialize_handshaker_req( alts_handshaker_client_get_send_buffer_for_testing(client), arena.ptr()); const grpc_gcp_StartServerHandshakeReq* server_start = @@ -232,23 +235,24 @@ static grpc_call_error check_server_start_success(grpc_call* /*call*/, upb_StringView const* application_protocols = grpc_gcp_StartServerHandshakeReq_application_protocols(server_start, nullptr); - GPR_ASSERT(upb_StringView_IsEqual( + EXPECT_TRUE(upb_StringView_IsEqual( application_protocols[0], upb_StringView_FromString(ALTS_APPLICATION_PROTOCOL))); - GPR_ASSERT(grpc_gcp_StartServerHandshakeReq_handshake_parameters_size( - server_start) == 1); + EXPECT_EQ( + grpc_gcp_StartServerHandshakeReq_handshake_parameters_size(server_start), + 1); grpc_gcp_ServerHandshakeParameters* value; - GPR_ASSERT(grpc_gcp_StartServerHandshakeReq_handshake_parameters_get( + EXPECT_TRUE(grpc_gcp_StartServerHandshakeReq_handshake_parameters_get( server_start, grpc_gcp_ALTS, &value)); upb_StringView const* record_protocols = grpc_gcp_ServerHandshakeParameters_record_protocols(value, nullptr); - GPR_ASSERT(upb_StringView_IsEqual( + EXPECT_TRUE(upb_StringView_IsEqual( record_protocols[0], upb_StringView_FromString(ALTS_RECORD_PROTOCOL))); validate_rpc_protocol_versions( grpc_gcp_StartServerHandshakeReq_rpc_versions(server_start)); - GPR_ASSERT(grpc_gcp_StartServerHandshakeReq_max_frame_size(server_start) == - ALTS_HANDSHAKER_CLIENT_TEST_MAX_FRAME_SIZE); - GPR_ASSERT(validate_op(client, op, nops, true /* is_start */)); + EXPECT_EQ(grpc_gcp_StartServerHandshakeReq_max_frame_size(server_start), + ALTS_HANDSHAKER_CLIENT_TEST_MAX_FRAME_SIZE); + EXPECT_TRUE(validate_op(client, op, nops, true /* is_start */)); return GRPC_CALL_OK; } @@ -263,15 +267,15 @@ static grpc_call_error check_next_success(grpc_call* /*call*/, upb::Arena arena; alts_handshaker_client* client = static_cast(closure->cb_arg); - GPR_ASSERT(alts_handshaker_client_get_closure_for_testing(client) == closure); + EXPECT_EQ(alts_handshaker_client_get_closure_for_testing(client), closure); grpc_gcp_HandshakerReq* req = deserialize_handshaker_req( alts_handshaker_client_get_send_buffer_for_testing(client), arena.ptr()); const grpc_gcp_NextHandshakeMessageReq* next = grpc_gcp_HandshakerReq_next(req); - GPR_ASSERT(upb_StringView_IsEqual( + EXPECT_TRUE(upb_StringView_IsEqual( grpc_gcp_NextHandshakeMessageReq_in_bytes(next), upb_StringView_FromString(ALTS_HANDSHAKER_CLIENT_TEST_OUT_FRAME))); - GPR_ASSERT(validate_op(client, op, nops, false /* is_start */)); + EXPECT_TRUE(validate_op(client, op, nops, false /* is_start */)); return GRPC_CALL_OK; } @@ -302,9 +306,9 @@ static grpc_alts_credentials_options* create_credentials_options( options, ALTS_HANDSHAKER_CLIENT_TEST_TARGET_SERVICE_ACCOUNT2); } grpc_gcp_rpc_protocol_versions* versions = &options->rpc_versions; - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_max( + EXPECT_TRUE(grpc_gcp_rpc_protocol_versions_set_max( versions, kMaxRpcVersionMajor, kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min( + EXPECT_TRUE(grpc_gcp_rpc_protocol_versions_set_min( versions, kMinRpcVersionMajor, kMinRpcVersionMinor)); return options; } @@ -334,8 +338,8 @@ static alts_handshaker_client_test_config* create_config() { grpc_slice_from_static_string(ALTS_HANDSHAKER_CLIENT_TEST_TARGET_NAME), nullptr, nullptr, nullptr, nullptr, true, ALTS_HANDSHAKER_CLIENT_TEST_MAX_FRAME_SIZE); - GPR_ASSERT(config->client != nullptr); - GPR_ASSERT(config->server != nullptr); + EXPECT_NE(config->client, nullptr); + EXPECT_NE(config->server, nullptr); grpc_alts_credentials_options_destroy(client_options); grpc_alts_credentials_options_destroy(server_options); config->out_frame = @@ -355,7 +359,7 @@ static void destroy_config(alts_handshaker_client_test_config* config) { gpr_free(config); } -static void schedule_request_invalid_arg_test() { +TEST(AltsHandshakerClientTest, ScheduleRequestInvalidArgTest) { /* Initialization. */ alts_handshaker_client_test_config* config = create_config(); /* Tests. */ @@ -364,30 +368,30 @@ static void schedule_request_invalid_arg_test() { /* Check client_start. */ { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(alts_handshaker_client_start_client(nullptr) == - TSI_INVALID_ARGUMENT); + ASSERT_EQ(alts_handshaker_client_start_client(nullptr), + TSI_INVALID_ARGUMENT); } /* Check server_start. */ { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(alts_handshaker_client_start_server(config->server, nullptr) == - TSI_INVALID_ARGUMENT); + ASSERT_EQ(alts_handshaker_client_start_server(config->server, nullptr), + TSI_INVALID_ARGUMENT); } { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(alts_handshaker_client_start_server( - nullptr, &config->out_frame) == TSI_INVALID_ARGUMENT); + ASSERT_EQ(alts_handshaker_client_start_server(nullptr, &config->out_frame), + TSI_INVALID_ARGUMENT); } /* Check next. */ { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(alts_handshaker_client_next(config->client, nullptr) == - TSI_INVALID_ARGUMENT); + ASSERT_EQ(alts_handshaker_client_next(config->client, nullptr), + TSI_INVALID_ARGUMENT); } { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(alts_handshaker_client_next(nullptr, &config->out_frame) == - TSI_INVALID_ARGUMENT); + ASSERT_EQ(alts_handshaker_client_next(nullptr, &config->out_frame), + TSI_INVALID_ARGUMENT); } /* Check shutdown. */ alts_handshaker_client_shutdown(nullptr); @@ -395,7 +399,7 @@ static void schedule_request_invalid_arg_test() { destroy_config(config); } -static void schedule_request_success_test() { +TEST(AltsHandshakerClientTest, ScheduleRequestSuccessTest) { /* Initialization. */ alts_handshaker_client_test_config* config = create_config(); /* Check client_start success. */ @@ -403,36 +407,37 @@ static void schedule_request_success_test() { config->client, check_client_start_success); { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(alts_handshaker_client_start_client(config->client) == TSI_OK); + ASSERT_EQ(alts_handshaker_client_start_client(config->client), TSI_OK); } { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(alts_handshaker_client_next(nullptr, &config->out_frame) == - TSI_INVALID_ARGUMENT); + ASSERT_EQ(alts_handshaker_client_next(nullptr, &config->out_frame), + TSI_INVALID_ARGUMENT); } /* Check server_start success. */ alts_handshaker_client_set_grpc_caller_for_testing( config->server, check_server_start_success); { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(alts_handshaker_client_start_server( - config->server, &config->out_frame) == TSI_OK); + ASSERT_EQ( + alts_handshaker_client_start_server(config->server, &config->out_frame), + TSI_OK); } /* Check client next success. */ alts_handshaker_client_set_grpc_caller_for_testing(config->client, check_next_success); { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(alts_handshaker_client_next(config->client, - &config->out_frame) == TSI_OK); + ASSERT_EQ(alts_handshaker_client_next(config->client, &config->out_frame), + TSI_OK); } /* Check server next success. */ alts_handshaker_client_set_grpc_caller_for_testing(config->server, check_next_success); { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(alts_handshaker_client_next(config->server, - &config->out_frame) == TSI_OK); + ASSERT_EQ(alts_handshaker_client_next(config->server, &config->out_frame), + TSI_OK); } /* Cleanup. */ { @@ -449,10 +454,10 @@ static void tsi_cb_assert_tsi_internal_error( tsi_result status, void* /*user_data*/, const unsigned char* /*bytes_to_send*/, size_t /*bytes_to_send_size*/, tsi_handshaker_result* /*result*/) { - GPR_ASSERT(status == TSI_INTERNAL_ERROR); + ASSERT_EQ(status, TSI_INTERNAL_ERROR); } -static void schedule_request_grpc_call_failure_test() { +TEST(AltsHandshakerClientTest, ScheduleRequestGrpcCallFailureTest) { /* Initialization. */ alts_handshaker_client_test_config* config = create_config(); /* Check client_start failure. */ @@ -482,14 +487,14 @@ static void schedule_request_grpc_call_failure_test() { { grpc_core::ExecCtx exec_ctx; /* Check client next failure. */ - GPR_ASSERT(alts_handshaker_client_next( - config->client, &config->out_frame) == TSI_INTERNAL_ERROR); + ASSERT_EQ(alts_handshaker_client_next(config->client, &config->out_frame), + TSI_INTERNAL_ERROR); } { grpc_core::ExecCtx exec_ctx; /* Check server next failure. */ - GPR_ASSERT(alts_handshaker_client_next( - config->server, &config->out_frame) == TSI_INTERNAL_ERROR); + ASSERT_EQ(alts_handshaker_client_next(config->server, &config->out_frame), + TSI_INTERNAL_ERROR); } /* Cleanup. */ { @@ -504,15 +509,10 @@ static void schedule_request_grpc_call_failure_test() { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); - /* Initialization. */ - grpc_init(); + ::testing::InitGoogleTest(&argc, argv); + grpc::testing::TestGrpcScope grpc_scope; grpc_alts_shared_resource_dedicated_init(); - /* Tests. */ - schedule_request_invalid_arg_test(); - schedule_request_success_test(); - schedule_request_grpc_call_failure_test(); - /* Cleanup. */ + int ret = RUN_ALL_TESTS(); grpc_alts_shared_resource_dedicated_shutdown(); - grpc_shutdown(); - return 0; + return ret; } diff --git a/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc b/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc index 10d8ad4dfee..b02a35da898 100644 --- a/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc +++ b/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc @@ -21,6 +21,8 @@ #include #include +#include + #include "upb/upb.hpp" #include @@ -162,7 +164,7 @@ static grpc_byte_buffer* generate_handshaker_response( upb_StringView_FromString(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY)); grpc_gcp_HandshakerResult_set_key_data( result, upb_StringView_FromString(ALTS_TSI_HANDSHAKER_TEST_KEY_DATA)); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_peer_rpc_versions( + EXPECT_TRUE(grpc_gcp_handshaker_resp_set_peer_rpc_versions( resp, arena.ptr(), ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR, ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MINOR, ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MAJOR, @@ -199,7 +201,7 @@ static grpc_byte_buffer* generate_handshaker_response( upb_StringView_FromString(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY)); grpc_gcp_HandshakerResult_set_key_data( result, upb_StringView_FromString(ALTS_TSI_HANDSHAKER_TEST_KEY_DATA)); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_peer_rpc_versions( + EXPECT_TRUE(grpc_gcp_handshaker_resp_set_peer_rpc_versions( resp, arena.ptr(), ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR, ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MINOR, ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MAJOR, @@ -240,33 +242,35 @@ static void check_must_not_be_called(tsi_result /*status*/, void* /*user_data*/, const unsigned char* /*bytes_to_send*/, size_t /*bytes_to_send_size*/, tsi_handshaker_result* /*result*/) { - GPR_ASSERT(0); + ASSERT_TRUE(0); } static void on_client_start_success_cb(tsi_result status, void* user_data, const unsigned char* bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result* result) { - GPR_ASSERT(status == TSI_OK); - GPR_ASSERT(user_data == nullptr); - GPR_ASSERT(bytes_to_send_size == strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME)); - GPR_ASSERT(memcmp(bytes_to_send, ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME, - bytes_to_send_size) == 0); - GPR_ASSERT(result == nullptr); + ASSERT_EQ(status, TSI_OK); + ASSERT_EQ(user_data, nullptr); + ASSERT_EQ(bytes_to_send_size, strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME)); + ASSERT_EQ(memcmp(bytes_to_send, ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME, + bytes_to_send_size), + 0); + ASSERT_EQ(result, nullptr); /* Validate peer identity. */ tsi_peer peer; - GPR_ASSERT(tsi_handshaker_result_extract_peer(result, &peer) == - TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_handshaker_result_extract_peer(result, &peer), + TSI_INVALID_ARGUMENT); /* Validate frame protector. */ tsi_frame_protector* protector = nullptr; - GPR_ASSERT(tsi_handshaker_result_create_frame_protector( - result, nullptr, &protector) == TSI_INVALID_ARGUMENT); + ASSERT_EQ( + tsi_handshaker_result_create_frame_protector(result, nullptr, &protector), + TSI_INVALID_ARGUMENT); /* Validate unused bytes. */ const unsigned char* unused_bytes = nullptr; size_t unused_bytes_size = 0; - GPR_ASSERT(tsi_handshaker_result_get_unused_bytes(result, &unused_bytes, - &unused_bytes_size) == - TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_handshaker_result_get_unused_bytes(result, &unused_bytes, + &unused_bytes_size), + TSI_INVALID_ARGUMENT); signal(&tsi_to_caller_notification); } @@ -274,26 +278,28 @@ static void on_server_start_success_cb(tsi_result status, void* user_data, const unsigned char* bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result* result) { - GPR_ASSERT(status == TSI_OK); - GPR_ASSERT(user_data == nullptr); - GPR_ASSERT(bytes_to_send_size == strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME)); - GPR_ASSERT(memcmp(bytes_to_send, ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME, - bytes_to_send_size) == 0); - GPR_ASSERT(result == nullptr); + ASSERT_EQ(status, TSI_OK); + ASSERT_EQ(user_data, nullptr); + ASSERT_EQ(bytes_to_send_size, strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME)); + ASSERT_EQ(memcmp(bytes_to_send, ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME, + bytes_to_send_size), + 0); + ASSERT_EQ(result, nullptr); /* Validate peer identity. */ tsi_peer peer; - GPR_ASSERT(tsi_handshaker_result_extract_peer(result, &peer) == - TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_handshaker_result_extract_peer(result, &peer), + TSI_INVALID_ARGUMENT); /* Validate frame protector. */ tsi_frame_protector* protector = nullptr; - GPR_ASSERT(tsi_handshaker_result_create_frame_protector( - result, nullptr, &protector) == TSI_INVALID_ARGUMENT); + ASSERT_EQ( + tsi_handshaker_result_create_frame_protector(result, nullptr, &protector), + TSI_INVALID_ARGUMENT); /* Validate unused bytes. */ const unsigned char* unused_bytes = nullptr; size_t unused_bytes_size = 0; - GPR_ASSERT(tsi_handshaker_result_get_unused_bytes(result, &unused_bytes, - &unused_bytes_size) == - TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_handshaker_result_get_unused_bytes(result, &unused_bytes, + &unused_bytes_size), + TSI_INVALID_ARGUMENT); signal(&tsi_to_caller_notification); } @@ -301,56 +307,64 @@ static void on_client_next_success_cb(tsi_result status, void* user_data, const unsigned char* bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result* result) { - GPR_ASSERT(status == TSI_OK); - GPR_ASSERT(user_data == nullptr); - GPR_ASSERT(bytes_to_send_size == strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME)); - GPR_ASSERT(memcmp(bytes_to_send, ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME, - bytes_to_send_size) == 0); - GPR_ASSERT(result != nullptr); + ASSERT_EQ(status, TSI_OK); + ASSERT_EQ(user_data, nullptr); + ASSERT_EQ(bytes_to_send_size, strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME)); + ASSERT_EQ(memcmp(bytes_to_send, ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME, + bytes_to_send_size), + 0); + ASSERT_NE(result, nullptr); // Validate max frame size value after Frame Size Negotiation. Here peer max // frame size is greater than default value, and user specified max frame size // is absent. tsi_zero_copy_grpc_protector* zero_copy_protector = nullptr; - GPR_ASSERT(tsi_handshaker_result_create_zero_copy_grpc_protector( - result, nullptr, &zero_copy_protector) == TSI_OK); + ASSERT_EQ(tsi_handshaker_result_create_zero_copy_grpc_protector( + result, nullptr, &zero_copy_protector), + TSI_OK); size_t actual_max_frame_size; tsi_zero_copy_grpc_protector_max_frame_size(zero_copy_protector, &actual_max_frame_size); - GPR_ASSERT(actual_max_frame_size == kTsiAltsMaxFrameSize); + ASSERT_EQ(actual_max_frame_size, kTsiAltsMaxFrameSize); tsi_zero_copy_grpc_protector_destroy(zero_copy_protector); /* Validate peer identity. */ tsi_peer peer; - GPR_ASSERT(tsi_handshaker_result_extract_peer(result, &peer) == TSI_OK); - GPR_ASSERT(peer.property_count == kTsiAltsNumOfPeerProperties); - GPR_ASSERT(memcmp(TSI_ALTS_CERTIFICATE_TYPE, peer.properties[0].value.data, - peer.properties[0].value.length) == 0); - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY, - peer.properties[1].value.data, - peer.properties[1].value.length) == 0); + ASSERT_EQ(tsi_handshaker_result_extract_peer(result, &peer), TSI_OK); + ASSERT_EQ(peer.property_count, kTsiAltsNumOfPeerProperties); + ASSERT_EQ(memcmp(TSI_ALTS_CERTIFICATE_TYPE, peer.properties[0].value.data, + peer.properties[0].value.length), + 0); + ASSERT_EQ( + memcmp(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY, + peer.properties[1].value.data, peer.properties[1].value.length), + 0); /* Validate alts context. */ upb::Arena context_arena; grpc_gcp_AltsContext* ctx = grpc_gcp_AltsContext_parse( peer.properties[3].value.data, peer.properties[3].value.length, context_arena.ptr()); - GPR_ASSERT(ctx != nullptr); + ASSERT_NE(ctx, nullptr); upb_StringView application_protocol = grpc_gcp_AltsContext_application_protocol(ctx); upb_StringView record_protocol = grpc_gcp_AltsContext_record_protocol(ctx); upb_StringView peer_account = grpc_gcp_AltsContext_peer_service_account(ctx); upb_StringView local_account = grpc_gcp_AltsContext_local_service_account(ctx); - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_APPLICATION_PROTOCOL, - application_protocol.data, application_protocol.size) == 0); - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_RECORD_PROTOCOL, - record_protocol.data, record_protocol.size) == 0); - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY, peer_account.data, - peer_account.size) == 0); - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY, local_account.data, - local_account.size) == 0); + ASSERT_EQ(memcmp(ALTS_TSI_HANDSHAKER_TEST_APPLICATION_PROTOCOL, + application_protocol.data, application_protocol.size), + 0); + ASSERT_EQ(memcmp(ALTS_TSI_HANDSHAKER_TEST_RECORD_PROTOCOL, + record_protocol.data, record_protocol.size), + 0); + ASSERT_EQ(memcmp(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY, peer_account.data, + peer_account.size), + 0); + ASSERT_EQ(memcmp(ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY, local_account.data, + local_account.size), + 0); size_t iter = kUpb_Map_Begin; grpc_gcp_AltsContext_PeerAttributesEntry* peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter); - GPR_ASSERT(peer_attributes_entry != nullptr); + ASSERT_NE(peer_attributes_entry, nullptr); while (peer_attributes_entry != nullptr) { upb_StringView key = grpc_gcp_AltsContext_PeerAttributesEntry_key( const_cast( @@ -358,33 +372,35 @@ static void on_client_next_success_cb(tsi_result status, void* user_data, upb_StringView val = grpc_gcp_AltsContext_PeerAttributesEntry_value( const_cast( peer_attributes_entry)); - GPR_ASSERT(upb_StringView_IsEqual( + ASSERT_TRUE(upb_StringView_IsEqual( key, upb_StringView_FromString( ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY))); - GPR_ASSERT(upb_StringView_IsEqual( + ASSERT_TRUE(upb_StringView_IsEqual( val, upb_StringView_FromString( ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE))); peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter); } /* Validate security level. */ - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL, - peer.properties[4].value.data, - peer.properties[4].value.length) == 0); + ASSERT_EQ( + memcmp(ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL, + peer.properties[4].value.data, peer.properties[4].value.length), + 0); tsi_peer_destruct(&peer); /* Validate unused bytes. */ const unsigned char* bytes = nullptr; size_t bytes_size = 0; - GPR_ASSERT(tsi_handshaker_result_get_unused_bytes(result, &bytes, - &bytes_size) == TSI_OK); - GPR_ASSERT(bytes_size == strlen(ALTS_TSI_HANDSHAKER_TEST_REMAIN_BYTES)); - GPR_ASSERT(memcmp(bytes, ALTS_TSI_HANDSHAKER_TEST_REMAIN_BYTES, bytes_size) == - 0); + ASSERT_EQ(tsi_handshaker_result_get_unused_bytes(result, &bytes, &bytes_size), + TSI_OK); + ASSERT_EQ(bytes_size, strlen(ALTS_TSI_HANDSHAKER_TEST_REMAIN_BYTES)); + ASSERT_EQ(memcmp(bytes, ALTS_TSI_HANDSHAKER_TEST_REMAIN_BYTES, bytes_size), + 0); /* Validate frame protector. */ tsi_frame_protector* protector = nullptr; - GPR_ASSERT(tsi_handshaker_result_create_frame_protector( - result, nullptr, &protector) == TSI_OK); - GPR_ASSERT(protector != nullptr); + ASSERT_EQ( + tsi_handshaker_result_create_frame_protector(result, nullptr, &protector), + TSI_OK); + ASSERT_NE(protector, nullptr); tsi_frame_protector_destroy(protector); tsi_handshaker_result_destroy(result); signal(&tsi_to_caller_notification); @@ -394,58 +410,64 @@ static void on_server_next_success_cb(tsi_result status, void* user_data, const unsigned char* bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result* result) { - GPR_ASSERT(status == TSI_OK); - GPR_ASSERT(user_data == nullptr); - GPR_ASSERT(bytes_to_send_size == 0); - GPR_ASSERT(bytes_to_send == nullptr); - GPR_ASSERT(result != nullptr); + ASSERT_EQ(status, TSI_OK); + ASSERT_EQ(user_data, nullptr); + ASSERT_EQ(bytes_to_send_size, 0); + ASSERT_EQ(bytes_to_send, nullptr); + ASSERT_NE(result, nullptr); // Validate max frame size value after Frame Size Negotiation. The negotiated // frame size value equals minimum send frame size, due to the absence of peer // max frame size. tsi_zero_copy_grpc_protector* zero_copy_protector = nullptr; size_t user_specified_max_frame_size = ALTS_TSI_HANDSHAKER_TEST_MAX_FRAME_SIZE; - GPR_ASSERT(tsi_handshaker_result_create_zero_copy_grpc_protector( - result, &user_specified_max_frame_size, - &zero_copy_protector) == TSI_OK); + ASSERT_EQ(tsi_handshaker_result_create_zero_copy_grpc_protector( + result, &user_specified_max_frame_size, &zero_copy_protector), + TSI_OK); size_t actual_max_frame_size; tsi_zero_copy_grpc_protector_max_frame_size(zero_copy_protector, &actual_max_frame_size); - GPR_ASSERT(actual_max_frame_size == kTsiAltsMinFrameSize); + ASSERT_EQ(actual_max_frame_size, kTsiAltsMinFrameSize); tsi_zero_copy_grpc_protector_destroy(zero_copy_protector); /* Validate peer identity. */ tsi_peer peer; - GPR_ASSERT(tsi_handshaker_result_extract_peer(result, &peer) == TSI_OK); - GPR_ASSERT(peer.property_count == kTsiAltsNumOfPeerProperties); - GPR_ASSERT(memcmp(TSI_ALTS_CERTIFICATE_TYPE, peer.properties[0].value.data, - peer.properties[0].value.length) == 0); - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY, - peer.properties[1].value.data, - peer.properties[1].value.length) == 0); + ASSERT_EQ(tsi_handshaker_result_extract_peer(result, &peer), TSI_OK); + ASSERT_EQ(peer.property_count, kTsiAltsNumOfPeerProperties); + ASSERT_EQ(memcmp(TSI_ALTS_CERTIFICATE_TYPE, peer.properties[0].value.data, + peer.properties[0].value.length), + 0); + ASSERT_EQ( + memcmp(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY, + peer.properties[1].value.data, peer.properties[1].value.length), + 0); /* Validate alts context. */ upb::Arena context_arena; grpc_gcp_AltsContext* ctx = grpc_gcp_AltsContext_parse( peer.properties[3].value.data, peer.properties[3].value.length, context_arena.ptr()); - GPR_ASSERT(ctx != nullptr); + ASSERT_NE(ctx, nullptr); upb_StringView application_protocol = grpc_gcp_AltsContext_application_protocol(ctx); upb_StringView record_protocol = grpc_gcp_AltsContext_record_protocol(ctx); upb_StringView peer_account = grpc_gcp_AltsContext_peer_service_account(ctx); upb_StringView local_account = grpc_gcp_AltsContext_local_service_account(ctx); - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_APPLICATION_PROTOCOL, - application_protocol.data, application_protocol.size) == 0); - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_RECORD_PROTOCOL, - record_protocol.data, record_protocol.size) == 0); - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY, peer_account.data, - peer_account.size) == 0); - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY, local_account.data, - local_account.size) == 0); + ASSERT_EQ(memcmp(ALTS_TSI_HANDSHAKER_TEST_APPLICATION_PROTOCOL, + application_protocol.data, application_protocol.size), + 0); + ASSERT_EQ(memcmp(ALTS_TSI_HANDSHAKER_TEST_RECORD_PROTOCOL, + record_protocol.data, record_protocol.size), + 0); + ASSERT_EQ(memcmp(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY, peer_account.data, + peer_account.size), + 0); + ASSERT_EQ(memcmp(ALTS_TSI_HANDSHAKER_TEST_LOCAL_IDENTITY, local_account.data, + local_account.size), + 0); size_t iter = kUpb_Map_Begin; grpc_gcp_AltsContext_PeerAttributesEntry* peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter); - GPR_ASSERT(peer_attributes_entry != nullptr); + ASSERT_NE(peer_attributes_entry, nullptr); while (peer_attributes_entry != nullptr) { upb_StringView key = grpc_gcp_AltsContext_PeerAttributesEntry_key( const_cast( @@ -453,33 +475,35 @@ static void on_server_next_success_cb(tsi_result status, void* user_data, upb_StringView val = grpc_gcp_AltsContext_PeerAttributesEntry_value( const_cast( peer_attributes_entry)); - GPR_ASSERT(upb_StringView_IsEqual( + ASSERT_TRUE(upb_StringView_IsEqual( key, upb_StringView_FromString( ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_KEY))); - GPR_ASSERT(upb_StringView_IsEqual( + ASSERT_TRUE(upb_StringView_IsEqual( val, upb_StringView_FromString( ALTS_TSI_HANDSHAKER_TEST_PEER_ATTRIBUTES_VALUE))); peer_attributes_entry = grpc_gcp_AltsContext_peer_attributes_nextmutable(ctx, &iter); } /* Check security level. */ - GPR_ASSERT(memcmp(ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL, - peer.properties[4].value.data, - peer.properties[4].value.length) == 0); + ASSERT_EQ( + memcmp(ALTS_TSI_HANDSHAKER_TEST_SECURITY_LEVEL, + peer.properties[4].value.data, peer.properties[4].value.length), + 0); tsi_peer_destruct(&peer); /* Validate unused bytes. */ const unsigned char* bytes = nullptr; size_t bytes_size = 0; - GPR_ASSERT(tsi_handshaker_result_get_unused_bytes(result, &bytes, - &bytes_size) == TSI_OK); - GPR_ASSERT(bytes_size == 0); - GPR_ASSERT(bytes == nullptr); + ASSERT_EQ(tsi_handshaker_result_get_unused_bytes(result, &bytes, &bytes_size), + TSI_OK); + ASSERT_EQ(bytes_size, 0); + ASSERT_EQ(bytes, nullptr); /* Validate frame protector. */ tsi_frame_protector* protector = nullptr; - GPR_ASSERT(tsi_handshaker_result_create_frame_protector( - result, nullptr, &protector) == TSI_OK); - GPR_ASSERT(protector != nullptr); + ASSERT_EQ( + tsi_handshaker_result_create_frame_protector(result, nullptr, &protector), + TSI_OK); + ASSERT_NE(protector, nullptr); tsi_frame_protector_destroy(protector); tsi_handshaker_result_destroy(result); signal(&tsi_to_caller_notification); @@ -514,7 +538,7 @@ static tsi_result mock_server_start(alts_handshaker_client* client, alts_handshaker_client_check_fields_for_testing( client, on_server_start_success_cb, nullptr, true, nullptr); grpc_slice slice = grpc_empty_slice(); - GPR_ASSERT(grpc_slice_cmp(*bytes_received, slice) == 0); + EXPECT_EQ(grpc_slice_cmp(*bytes_received, slice), 0); /* Populate handshaker response for server_start request. */ grpc_byte_buffer** recv_buffer_ptr = alts_handshaker_client_get_recv_buffer_addr_for_testing(client); @@ -539,10 +563,11 @@ static tsi_result mock_next(alts_handshaker_client* client, alts_handshaker_client_set_recv_bytes_for_testing(client, bytes_received); alts_handshaker_client_check_fields_for_testing(client, cb, nullptr, true, bytes_received); - GPR_ASSERT(bytes_received != nullptr); - GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(*bytes_received), - ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, - GRPC_SLICE_LENGTH(*bytes_received)) == 0); + EXPECT_NE(bytes_received, nullptr); + EXPECT_EQ(memcmp(GRPC_SLICE_START_PTR(*bytes_received), + ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, + GRPC_SLICE_LENGTH(*bytes_received)), + 0); /* Populate handshaker response for next request. */ grpc_slice out_frame = grpc_slice_from_static_string(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME); @@ -583,22 +608,24 @@ static void run_tsi_handshaker_destroy_with_exec_ctx( tsi_handshaker_destroy(handshaker); } -static void check_handshaker_next_invalid_input() { +TEST(AltsTsiHandshakerTest, CheckHandshakerNextInvalidInput) { + should_handshaker_client_api_succeed = true; /* Initialization. */ tsi_handshaker* handshaker = create_test_handshaker(true); /* Check nullptr handshaker. */ - GPR_ASSERT(tsi_handshaker_next(nullptr, nullptr, 0, nullptr, nullptr, nullptr, - check_must_not_be_called, - nullptr) == TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_handshaker_next(nullptr, nullptr, 0, nullptr, nullptr, nullptr, + check_must_not_be_called, nullptr), + TSI_INVALID_ARGUMENT); /* Check nullptr callback. */ - GPR_ASSERT(tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, - nullptr, nullptr, - nullptr) == TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, + nullptr, nullptr, nullptr), + TSI_INVALID_ARGUMENT); /* Cleanup. */ run_tsi_handshaker_destroy_with_exec_ctx(handshaker); } -static void check_handshaker_shutdown_invalid_input() { +TEST(AltsTsiHandshakerTest, CheckHandshakerShutdownInvalidInput) { + should_handshaker_client_api_succeed = false; /* Initialization. */ tsi_handshaker* handshaker = create_test_handshaker(true /* is_client */); /* Check nullptr handshaker. */ @@ -617,28 +644,30 @@ static void check_handshaker_next_success() { tsi_handshaker* server_handshaker = create_test_handshaker(false /* is_client */); /* Client start. */ - GPR_ASSERT(tsi_handshaker_next(client_handshaker, nullptr, 0, nullptr, - nullptr, nullptr, on_client_start_success_cb, - nullptr) == TSI_ASYNC); + ASSERT_EQ(tsi_handshaker_next(client_handshaker, nullptr, 0, nullptr, nullptr, + nullptr, on_client_start_success_cb, nullptr), + TSI_ASYNC); wait(&tsi_to_caller_notification); /* Client next. */ - GPR_ASSERT(tsi_handshaker_next( - client_handshaker, - (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, - strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr, - nullptr, on_client_next_success_cb, nullptr) == TSI_ASYNC); + ASSERT_EQ(tsi_handshaker_next( + client_handshaker, + (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, + strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr, + nullptr, on_client_next_success_cb, nullptr), + TSI_ASYNC); wait(&tsi_to_caller_notification); /* Server start. */ - GPR_ASSERT(tsi_handshaker_next(server_handshaker, nullptr, 0, nullptr, - nullptr, nullptr, on_server_start_success_cb, - nullptr) == TSI_ASYNC); + ASSERT_EQ(tsi_handshaker_next(server_handshaker, nullptr, 0, nullptr, nullptr, + nullptr, on_server_start_success_cb, nullptr), + TSI_ASYNC); wait(&tsi_to_caller_notification); /* Server next. */ - GPR_ASSERT(tsi_handshaker_next( - server_handshaker, - (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, - strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr, - nullptr, on_server_next_success_cb, nullptr) == TSI_ASYNC); + ASSERT_EQ(tsi_handshaker_next( + server_handshaker, + (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, + strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr, + nullptr, on_server_next_success_cb, nullptr), + TSI_ASYNC); wait(&tsi_to_caller_notification); /* Cleanup. */ run_tsi_handshaker_destroy_with_exec_ctx(server_handshaker); @@ -648,17 +677,17 @@ static void check_handshaker_next_success() { static void check_handshaker_next_with_shutdown() { tsi_handshaker* handshaker = create_test_handshaker(true /* is_client*/); /* next(success) -- shutdown(success) -- next (fail) */ - GPR_ASSERT(tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, - nullptr, on_client_start_success_cb, - nullptr) == TSI_ASYNC); + ASSERT_EQ(tsi_handshaker_next(handshaker, nullptr, 0, nullptr, nullptr, + nullptr, on_client_start_success_cb, nullptr), + TSI_ASYNC); wait(&tsi_to_caller_notification); tsi_handshaker_shutdown(handshaker); - GPR_ASSERT(tsi_handshaker_next( - handshaker, - (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, - strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr, - nullptr, on_client_next_success_cb, - nullptr) == TSI_HANDSHAKE_SHUTDOWN); + ASSERT_EQ( + tsi_handshaker_next( + handshaker, (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, + strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr, + nullptr, on_client_next_success_cb, nullptr), + TSI_HANDSHAKE_SHUTDOWN); /* Cleanup. */ run_tsi_handshaker_destroy_with_exec_ctx(handshaker); } @@ -668,7 +697,8 @@ static void check_handle_response_with_shutdown(void* /*unused*/) { alts_handshaker_client_handle_response(cb_event, true /* is_ok */); } -static void check_handshaker_next_failure() { +TEST(AltsTsiHandshakerTest, CheckHandshakerNextFailure) { + should_handshaker_client_api_succeed = false; /** * Create handshakers for which internal mock client is always going to fail. */ @@ -677,27 +707,27 @@ static void check_handshaker_next_failure() { tsi_handshaker* server_handshaker = create_test_handshaker(false /* is_client */); /* Client start. */ - GPR_ASSERT(tsi_handshaker_next(client_handshaker, nullptr, 0, nullptr, - nullptr, nullptr, check_must_not_be_called, - nullptr) == TSI_INTERNAL_ERROR); + ASSERT_EQ(tsi_handshaker_next(client_handshaker, nullptr, 0, nullptr, nullptr, + nullptr, check_must_not_be_called, nullptr), + TSI_INTERNAL_ERROR); /* Server start. */ - GPR_ASSERT(tsi_handshaker_next(server_handshaker, nullptr, 0, nullptr, - nullptr, nullptr, check_must_not_be_called, - nullptr) == TSI_INTERNAL_ERROR); + ASSERT_EQ(tsi_handshaker_next(server_handshaker, nullptr, 0, nullptr, nullptr, + nullptr, check_must_not_be_called, nullptr), + TSI_INTERNAL_ERROR); /* Server next. */ - GPR_ASSERT(tsi_handshaker_next( - server_handshaker, - (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, - strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr, - nullptr, check_must_not_be_called, - nullptr) == TSI_INTERNAL_ERROR); + ASSERT_EQ(tsi_handshaker_next( + server_handshaker, + (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, + strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr, + nullptr, check_must_not_be_called, nullptr), + TSI_INTERNAL_ERROR); /* Client next. */ - GPR_ASSERT(tsi_handshaker_next( - client_handshaker, - (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, - strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr, - nullptr, check_must_not_be_called, - nullptr) == TSI_INTERNAL_ERROR); + ASSERT_EQ(tsi_handshaker_next( + client_handshaker, + (const unsigned char*)ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES, + strlen(ALTS_TSI_HANDSHAKER_TEST_RECV_BYTES), nullptr, nullptr, + nullptr, check_must_not_be_called, nullptr), + TSI_INTERNAL_ERROR); /* Cleanup. */ run_tsi_handshaker_destroy_with_exec_ctx(server_handshaker); run_tsi_handshaker_destroy_with_exec_ctx(client_handshaker); @@ -707,25 +737,26 @@ static void on_invalid_input_cb(tsi_result status, void* user_data, const unsigned char* bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result* result) { - GPR_ASSERT(status == TSI_INTERNAL_ERROR); - GPR_ASSERT(user_data == nullptr); - GPR_ASSERT(bytes_to_send == nullptr); - GPR_ASSERT(bytes_to_send_size == 0); - GPR_ASSERT(result == nullptr); + ASSERT_EQ(status, TSI_INTERNAL_ERROR); + ASSERT_EQ(user_data, nullptr); + ASSERT_EQ(bytes_to_send, nullptr); + ASSERT_EQ(bytes_to_send_size, 0); + ASSERT_EQ(result, nullptr); } static void on_failed_grpc_call_cb(tsi_result status, void* user_data, const unsigned char* bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result* result) { - GPR_ASSERT(status == TSI_INTERNAL_ERROR); - GPR_ASSERT(user_data == nullptr); - GPR_ASSERT(bytes_to_send == nullptr); - GPR_ASSERT(bytes_to_send_size == 0); - GPR_ASSERT(result == nullptr); + ASSERT_EQ(status, TSI_INTERNAL_ERROR); + ASSERT_EQ(user_data, nullptr); + ASSERT_EQ(bytes_to_send, nullptr); + ASSERT_EQ(bytes_to_send_size, 0); + ASSERT_EQ(result, nullptr); } -static void check_handle_response_nullptr_handshaker() { +TEST(AltsTsiHandshakerTest, CheckHandleResponseNullptrHandshaker) { + should_handshaker_client_api_succeed = false; /* Initialization. */ notification_init(&caller_to_tsi_notification); notification_init(&tsi_to_caller_notification); @@ -764,7 +795,8 @@ static void check_handle_response_nullptr_handshaker() { notification_destroy(&tsi_to_caller_notification); } -static void check_handle_response_nullptr_recv_bytes() { +TEST(AltsTsiHandshakerTest, CheckHandleResponseNullptrRecvBytes) { + should_handshaker_client_api_succeed = false; /* Initialization. */ notification_init(&caller_to_tsi_notification); notification_init(&tsi_to_caller_notification); @@ -796,7 +828,9 @@ static void check_handle_response_nullptr_recv_bytes() { notification_destroy(&tsi_to_caller_notification); } -static void check_handle_response_failed_grpc_call_to_handshaker_service() { +TEST(AltsTsiHandshakerTest, + CheckHandleResponseFailedGrpcCallToHandshakerService) { + should_handshaker_client_api_succeed = false; /* Initialization. */ notification_init(&caller_to_tsi_notification); notification_init(&tsi_to_caller_notification); @@ -831,8 +865,9 @@ static void check_handle_response_failed_grpc_call_to_handshaker_service() { notification_destroy(&tsi_to_caller_notification); } -static void -check_handle_response_failed_recv_message_from_handshaker_service() { +TEST(AltsTsiHandshakerTest, + CheckHandleResponseFailedRecvMessageFromHandshakerService) { + should_handshaker_client_api_succeed = false; /* Initialization. */ notification_init(&caller_to_tsi_notification); notification_init(&tsi_to_caller_notification); @@ -871,14 +906,15 @@ static void on_invalid_resp_cb(tsi_result status, void* user_data, const unsigned char* bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result* result) { - GPR_ASSERT(status == TSI_DATA_CORRUPTED); - GPR_ASSERT(user_data == nullptr); - GPR_ASSERT(bytes_to_send == nullptr); - GPR_ASSERT(bytes_to_send_size == 0); - GPR_ASSERT(result == nullptr); + ASSERT_EQ(status, TSI_DATA_CORRUPTED); + ASSERT_EQ(user_data, nullptr); + ASSERT_EQ(bytes_to_send, nullptr); + ASSERT_EQ(bytes_to_send_size, 0); + ASSERT_EQ(result, nullptr); } -static void check_handle_response_invalid_resp() { +TEST(AltsTsiHandshakerTest, CheckHandleResponseInvalidResp) { + should_handshaker_client_api_succeed = false; /* Initialization. */ notification_init(&caller_to_tsi_notification); notification_init(&tsi_to_caller_notification); @@ -942,14 +978,15 @@ static void on_failed_resp_cb(tsi_result status, void* user_data, const unsigned char* bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result* result) { - GPR_ASSERT(status == TSI_INVALID_ARGUMENT); - GPR_ASSERT(user_data == nullptr); - GPR_ASSERT(bytes_to_send == nullptr); - GPR_ASSERT(bytes_to_send_size == 0); - GPR_ASSERT(result == nullptr); + ASSERT_EQ(status, TSI_INVALID_ARGUMENT); + ASSERT_EQ(user_data, nullptr); + ASSERT_EQ(bytes_to_send, nullptr); + ASSERT_EQ(bytes_to_send_size, 0); + ASSERT_EQ(result, nullptr); } -static void check_handle_response_failure() { +TEST(AltsTsiHandshakerTest, CheckHandleResponseFailure) { + should_handshaker_client_api_succeed = false; /* Initialization. */ notification_init(&caller_to_tsi_notification); notification_init(&tsi_to_caller_notification); @@ -986,14 +1023,15 @@ static void on_shutdown_resp_cb(tsi_result status, void* user_data, const unsigned char* bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result* result) { - GPR_ASSERT(status == TSI_HANDSHAKE_SHUTDOWN); - GPR_ASSERT(user_data == nullptr); - GPR_ASSERT(bytes_to_send == nullptr); - GPR_ASSERT(bytes_to_send_size == 0); - GPR_ASSERT(result == nullptr); + ASSERT_EQ(status, TSI_HANDSHAKE_SHUTDOWN); + ASSERT_EQ(user_data, nullptr); + ASSERT_EQ(bytes_to_send, nullptr); + ASSERT_EQ(bytes_to_send_size, 0); + ASSERT_EQ(result, nullptr); } -static void check_handle_response_after_shutdown() { +TEST(AltsTsiHandshakerTest, CheckHandleResponseAfterShutdown) { + should_handshaker_client_api_succeed = true; /* Initialization. */ notification_init(&caller_to_tsi_notification); notification_init(&tsi_to_caller_notification); @@ -1027,7 +1065,8 @@ static void check_handle_response_after_shutdown() { notification_destroy(&tsi_to_caller_notification); } -void check_handshaker_next_fails_after_shutdown() { +TEST(AltsTsiHandshakerTest, CheckHandshakerNextFailsAfterShutdown) { + should_handshaker_client_api_succeed = true; /* Initialization. */ notification_init(&caller_to_tsi_notification); notification_init(&tsi_to_caller_notification); @@ -1043,7 +1082,8 @@ void check_handshaker_next_fails_after_shutdown() { notification_destroy(&tsi_to_caller_notification); } -void check_handshaker_success() { +TEST(AltsTsiHandshakerTest, CheckHandshakerSuccess) { + should_handshaker_client_api_succeed = true; /* Initialization. */ notification_init(&caller_to_tsi_notification); notification_init(&tsi_to_caller_notification); @@ -1060,26 +1100,10 @@ void check_handshaker_success() { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); - /* Initialization. */ - grpc_init(); + ::testing::InitGoogleTest(&argc, argv); + grpc::testing::TestGrpcScope grpc_scope; grpc_alts_shared_resource_dedicated_init(); - /* Tests. */ - should_handshaker_client_api_succeed = true; - check_handshaker_success(); - check_handshaker_next_invalid_input(); - check_handshaker_next_fails_after_shutdown(); - check_handle_response_after_shutdown(); - should_handshaker_client_api_succeed = false; - check_handshaker_shutdown_invalid_input(); - check_handshaker_next_failure(); - check_handle_response_nullptr_handshaker(); - check_handle_response_nullptr_recv_bytes(); - check_handle_response_failed_grpc_call_to_handshaker_service(); - check_handle_response_failed_recv_message_from_handshaker_service(); - check_handle_response_invalid_resp(); - check_handle_response_failure(); - /* Cleanup. */ + int ret = RUN_ALL_TESTS(); grpc_alts_shared_resource_dedicated_shutdown(); - grpc_shutdown(); - return 0; + return ret; } diff --git a/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc b/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc index 9c24f82c750..079f9370366 100644 --- a/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc +++ b/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc @@ -18,6 +18,8 @@ #include "src/core/tsi/alts/handshaker/alts_tsi_utils.h" +#include + #include "upb/upb.hpp" #include "test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h" @@ -25,21 +27,21 @@ #define ALTS_TSI_UTILS_TEST_OUT_FRAME "Hello Google" -static void convert_to_tsi_result_test() { - GPR_ASSERT(alts_tsi_utils_convert_to_tsi_result(GRPC_STATUS_OK) == TSI_OK); - GPR_ASSERT(alts_tsi_utils_convert_to_tsi_result(GRPC_STATUS_UNKNOWN) == - TSI_UNKNOWN_ERROR); - GPR_ASSERT(alts_tsi_utils_convert_to_tsi_result( - GRPC_STATUS_INVALID_ARGUMENT) == TSI_INVALID_ARGUMENT); - GPR_ASSERT(alts_tsi_utils_convert_to_tsi_result(GRPC_STATUS_OUT_OF_RANGE) == - TSI_UNKNOWN_ERROR); - GPR_ASSERT(alts_tsi_utils_convert_to_tsi_result(GRPC_STATUS_INTERNAL) == - TSI_INTERNAL_ERROR); - GPR_ASSERT(alts_tsi_utils_convert_to_tsi_result(GRPC_STATUS_NOT_FOUND) == - TSI_NOT_FOUND); +TEST(AltsTsiUtilsTest, ConvertToTsiResultTest) { + ASSERT_EQ(alts_tsi_utils_convert_to_tsi_result(GRPC_STATUS_OK), TSI_OK); + ASSERT_EQ(alts_tsi_utils_convert_to_tsi_result(GRPC_STATUS_UNKNOWN), + TSI_UNKNOWN_ERROR); + ASSERT_EQ(alts_tsi_utils_convert_to_tsi_result(GRPC_STATUS_INVALID_ARGUMENT), + TSI_INVALID_ARGUMENT); + ASSERT_EQ(alts_tsi_utils_convert_to_tsi_result(GRPC_STATUS_OUT_OF_RANGE), + TSI_UNKNOWN_ERROR); + ASSERT_EQ(alts_tsi_utils_convert_to_tsi_result(GRPC_STATUS_INTERNAL), + TSI_INTERNAL_ERROR); + ASSERT_EQ(alts_tsi_utils_convert_to_tsi_result(GRPC_STATUS_NOT_FOUND), + TSI_NOT_FOUND); } -static void deserialize_response_test() { +TEST(AltsTsiUtilsTest, DeserializeResponseTest) { upb::Arena arena; grpc_gcp_HandshakerResp* resp = grpc_gcp_HandshakerResp_new(arena.ptr()); grpc_gcp_HandshakerResp_set_out_frames( @@ -54,15 +56,14 @@ static void deserialize_response_test() { grpc_raw_byte_buffer_create(&slice, 1 /* number of slices */); grpc_gcp_HandshakerResp* decoded_resp = alts_tsi_utils_deserialize_response(buffer, arena2.ptr()); - GPR_ASSERT(grpc_gcp_handshaker_resp_equals(resp, decoded_resp)); + ASSERT_TRUE(grpc_gcp_handshaker_resp_equals(resp, decoded_resp)); grpc_byte_buffer_destroy(buffer); /* Invalid serialization. */ grpc_slice bad_slice = grpc_slice_split_head(&slice, GRPC_SLICE_LENGTH(slice) - 1); buffer = grpc_raw_byte_buffer_create(&bad_slice, 1 /* number of slices */); - GPR_ASSERT(alts_tsi_utils_deserialize_response(buffer, arena2.ptr()) == - nullptr); + ASSERT_EQ(alts_tsi_utils_deserialize_response(buffer, arena2.ptr()), nullptr); /* Clean up. */ grpc_slice_unref(slice); @@ -72,10 +73,7 @@ static void deserialize_response_test() { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); - /* Tests. */ - grpc_init(); - deserialize_response_test(); - convert_to_tsi_result_test(); - grpc_shutdown(); - return 0; + ::testing::InitGoogleTest(&argc, argv); + grpc::testing::TestGrpcScope grpc_scope; + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/alts/handshaker/transport_security_common_api_test.cc b/test/core/tsi/alts/handshaker/transport_security_common_api_test.cc index 7579ed1014d..e5c2478edfb 100644 --- a/test/core/tsi/alts/handshaker/transport_security_common_api_test.cc +++ b/test/core/tsi/alts/handshaker/transport_security_common_api_test.cc @@ -22,6 +22,8 @@ #include #include +#include + const size_t kMaxRpcVersionMajor = 3; const size_t kMaxRpcVersionMinor = 2; const size_t kMinRpcVersionMajor = 2; @@ -30,7 +32,7 @@ const size_t kMinRpcVersionMinor = 1; static bool grpc_gcp_rpc_protocol_versions_equal( grpc_gcp_rpc_protocol_versions* l_versions, grpc_gcp_rpc_protocol_versions* r_versions) { - GPR_ASSERT(l_versions != nullptr && r_versions != nullptr); + EXPECT_TRUE(l_versions != nullptr && r_versions != nullptr); if ((l_versions->max_rpc_version.major != r_versions->max_rpc_version.major) || (l_versions->max_rpc_version.minor != @@ -46,121 +48,121 @@ static bool grpc_gcp_rpc_protocol_versions_equal( return true; } -static void test_success() { +TEST(TransportSecurityCommonApiTest, TestSuccess) { grpc_gcp_rpc_protocol_versions version; grpc_gcp_rpc_protocol_versions decoded_version; - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_max( + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_max( &version, kMaxRpcVersionMajor, kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min( + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_min( &version, kMinRpcVersionMajor, kMinRpcVersionMinor)); /* Serializes to grpc slice. */ grpc_slice encoded_slice; - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_encode(&version, &encoded_slice)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_encode(&version, &encoded_slice)); /* Deserializes and compares with the original version. */ - GPR_ASSERT( + ASSERT_TRUE( grpc_gcp_rpc_protocol_versions_decode(encoded_slice, &decoded_version)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_equal(&version, &decoded_version)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_equal(&version, &decoded_version)); grpc_slice_unref(encoded_slice); } -static void test_failure() { +TEST(TransportSecurityCommonApiTest, TestFailure) { grpc_gcp_rpc_protocol_versions version, decoded_version; grpc_slice encoded_slice; /* Test for invalid arguments. */ - GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_set_max( + ASSERT_FALSE(grpc_gcp_rpc_protocol_versions_set_max( nullptr, kMaxRpcVersionMajor, kMaxRpcVersionMinor)); - GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_set_min( + ASSERT_FALSE(grpc_gcp_rpc_protocol_versions_set_min( nullptr, kMinRpcVersionMajor, kMinRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_max( + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_max( &version, kMaxRpcVersionMajor, kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min( + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_min( &version, kMinRpcVersionMajor, kMinRpcVersionMinor)); - GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_encode(nullptr, &encoded_slice)); - GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_encode(&version, nullptr)); - GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_decode(encoded_slice, nullptr)); + ASSERT_FALSE(grpc_gcp_rpc_protocol_versions_encode(nullptr, &encoded_slice)); + ASSERT_FALSE(grpc_gcp_rpc_protocol_versions_encode(&version, nullptr)); + ASSERT_FALSE(grpc_gcp_rpc_protocol_versions_decode(encoded_slice, nullptr)); /* Test for upb decode. */ - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_encode(&version, &encoded_slice)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_encode(&version, &encoded_slice)); grpc_slice bad_slice = grpc_slice_split_head( &encoded_slice, GRPC_SLICE_LENGTH(encoded_slice) - 1); grpc_slice_unref(encoded_slice); - GPR_ASSERT( + ASSERT_TRUE( !grpc_gcp_rpc_protocol_versions_decode(bad_slice, &decoded_version)); grpc_slice_unref(bad_slice); } -static void test_copy() { +TEST(TransportSecurityCommonApiTest, TestCopy) { grpc_gcp_rpc_protocol_versions src; grpc_gcp_rpc_protocol_versions des; - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_max(&src, kMaxRpcVersionMajor, - kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min(&src, kMinRpcVersionMajor, - kMinRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_copy(&src, &des)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_equal(&src, &des)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_max(&src, kMaxRpcVersionMajor, + kMaxRpcVersionMinor)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_min(&src, kMinRpcVersionMajor, + kMinRpcVersionMinor)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_copy(&src, &des)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_equal(&src, &des)); } -static void test_check_success() { +TEST(TransportSecurityCommonApiTest, TestCheckSuccess) { grpc_gcp_rpc_protocol_versions v1; grpc_gcp_rpc_protocol_versions v2; grpc_gcp_rpc_protocol_versions_version highest_common_version; /* test equality. */ - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_max(&v1, kMaxRpcVersionMajor, - kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min(&v1, kMaxRpcVersionMajor, - kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_max(&v2, kMaxRpcVersionMajor, - kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min(&v2, kMaxRpcVersionMajor, - kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_check( - (const grpc_gcp_rpc_protocol_versions*)&v1, - (const grpc_gcp_rpc_protocol_versions*)&v2, - &highest_common_version) == 1); - GPR_ASSERT(grpc_core::internal::grpc_gcp_rpc_protocol_version_compare( - &highest_common_version, &v1.max_rpc_version) == 0); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_max(&v1, kMaxRpcVersionMajor, + kMaxRpcVersionMinor)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_min(&v1, kMaxRpcVersionMajor, + kMaxRpcVersionMinor)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_max(&v2, kMaxRpcVersionMajor, + kMaxRpcVersionMinor)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_min(&v2, kMaxRpcVersionMajor, + kMaxRpcVersionMinor)); + ASSERT_EQ( + grpc_gcp_rpc_protocol_versions_check( + (const grpc_gcp_rpc_protocol_versions*)&v1, + (const grpc_gcp_rpc_protocol_versions*)&v2, &highest_common_version), + 1); + ASSERT_EQ(grpc_core::internal::grpc_gcp_rpc_protocol_version_compare( + &highest_common_version, &v1.max_rpc_version), + 0); /* test inequality. */ - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_max(&v1, kMaxRpcVersionMajor, - kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min(&v1, kMinRpcVersionMinor, - kMinRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_max(&v2, kMaxRpcVersionMajor, - kMinRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min(&v2, kMinRpcVersionMajor, - kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_check( - (const grpc_gcp_rpc_protocol_versions*)&v1, - (const grpc_gcp_rpc_protocol_versions*)&v2, - &highest_common_version) == 1); - GPR_ASSERT(grpc_core::internal::grpc_gcp_rpc_protocol_version_compare( - &highest_common_version, &v2.max_rpc_version) == 0); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_max(&v1, kMaxRpcVersionMajor, + kMaxRpcVersionMinor)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_min(&v1, kMinRpcVersionMinor, + kMinRpcVersionMinor)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_max(&v2, kMaxRpcVersionMajor, + kMinRpcVersionMinor)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_min(&v2, kMinRpcVersionMajor, + kMaxRpcVersionMinor)); + ASSERT_EQ( + grpc_gcp_rpc_protocol_versions_check( + (const grpc_gcp_rpc_protocol_versions*)&v1, + (const grpc_gcp_rpc_protocol_versions*)&v2, &highest_common_version), + 1); + ASSERT_EQ(grpc_core::internal::grpc_gcp_rpc_protocol_version_compare( + &highest_common_version, &v2.max_rpc_version), + 0); } -static void test_check_failure() { +TEST(TransportSecurityCommonApiTest, TestCheckFailure) { grpc_gcp_rpc_protocol_versions v1; grpc_gcp_rpc_protocol_versions v2; grpc_gcp_rpc_protocol_versions_version highest_common_version; - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_max(&v1, kMinRpcVersionMajor, - kMinRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min(&v1, kMinRpcVersionMajor, - kMinRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_max(&v2, kMaxRpcVersionMajor, - kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min(&v2, kMaxRpcVersionMajor, - kMaxRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_check( - (const grpc_gcp_rpc_protocol_versions*)&v1, - (const grpc_gcp_rpc_protocol_versions*)&v2, - &highest_common_version) == 0); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_max(&v1, kMinRpcVersionMajor, + kMinRpcVersionMinor)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_min(&v1, kMinRpcVersionMajor, + kMinRpcVersionMinor)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_max(&v2, kMaxRpcVersionMajor, + kMaxRpcVersionMinor)); + ASSERT_TRUE(grpc_gcp_rpc_protocol_versions_set_min(&v2, kMaxRpcVersionMajor, + kMaxRpcVersionMinor)); + ASSERT_EQ( + grpc_gcp_rpc_protocol_versions_check( + (const grpc_gcp_rpc_protocol_versions*)&v1, + (const grpc_gcp_rpc_protocol_versions*)&v2, &highest_common_version), + 0); } -int main(int /*argc*/, char** /*argv*/) { - /* Run tests. */ - test_success(); - test_failure(); - test_copy(); - test_check_success(); - test_check_failure(); - return 0; +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/alts/zero_copy_frame_protector/BUILD b/test/core/tsi/alts/zero_copy_frame_protector/BUILD index 2a5363bb0a7..9afcd89ce42 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/BUILD +++ b/test/core/tsi/alts/zero_copy_frame_protector/BUILD @@ -21,6 +21,7 @@ grpc_package(name = "test/core/tsi/alts/zero_copy_frame_protector") grpc_cc_test( name = "alts_grpc_record_protocol_test", srcs = ["alts_grpc_record_protocol_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ "//:gpr", @@ -34,6 +35,7 @@ grpc_cc_test( grpc_cc_test( name = "alts_iovec_record_protocol_test", srcs = ["alts_iovec_record_protocol_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ "//:gpr", @@ -46,6 +48,7 @@ grpc_cc_test( grpc_cc_test( name = "alts_zero_copy_grpc_protector_test", srcs = ["alts_zero_copy_grpc_protector_test.cc"], + external_deps = ["gtest"], language = "C++", deps = [ "//:gpr", diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc index 2b6812b9bfa..44d525f0d3c 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc @@ -18,6 +18,8 @@ #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h" +#include + #include #include @@ -55,7 +57,7 @@ struct alts_grpc_record_protocol_test_var { /* --- Test utility functions. --- */ static void create_random_slice_buffer(grpc_slice_buffer* sb) { - GPR_ASSERT(sb != nullptr); + ASSERT_NE(sb, nullptr); size_t slice_count = gsec_test_bias_random_uint32(kMaxSlices) + 1; for (size_t i = 0; i < slice_count; i++) { size_t slice_length = gsec_test_bias_random_uint32(kMaxSliceLength) + 1; @@ -66,8 +68,8 @@ static void create_random_slice_buffer(grpc_slice_buffer* sb) { } static uint8_t* pointer_to_nth_byte(grpc_slice_buffer* sb, size_t index) { - GPR_ASSERT(sb != nullptr); - GPR_ASSERT(index < sb->length); + EXPECT_NE(sb, nullptr); + EXPECT_LT(index, sb->length); for (size_t i = 0; i < sb->count; i++) { if (index < GRPC_SLICE_LENGTH(sb->slices[i])) { return GRPC_SLICE_START_PTR(sb->slices[i]) + index; @@ -82,16 +84,16 @@ static uint8_t* pointer_to_nth_byte(grpc_slice_buffer* sb, size_t index) { * but OK for testing. */ static bool are_slice_buffers_equal(grpc_slice_buffer* first, grpc_slice_buffer* second) { - GPR_ASSERT(first != nullptr); - GPR_ASSERT(second != nullptr); + EXPECT_NE(first, nullptr); + EXPECT_NE(second, nullptr); if (first->length != second->length) { return false; } for (size_t i = 0; i < first->length; i++) { uint8_t* first_ptr = pointer_to_nth_byte(first, i); uint8_t* second_ptr = pointer_to_nth_byte(second, i); - GPR_ASSERT(first_ptr != nullptr); - GPR_ASSERT(second_ptr != nullptr); + EXPECT_NE(first_ptr, nullptr); + EXPECT_NE(second_ptr, nullptr); if ((*first_ptr) != (*second_ptr)) { return false; } @@ -100,7 +102,7 @@ static bool are_slice_buffers_equal(grpc_slice_buffer* first, } static void alter_random_byte(grpc_slice_buffer* sb) { - GPR_ASSERT(sb != nullptr); + ASSERT_NE(sb, nullptr); if (sb->length == 0) { return; } @@ -121,33 +123,41 @@ test_fixture_integrity_only_create(bool rekey, bool extra_copy) { gsec_aead_crypter* crypter = nullptr; /* Create client record protocol for protect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_grpc_integrity_only_record_protocol_create( - crypter, 8, /*is_client=*/true, /*is_protect=*/true, - extra_copy, &fixture->client_protect) == TSI_OK); + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_grpc_integrity_only_record_protocol_create( + crypter, 8, /*is_client=*/true, /*is_protect=*/true, extra_copy, + &fixture->client_protect), + TSI_OK); /* Create client record protocol for unprotect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_grpc_integrity_only_record_protocol_create( - crypter, 8, /*is_client=*/true, /*is_protect=*/false, - extra_copy, &fixture->client_unprotect) == TSI_OK); + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_grpc_integrity_only_record_protocol_create( + crypter, 8, /*is_client=*/true, /*is_protect=*/false, + extra_copy, &fixture->client_unprotect), + TSI_OK); /* Create server record protocol for protect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_grpc_integrity_only_record_protocol_create( - crypter, 8, /*is_client=*/false, /*is_protect=*/true, - extra_copy, &fixture->server_protect) == TSI_OK); + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_grpc_integrity_only_record_protocol_create( + crypter, 8, /*is_client=*/false, /*is_protect=*/true, + extra_copy, &fixture->server_protect), + TSI_OK); /* Create server record protocol for unprotect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_grpc_integrity_only_record_protocol_create( - crypter, 8, /*is_client=*/false, /*is_protect=*/false, - extra_copy, &fixture->server_unprotect) == TSI_OK); + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_grpc_integrity_only_record_protocol_create( + crypter, 8, /*is_client=*/false, /*is_protect=*/false, + extra_copy, &fixture->server_unprotect), + TSI_OK); gpr_free(key); return fixture; @@ -179,34 +189,41 @@ test_fixture_privacy_integrity_create(bool rekey) { gsec_aead_crypter* crypter = nullptr; /* Create client record protocol for protect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_grpc_privacy_integrity_record_protocol_create( - crypter, 8, /*is_client=*/true, /*is_protect=*/true, - &fixture->client_protect) == TSI_OK); + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_grpc_privacy_integrity_record_protocol_create( + crypter, 8, /*is_client=*/true, /*is_protect=*/true, + &fixture->client_protect), + TSI_OK); /* Create client record protocol for unprotect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_grpc_privacy_integrity_record_protocol_create( - crypter, 8, /*is_client=*/true, /*is_protect=*/false, - &fixture->client_unprotect) == TSI_OK); + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_grpc_privacy_integrity_record_protocol_create( + crypter, 8, /*is_client=*/true, /*is_protect=*/false, + &fixture->client_unprotect), + TSI_OK); /* Create server record protocol for protect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_grpc_privacy_integrity_record_protocol_create( - crypter, 8, /*is_client=*/false, /*is_protect=*/true, - &fixture->server_protect) == TSI_OK); + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_grpc_privacy_integrity_record_protocol_create( + crypter, 8, /*is_client=*/false, /*is_protect=*/true, + &fixture->server_protect), + TSI_OK); /* Create server record protocol for unprotect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_grpc_privacy_integrity_record_protocol_create( - crypter, 8, /*is_client=*/false, /*is_protect=*/false, - &fixture->server_unprotect) == TSI_OK); - + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_grpc_privacy_integrity_record_protocol_create( + crypter, 8, /*is_client=*/false, /*is_protect=*/false, + &fixture->server_unprotect), + TSI_OK); gpr_free(key); return fixture; } @@ -280,13 +297,13 @@ static void random_seal_unseal(alts_grpc_record_protocol* sender, size_t data_length = var->original_sb.length; tsi_result status = alts_grpc_record_protocol_protect( sender, &var->original_sb, &var->protected_sb); - GPR_ASSERT(status == TSI_OK); - GPR_ASSERT(var->protected_sb.length == - data_length + var->header_length + var->tag_length); + ASSERT_EQ(status, TSI_OK); + ASSERT_EQ(var->protected_sb.length, + data_length + var->header_length + var->tag_length); status = alts_grpc_record_protocol_unprotect(receiver, &var->protected_sb, &var->unprotected_sb); - GPR_ASSERT(status == TSI_OK); - GPR_ASSERT( + ASSERT_EQ(status, TSI_OK); + ASSERT_TRUE( are_slice_buffers_equal(&var->unprotected_sb, &var->duplicate_sb)); alts_grpc_record_protocol_test_var_destroy(var); } @@ -304,13 +321,12 @@ static void empty_seal_unseal(alts_grpc_record_protocol* sender, grpc_slice_buffer_reset_and_unref_internal(&var->duplicate_sb); tsi_result status = alts_grpc_record_protocol_protect( sender, &var->original_sb, &var->protected_sb); - GPR_ASSERT(status == TSI_OK); - GPR_ASSERT(var->protected_sb.length == - var->header_length + var->tag_length); + ASSERT_EQ(status, TSI_OK); + ASSERT_EQ(var->protected_sb.length, var->header_length + var->tag_length); status = alts_grpc_record_protocol_unprotect(receiver, &var->protected_sb, &var->unprotected_sb); - GPR_ASSERT(status == TSI_OK); - GPR_ASSERT( + ASSERT_EQ(status, TSI_OK); + ASSERT_TRUE( are_slice_buffers_equal(&var->unprotected_sb, &var->duplicate_sb)); alts_grpc_record_protocol_test_var_destroy(var); } @@ -326,16 +342,16 @@ static void unsync_seal_unseal(alts_grpc_record_protocol* sender, /* Seals once. */ status = alts_grpc_record_protocol_protect(sender, &var->original_sb, &var->protected_sb); - GPR_ASSERT(status == TSI_OK); + ASSERT_EQ(status, TSI_OK); grpc_slice_buffer_reset_and_unref_internal(&var->protected_sb); /* Seals again. */ status = alts_grpc_record_protocol_protect(sender, &var->duplicate_sb, &var->protected_sb); - GPR_ASSERT(status == TSI_OK); + ASSERT_EQ(status, TSI_OK); /* Unseals the second frame. */ status = alts_grpc_record_protocol_unprotect(receiver, &var->protected_sb, &var->unprotected_sb); - GPR_ASSERT(status == TSI_INTERNAL_ERROR); + ASSERT_EQ(status, TSI_INTERNAL_ERROR); alts_grpc_record_protocol_test_var_destroy(var); grpc_core::ExecCtx::Get()->Flush(); } @@ -349,12 +365,12 @@ static void corrupted_data(alts_grpc_record_protocol* sender, /* Seals once. */ status = alts_grpc_record_protocol_protect(sender, &var->original_sb, &var->protected_sb); - GPR_ASSERT(status == TSI_OK); + ASSERT_EQ(status, TSI_OK); /* Corrupts one byte in protected_sb and tries to unprotect. */ alter_random_byte(&var->protected_sb); status = alts_grpc_record_protocol_unprotect(receiver, &var->protected_sb, &var->unprotected_sb); - GPR_ASSERT(status == TSI_INTERNAL_ERROR); + ASSERT_EQ(status, TSI_INTERNAL_ERROR); alts_grpc_record_protocol_test_var_destroy(var); grpc_core::ExecCtx::Get()->Flush(); } @@ -366,18 +382,18 @@ static void input_check(alts_grpc_record_protocol* rp) { alts_grpc_record_protocol_test_var_create(); /* Protects with nullptr input. */ status = alts_grpc_record_protocol_protect(rp, nullptr, &var->protected_sb); - GPR_ASSERT(status == TSI_INVALID_ARGUMENT); + ASSERT_EQ(status, TSI_INVALID_ARGUMENT); status = alts_grpc_record_protocol_protect(rp, &var->original_sb, nullptr); - GPR_ASSERT(status == TSI_INVALID_ARGUMENT); + ASSERT_EQ(status, TSI_INVALID_ARGUMENT); /* Unprotects with nullptr input. */ status = alts_grpc_record_protocol_protect(rp, &var->original_sb, &var->protected_sb); - GPR_ASSERT(status == TSI_OK); + ASSERT_EQ(status, TSI_OK); status = alts_grpc_record_protocol_unprotect(rp, nullptr, &var->unprotected_sb); - GPR_ASSERT(status == TSI_INVALID_ARGUMENT); + ASSERT_EQ(status, TSI_INVALID_ARGUMENT); status = alts_grpc_record_protocol_unprotect(rp, &var->protected_sb, nullptr); - GPR_ASSERT(status == TSI_INVALID_ARGUMENT); + ASSERT_EQ(status, TSI_INVALID_ARGUMENT); /* Unprotects on a temporary slice buffer which length is smaller than header * length plus tag length. */ grpc_slice_buffer temp_sb; @@ -386,7 +402,7 @@ static void input_check(alts_grpc_record_protocol* rp) { &var->protected_sb, var->header_length + var->tag_length - 1, &temp_sb); status = alts_grpc_record_protocol_unprotect(rp, &temp_sb, &var->unprotected_sb); - GPR_ASSERT(status == TSI_INVALID_ARGUMENT); + ASSERT_EQ(status, TSI_INVALID_ARGUMENT); grpc_slice_buffer_destroy_internal(&temp_sb); alts_grpc_record_protocol_test_var_destroy(var); grpc_core::ExecCtx::Get()->Flush(); @@ -446,8 +462,7 @@ static void alts_grpc_record_protocol_tests( alts_grpc_record_protocol_test_fixture_destroy(fixture_5); } -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(&argc, argv); +TEST(AltsGrpcRecordProtocolTest, MainTest) { grpc_init(); alts_grpc_record_protocol_tests( &test_fixture_integrity_only_no_rekey_no_extra_copy_create); @@ -458,5 +473,11 @@ int main(int argc, char** argv) { &test_fixture_privacy_integrity_no_rekey_create); alts_grpc_record_protocol_tests(&test_fixture_privacy_integrity_rekey_create); grpc_shutdown(); - return 0; +} + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(&argc, argv); + ::testing::InitGoogleTest(&argc, argv); + grpc::testing::TestGrpcScope grpc_scope; + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc index 9096b6627c5..ff9e6c5f43e 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc @@ -18,6 +18,8 @@ #include "src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h" +#include + #include #include @@ -78,7 +80,7 @@ static void randomly_slice(uint8_t* input, size_t input_length, } static size_t alter_random_byte(uint8_t* buf, size_t buf_length) { - GPR_ASSERT(buf != nullptr); + EXPECT_NE(buf, nullptr); uint32_t offset = gsec_test_bias_random_uint32(static_cast(buf_length)); (*(buf + offset))++; @@ -86,7 +88,7 @@ static size_t alter_random_byte(uint8_t* buf, size_t buf_length) { } static void revert_back_alter(uint8_t* buf, size_t offset) { - GPR_ASSERT(buf != nullptr); + ASSERT_NE(buf, nullptr); (*(buf + offset))--; } @@ -102,38 +104,41 @@ alts_iovec_record_protocol_test_fixture_create(bool rekey, gsec_test_random_array(&key, key_length); gsec_aead_crypter* crypter = nullptr; /* Create client record protocol for protect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_iovec_record_protocol_create( - crypter, overflow_size, /*is_client=*/true, integrity_only, - /*is_protect=*/true, &fixture->client_protect, - nullptr) == GRPC_STATUS_OK); + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_iovec_record_protocol_create( + crypter, overflow_size, /*is_client=*/true, integrity_only, + /*is_protect=*/true, &fixture->client_protect, nullptr), + GRPC_STATUS_OK); /* Create client record protocol for unprotect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_iovec_record_protocol_create( - crypter, overflow_size, /*is_client=*/true, integrity_only, - /*is_protect=*/false, &fixture->client_unprotect, - nullptr) == GRPC_STATUS_OK); + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_iovec_record_protocol_create( + crypter, overflow_size, /*is_client=*/true, integrity_only, + /*is_protect=*/false, &fixture->client_unprotect, nullptr), + GRPC_STATUS_OK); /* Create server record protocol for protect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_iovec_record_protocol_create( - crypter, overflow_size, /*is_client=*/false, integrity_only, - /*is_protect=*/true, &fixture->server_protect, - nullptr) == GRPC_STATUS_OK); + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_iovec_record_protocol_create( + crypter, overflow_size, /*is_client=*/false, integrity_only, + /*is_protect=*/true, &fixture->server_protect, nullptr), + GRPC_STATUS_OK); /* Create server record protocol for unprotect. */ - GPR_ASSERT(gsec_aes_gcm_aead_crypter_create( - key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, - &crypter, nullptr) == GRPC_STATUS_OK); - GPR_ASSERT(alts_iovec_record_protocol_create( - crypter, overflow_size, /*is_client=*/false, integrity_only, - /*is_protect=*/false, &fixture->server_unprotect, - nullptr) == GRPC_STATUS_OK); - + EXPECT_EQ(gsec_aes_gcm_aead_crypter_create( + key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey, + &crypter, nullptr), + GRPC_STATUS_OK); + EXPECT_EQ(alts_iovec_record_protocol_create( + crypter, overflow_size, /*is_client=*/false, integrity_only, + /*is_protect=*/false, &fixture->server_unprotect, nullptr), + GRPC_STATUS_OK); gpr_free(key); return fixture; } @@ -210,7 +215,7 @@ static void integrity_only_random_seal_unseal( grpc_status_code status = alts_iovec_record_protocol_integrity_only_protect( sender, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); gpr_free(var->data_iovec); /* Randomly slices data buffer again. */ randomly_slice(var->data_buf, var->data_length, &var->data_iovec, @@ -218,10 +223,10 @@ static void integrity_only_random_seal_unseal( status = alts_iovec_record_protocol_integrity_only_unprotect( receiver, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); /* Makes sure data buffer has not been modified during * seal/unseal. */ - GPR_ASSERT(memcmp(var->data_buf, var->dup_buf, var->data_length) == 0); + ASSERT_EQ(memcmp(var->data_buf, var->dup_buf, var->data_length), 0); alts_iovec_record_protocol_test_var_destroy(var); } } @@ -234,10 +239,10 @@ static void integrity_only_empty_seal_unseal( /* Seals and then unseals empty payload. */ grpc_status_code status = alts_iovec_record_protocol_integrity_only_protect( sender, nullptr, 0, var->header_iovec, var->tag_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); status = alts_iovec_record_protocol_integrity_only_unprotect( receiver, nullptr, 0, var->header_iovec, var->tag_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); alts_iovec_record_protocol_test_var_destroy(var); } } @@ -250,20 +255,20 @@ static void integrity_only_unsync_seal_unseal( grpc_status_code status = alts_iovec_record_protocol_integrity_only_protect( sender, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); alts_iovec_record_protocol_test_var_destroy(var); /* Seals again. */ var = alts_iovec_record_protocol_test_var_create(); status = alts_iovec_record_protocol_integrity_only_protect( sender, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); /* Unseals the second frame. */ char* error_message = nullptr; status = alts_iovec_record_protocol_integrity_only_unprotect( receiver, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INTERNAL, error_message, "Frame tag verification failed.")); gpr_free(error_message); @@ -278,7 +283,7 @@ static void integrity_only_corrupted_data( grpc_status_code status = alts_iovec_record_protocol_integrity_only_protect( sender, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); /* Alter frame length field. */ char* error_message = nullptr; size_t offset = @@ -286,7 +291,7 @@ static void integrity_only_corrupted_data( status = alts_iovec_record_protocol_integrity_only_unprotect( receiver, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INTERNAL, error_message, "Bad frame length.")); gpr_free(error_message); revert_back_alter(var->header_buf, offset); @@ -296,7 +301,7 @@ static void integrity_only_corrupted_data( status = alts_iovec_record_protocol_integrity_only_unprotect( receiver, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INTERNAL, error_message, "Unsupported message type.")); gpr_free(error_message); @@ -306,7 +311,7 @@ static void integrity_only_corrupted_data( status = alts_iovec_record_protocol_integrity_only_unprotect( receiver, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INTERNAL, error_message, "Frame tag verification failed.")); gpr_free(error_message); @@ -316,7 +321,7 @@ static void integrity_only_corrupted_data( status = alts_iovec_record_protocol_integrity_only_unprotect( receiver, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INTERNAL, error_message, "Frame tag verification failed.")); gpr_free(error_message); @@ -325,8 +330,8 @@ static void integrity_only_corrupted_data( status = alts_iovec_record_protocol_integrity_only_unprotect( receiver, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(memcmp(var->data_buf, var->dup_buf, var->data_length) == 0); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(memcmp(var->data_buf, var->dup_buf, var->data_length), 0); alts_iovec_record_protocol_test_var_destroy(var); } @@ -339,7 +344,7 @@ static void integrity_only_protect_input_check(alts_iovec_record_protocol* rp) { grpc_status_code status = alts_iovec_record_protocol_integrity_only_protect( rp, var->data_iovec, var->data_iovec_length, header_iovec, var->tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Header is nullptr.")); gpr_free(error_message); @@ -349,7 +354,7 @@ static void integrity_only_protect_input_check(alts_iovec_record_protocol* rp) { status = alts_iovec_record_protocol_integrity_only_protect( rp, var->data_iovec, var->data_iovec_length, header_iovec, var->tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Header length is incorrect.")); gpr_free(error_message); @@ -358,7 +363,7 @@ static void integrity_only_protect_input_check(alts_iovec_record_protocol* rp) { status = alts_iovec_record_protocol_integrity_only_protect( rp, var->data_iovec, var->data_iovec_length, var->header_iovec, tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Tag is nullptr.")); gpr_free(error_message); /* Tag buffer length is 0. */ @@ -367,7 +372,7 @@ static void integrity_only_protect_input_check(alts_iovec_record_protocol* rp) { status = alts_iovec_record_protocol_integrity_only_protect( rp, var->data_iovec, var->data_iovec_length, var->header_iovec, tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Tag length is incorrect.")); gpr_free(error_message); @@ -384,7 +389,7 @@ static void integrity_only_unprotect_input_check( grpc_status_code status = alts_iovec_record_protocol_integrity_only_unprotect( rp, var->data_iovec, var->data_iovec_length, header_iovec, var->tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Header is nullptr.")); gpr_free(error_message); @@ -394,7 +399,7 @@ static void integrity_only_unprotect_input_check( status = alts_iovec_record_protocol_integrity_only_unprotect( rp, var->data_iovec, var->data_iovec_length, header_iovec, var->tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Header length is incorrect.")); gpr_free(error_message); @@ -403,7 +408,7 @@ static void integrity_only_unprotect_input_check( status = alts_iovec_record_protocol_integrity_only_unprotect( rp, var->data_iovec, var->data_iovec_length, var->header_iovec, tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Tag is nullptr.")); gpr_free(error_message); /* Tag buffer length is 0. */ @@ -412,7 +417,7 @@ static void integrity_only_unprotect_input_check( status = alts_iovec_record_protocol_integrity_only_unprotect( rp, var->data_iovec, var->data_iovec_length, var->header_iovec, tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Tag length is incorrect.")); gpr_free(error_message); @@ -431,7 +436,7 @@ static void privacy_integrity_random_seal_unseal( alts_iovec_record_protocol_privacy_integrity_protect( sender, var->data_iovec, var->data_iovec_length, var->protected_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); iovec_t header_iovec = {var->protected_buf, var->header_length}; gpr_free(var->data_iovec); /* Randomly slices protected buffer, excluding the header. */ @@ -441,9 +446,9 @@ static void privacy_integrity_random_seal_unseal( status = alts_iovec_record_protocol_privacy_integrity_unprotect( receiver, header_iovec, var->data_iovec, var->data_iovec_length, var->unprotected_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); /* Makes sure unprotected data are the same as the original. */ - GPR_ASSERT(memcmp(var->data_buf, var->dup_buf, var->data_length) == 0); + ASSERT_EQ(memcmp(var->data_buf, var->dup_buf, var->data_length), 0); alts_iovec_record_protocol_test_var_destroy(var); } } @@ -463,11 +468,11 @@ static void privacy_integrity_empty_seal_unseal( grpc_status_code status = alts_iovec_record_protocol_privacy_integrity_protect( sender, nullptr, 0, protected_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); iovec_t header_iovec = {protected_buf, var->header_length}; status = alts_iovec_record_protocol_privacy_integrity_unprotect( receiver, header_iovec, &data_iovec, 1, unprotected_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); } gpr_free(protected_buf); alts_iovec_record_protocol_test_var_destroy(var); @@ -482,14 +487,14 @@ static void privacy_integrity_unsync_seal_unseal( alts_iovec_record_protocol_privacy_integrity_protect( sender, var->data_iovec, var->data_iovec_length, var->protected_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); alts_iovec_record_protocol_test_var_destroy(var); /* Seals again. */ var = alts_iovec_record_protocol_test_var_create(); status = alts_iovec_record_protocol_privacy_integrity_protect( sender, var->data_iovec, var->data_iovec_length, var->protected_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); /* Unseals the second frame. */ char* error_message = nullptr; iovec_t header_iovec = {var->protected_buf, var->header_length}; @@ -498,7 +503,7 @@ static void privacy_integrity_unsync_seal_unseal( status = alts_iovec_record_protocol_privacy_integrity_unprotect( receiver, header_iovec, &protected_iovec, 1, var->unprotected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INTERNAL, error_message, "Frame decryption failed.")); gpr_free(error_message); alts_iovec_record_protocol_test_var_destroy(var); @@ -513,7 +518,7 @@ static void privacy_integrity_corrupted_data( alts_iovec_record_protocol_privacy_integrity_protect( sender, var->data_iovec, var->data_iovec_length, var->protected_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); char* error_message = nullptr; uint8_t* header_buf = var->protected_buf; size_t header_length = var->header_length; @@ -527,7 +532,7 @@ static void privacy_integrity_corrupted_data( status = alts_iovec_record_protocol_privacy_integrity_unprotect( receiver, header_iovec, &protected_iovec, 1, var->unprotected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INTERNAL, error_message, "Bad frame length.")); gpr_free(error_message); revert_back_alter(header_buf, offset); @@ -537,7 +542,7 @@ static void privacy_integrity_corrupted_data( status = alts_iovec_record_protocol_privacy_integrity_unprotect( receiver, header_iovec, &protected_iovec, 1, var->unprotected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INTERNAL, error_message, "Unsupported message type.")); gpr_free(error_message); @@ -547,7 +552,7 @@ static void privacy_integrity_corrupted_data( status = alts_iovec_record_protocol_privacy_integrity_unprotect( receiver, header_iovec, &protected_iovec, 1, var->unprotected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INTERNAL, error_message, "Frame decryption failed.")); gpr_free(error_message); revert_back_alter(protected_buf, offset); @@ -555,8 +560,8 @@ static void privacy_integrity_corrupted_data( status = alts_iovec_record_protocol_privacy_integrity_unprotect( receiver, header_iovec, &protected_iovec, 1, var->unprotected_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); - GPR_ASSERT(memcmp(var->data_buf, var->dup_buf, var->data_length) == 0); + ASSERT_EQ(status, GRPC_STATUS_OK); + ASSERT_EQ(memcmp(var->data_buf, var->dup_buf, var->data_length), 0); alts_iovec_record_protocol_test_var_destroy(var); } @@ -571,7 +576,7 @@ static void privacy_integrity_protect_input_check( alts_iovec_record_protocol_privacy_integrity_protect( rp, var->data_iovec, var->data_iovec_length, protected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Protected frame is nullptr.")); gpr_free(error_message); @@ -581,7 +586,7 @@ static void privacy_integrity_protect_input_check( status = alts_iovec_record_protocol_privacy_integrity_protect( rp, var->data_iovec, var->data_iovec_length, protected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Protected frame size is incorrect.")); gpr_free(error_message); @@ -602,7 +607,7 @@ static void privacy_integrity_unprotect_input_check( alts_iovec_record_protocol_privacy_integrity_unprotect( rp, header_iovec, &protected_iovec, 1, var->unprotected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Header is nullptr.")); gpr_free(error_message); @@ -612,7 +617,7 @@ static void privacy_integrity_unprotect_input_check( status = alts_iovec_record_protocol_privacy_integrity_unprotect( rp, header_iovec, &protected_iovec, 1, var->unprotected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Header length is incorrect.")); gpr_free(error_message); @@ -621,7 +626,7 @@ static void privacy_integrity_unprotect_input_check( iovec_t unprotected_iovec = {var->data_buf, var->data_length - 1}; status = alts_iovec_record_protocol_privacy_integrity_unprotect( rp, header_iovec, &protected_iovec, 1, unprotected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "Unprotected data size is incorrect.")); gpr_free(error_message); @@ -643,7 +648,7 @@ static void record_protocol_wrong_mode( status = alts_iovec_record_protocol_integrity_only_protect( privacy_integrity_protect_rp, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Integrity-only operations are not allowed for this object.")); gpr_free(error_message); @@ -651,7 +656,7 @@ static void record_protocol_wrong_mode( status = alts_iovec_record_protocol_integrity_only_unprotect( privacy_integrity_unprotect_rp, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Integrity-only operations are not allowed for this object.")); gpr_free(error_message); @@ -659,7 +664,7 @@ static void record_protocol_wrong_mode( status = alts_iovec_record_protocol_privacy_integrity_protect( integrity_only_protect_rp, var->data_iovec, var->data_iovec_length, var->protected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Privacy-integrity operations are not allowed for this object.")); gpr_free(error_message); @@ -667,7 +672,7 @@ static void record_protocol_wrong_mode( status = alts_iovec_record_protocol_privacy_integrity_unprotect( integrity_only_unprotect_rp, var->header_iovec, var->data_iovec, var->data_iovec_length, var->unprotected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_FAILED_PRECONDITION, error_message, "Privacy-integrity operations are not allowed for this object.")); gpr_free(error_message); @@ -685,7 +690,7 @@ static void integrity_seal_privacy_unseal( status = alts_iovec_record_protocol_integrity_only_protect( integrity_only_sender, var->data_iovec, var->data_iovec_length, var->header_iovec, var->tag_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); /* Unseal with privacy-integrity unprotect. */ memcpy(var->protected_buf, var->data_buf, var->data_length); memcpy(var->protected_buf + var->data_length, var->tag_buf, var->tag_length); @@ -694,7 +699,7 @@ static void integrity_seal_privacy_unseal( status = alts_iovec_record_protocol_privacy_integrity_unprotect( privacy_integrity_receiver, var->header_iovec, &protected_iovec, 1, var->unprotected_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INTERNAL, error_message, "Frame decryption failed.")); gpr_free(error_message); alts_iovec_record_protocol_test_var_destroy(var); @@ -711,7 +716,7 @@ static void privacy_seal_integrity_unseal( status = alts_iovec_record_protocol_privacy_integrity_protect( privacy_integrity_sender, var->data_iovec, var->data_iovec_length, var->protected_iovec, nullptr); - GPR_ASSERT(status == GRPC_STATUS_OK); + ASSERT_EQ(status, GRPC_STATUS_OK); /* Unseal with integrity-only unprotect. */ iovec_t header_iovec = {var->protected_buf, var->header_length}; iovec_t data_iovec = {var->protected_buf + var->header_length, @@ -722,7 +727,7 @@ static void privacy_seal_integrity_unseal( status = alts_iovec_record_protocol_integrity_only_unprotect( integrity_only_receiver, &data_iovec, 1, header_iovec, tag_iovec, &error_message); - GPR_ASSERT(gsec_test_expect_compare_code_and_substr( + ASSERT_TRUE(gsec_test_expect_compare_code_and_substr( status, GRPC_STATUS_INTERNAL, error_message, "Frame tag verification failed.")); gpr_free(error_message); @@ -731,7 +736,8 @@ static void privacy_seal_integrity_unseal( /* --- Test cases. --- */ -static void alts_iovec_record_protocol_random_seal_unseal_tests() { +TEST(AltsIovecRecordProtocolTest, + AltsIovecRecordProtocolRandomSealUnsealTests) { alts_iovec_record_protocol_test_fixture* fixture = alts_iovec_record_protocol_test_fixture_create( /*rekey=*/false, /*integrity_only=*/true); @@ -766,7 +772,7 @@ static void alts_iovec_record_protocol_random_seal_unseal_tests() { alts_iovec_record_protocol_test_fixture_destroy(fixture); } -static void alts_iovec_record_protocol_empty_seal_unseal_tests() { +TEST(AltsIovecRecordProtocolTest, AltsIovecRecordProtocolEmptySealUnsealTests) { alts_iovec_record_protocol_test_fixture* fixture = alts_iovec_record_protocol_test_fixture_create( /*rekey=*/false, /*integrity_only=*/true); @@ -801,7 +807,8 @@ static void alts_iovec_record_protocol_empty_seal_unseal_tests() { alts_iovec_record_protocol_test_fixture_destroy(fixture); } -static void alts_iovec_record_protocol_unsync_seal_unseal_tests() { +TEST(AltsIovecRecordProtocolTest, + AltsIovecRecordProtocolUnsyncSealUnsealTests) { alts_iovec_record_protocol_test_fixture* fixture = alts_iovec_record_protocol_test_fixture_create( /*rekey=*/false, /*integrity_only=*/true); @@ -836,7 +843,7 @@ static void alts_iovec_record_protocol_unsync_seal_unseal_tests() { alts_iovec_record_protocol_test_fixture_destroy(fixture); } -static void alts_iovec_record_protocol_corrupted_data_tests() { +TEST(AltsIovecRecordProtocolTest, AltsIovecRecordProtocolCorruptedDataTests) { alts_iovec_record_protocol_test_fixture* fixture = alts_iovec_record_protocol_test_fixture_create( /*rekey=*/false, /*integrity_only=*/true); @@ -871,7 +878,7 @@ static void alts_iovec_record_protocol_corrupted_data_tests() { alts_iovec_record_protocol_test_fixture_destroy(fixture); } -static void alts_iovec_record_protocol_input_check_tests() { +TEST(AltsIovecRecordProtocolTest, AltsIovecRecordProtocolInputCheckTests) { alts_iovec_record_protocol_test_fixture* fixture = alts_iovec_record_protocol_test_fixture_create( /*rekey=*/false, /*integrity_only=*/true); @@ -898,7 +905,7 @@ static void alts_iovec_record_protocol_input_check_tests() { alts_iovec_record_protocol_test_fixture_destroy(fixture); } -static void alts_iovec_record_protocol_mix_operations_tests() { +TEST(AltsIovecRecordProtocolTest, AltsIovecRecordProtocolMixOperationsTests) { alts_iovec_record_protocol_test_fixture* fixture_1 = alts_iovec_record_protocol_test_fixture_create( /*rekey=*/false, /*integrity_only=*/true); @@ -918,12 +925,7 @@ static void alts_iovec_record_protocol_mix_operations_tests() { alts_iovec_record_protocol_test_fixture_destroy(fixture_2); } -int main(int /*argc*/, char** /*argv*/) { - alts_iovec_record_protocol_random_seal_unseal_tests(); - alts_iovec_record_protocol_empty_seal_unseal_tests(); - alts_iovec_record_protocol_unsync_seal_unseal_tests(); - alts_iovec_record_protocol_corrupted_data_tests(); - alts_iovec_record_protocol_input_check_tests(); - alts_iovec_record_protocol_mix_operations_tests(); - return 0; +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc index 72ea12d7bd2..ed2b7f43358 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc @@ -18,6 +18,8 @@ #include "src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h" +#include + #include #include #include @@ -59,9 +61,9 @@ struct alts_zero_copy_grpc_protector_test_var { static void create_random_slice_buffer(grpc_slice_buffer* sb, grpc_slice_buffer* dup_sb, size_t length) { - GPR_ASSERT(sb != nullptr); - GPR_ASSERT(dup_sb != nullptr); - GPR_ASSERT(length > 0); + ASSERT_NE(sb, nullptr); + ASSERT_NE(dup_sb, nullptr); + ASSERT_GT(length, 0); grpc_slice slice = GRPC_SLICE_MALLOC(length); gsec_test_random_bytes(GRPC_SLICE_START_PTR(slice), length); grpc_slice_buffer_add(sb, grpc_slice_ref(slice)); @@ -69,8 +71,8 @@ static void create_random_slice_buffer(grpc_slice_buffer* sb, } static uint8_t* pointer_to_nth_byte(grpc_slice_buffer* sb, size_t index) { - GPR_ASSERT(sb != nullptr); - GPR_ASSERT(index < sb->length); + EXPECT_NE(sb, nullptr); + EXPECT_LT(index, sb->length); for (size_t i = 0; i < sb->count; i++) { if (index < GRPC_SLICE_LENGTH(sb->slices[i])) { return GRPC_SLICE_START_PTR(sb->slices[i]) + index; @@ -85,15 +87,15 @@ static uint8_t* pointer_to_nth_byte(grpc_slice_buffer* sb, size_t index) { * but OK for testing. */ static bool are_slice_buffers_equal(grpc_slice_buffer* first, grpc_slice_buffer* second) { - GPR_ASSERT(first != nullptr); - GPR_ASSERT(second != nullptr); + EXPECT_NE(first, nullptr); + EXPECT_NE(second, nullptr); if (first->length != second->length) { return false; } for (size_t i = 0; i < first->length; i++) { uint8_t* first_ptr = pointer_to_nth_byte(first, i); uint8_t* second_ptr = pointer_to_nth_byte(second, i); - GPR_ASSERT(first_ptr != nullptr && second_ptr != nullptr); + EXPECT_TRUE(first_ptr != nullptr && second_ptr != nullptr); if ((*first_ptr) != (*second_ptr)) { return false; } @@ -114,20 +116,22 @@ alts_zero_copy_grpc_protector_test_fixture_create(bool rekey, size_t max_protected_frame_size = 1024; size_t actual_max_protected_frame_size; gsec_test_random_array(&key, key_length); - GPR_ASSERT(alts_zero_copy_grpc_protector_create( - key, key_length, rekey, /*is_client=*/true, integrity_only, - enable_extra_copy, &max_protected_frame_size, - &fixture->client) == TSI_OK); - GPR_ASSERT(tsi_zero_copy_grpc_protector_max_frame_size( - fixture->client, &actual_max_protected_frame_size) == TSI_OK); - GPR_ASSERT(actual_max_protected_frame_size == max_protected_frame_size); - GPR_ASSERT(alts_zero_copy_grpc_protector_create( - key, key_length, rekey, /*is_client=*/false, integrity_only, - enable_extra_copy, &max_protected_frame_size, - &fixture->server) == TSI_OK); - GPR_ASSERT(tsi_zero_copy_grpc_protector_max_frame_size( - fixture->server, &actual_max_protected_frame_size) == TSI_OK); - GPR_ASSERT(actual_max_protected_frame_size == max_protected_frame_size); + EXPECT_EQ(alts_zero_copy_grpc_protector_create( + key, key_length, rekey, /*is_client=*/true, integrity_only, + enable_extra_copy, &max_protected_frame_size, &fixture->client), + TSI_OK); + EXPECT_EQ(tsi_zero_copy_grpc_protector_max_frame_size( + fixture->client, &actual_max_protected_frame_size), + TSI_OK); + EXPECT_EQ(actual_max_protected_frame_size, max_protected_frame_size); + EXPECT_EQ(alts_zero_copy_grpc_protector_create( + key, key_length, rekey, /*is_client=*/false, integrity_only, + enable_extra_copy, &max_protected_frame_size, &fixture->server), + TSI_OK); + EXPECT_EQ(tsi_zero_copy_grpc_protector_max_frame_size( + fixture->server, &actual_max_protected_frame_size), + TSI_OK); + EXPECT_EQ(actual_max_protected_frame_size, max_protected_frame_size); gpr_free(key); grpc_core::ExecCtx::Get()->Flush(); return fixture; @@ -183,8 +187,9 @@ static void seal_unseal_small_buffer(tsi_zero_copy_grpc_protector* sender, /* Creates a random small slice buffer and calls protect(). */ create_random_slice_buffer(&var->original_sb, &var->duplicate_sb, kSmallBufferSize); - GPR_ASSERT(tsi_zero_copy_grpc_protector_protect( - sender, &var->original_sb, &var->protected_sb) == TSI_OK); + ASSERT_EQ(tsi_zero_copy_grpc_protector_protect(sender, &var->original_sb, + &var->protected_sb), + TSI_OK); /* Splits protected slice buffer into two: first one is staging_sb, and * second one is protected_sb. */ uint32_t staging_sb_size = @@ -194,22 +199,23 @@ static void seal_unseal_small_buffer(tsi_zero_copy_grpc_protector* sender, grpc_slice_buffer_move_first(&var->protected_sb, staging_sb_size, &var->staging_sb); /* Unprotects one by one. */ - GPR_ASSERT(tsi_zero_copy_grpc_protector_unprotect( - receiver, &var->staging_sb, &var->unprotected_sb, - &min_progress_size) == TSI_OK); + ASSERT_EQ(tsi_zero_copy_grpc_protector_unprotect(receiver, &var->staging_sb, + &var->unprotected_sb, + &min_progress_size), + TSI_OK); if (staging_sb_size >= kZeroCopyFrameLengthFieldSize) { - GPR_ASSERT(min_progress_size == - static_cast(var->protected_sb.length)); + ASSERT_EQ(min_progress_size, static_cast(var->protected_sb.length)); } else { - GPR_ASSERT(min_progress_size == 1); + ASSERT_EQ(min_progress_size, 1); } - GPR_ASSERT(var->unprotected_sb.length == 0); - GPR_ASSERT(tsi_zero_copy_grpc_protector_unprotect( - receiver, &var->protected_sb, &var->unprotected_sb, - &min_progress_size) == TSI_OK); - GPR_ASSERT( + ASSERT_EQ(var->unprotected_sb.length, 0); + ASSERT_EQ(tsi_zero_copy_grpc_protector_unprotect( + receiver, &var->protected_sb, &var->unprotected_sb, + &min_progress_size), + TSI_OK); + ASSERT_TRUE( are_slice_buffers_equal(&var->unprotected_sb, &var->duplicate_sb)); - GPR_ASSERT(min_progress_size == 1); + ASSERT_EQ(min_progress_size, 1); alts_zero_copy_grpc_protector_test_var_destroy(var); } grpc_core::ExecCtx::Get()->Flush(); @@ -224,8 +230,9 @@ static void seal_unseal_large_buffer(tsi_zero_copy_grpc_protector* sender, /* Creates a random large slice buffer and calls protect(). */ create_random_slice_buffer(&var->original_sb, &var->duplicate_sb, kLargeBufferSize); - GPR_ASSERT(tsi_zero_copy_grpc_protector_protect( - sender, &var->original_sb, &var->protected_sb) == TSI_OK); + ASSERT_EQ(tsi_zero_copy_grpc_protector_protect(sender, &var->original_sb, + &var->protected_sb), + TSI_OK); /* Splits protected slice buffer into multiple pieces. Receiver unprotects * each slice buffer one by one. */ uint32_t channel_size = gsec_test_bias_random_uint32(static_cast( @@ -235,14 +242,14 @@ static void seal_unseal_large_buffer(tsi_zero_copy_grpc_protector* sender, grpc_slice_buffer_reset_and_unref_internal(&var->staging_sb); grpc_slice_buffer_move_first(&var->protected_sb, channel_size, &var->staging_sb); - GPR_ASSERT(tsi_zero_copy_grpc_protector_unprotect( - receiver, &var->staging_sb, &var->unprotected_sb, - nullptr) == TSI_OK); + ASSERT_EQ(tsi_zero_copy_grpc_protector_unprotect( + receiver, &var->staging_sb, &var->unprotected_sb, nullptr), + TSI_OK); } - GPR_ASSERT(tsi_zero_copy_grpc_protector_unprotect( - receiver, &var->protected_sb, &var->unprotected_sb, - nullptr) == TSI_OK); - GPR_ASSERT( + ASSERT_EQ(tsi_zero_copy_grpc_protector_unprotect( + receiver, &var->protected_sb, &var->unprotected_sb, nullptr), + TSI_OK); + ASSERT_TRUE( are_slice_buffers_equal(&var->unprotected_sb, &var->duplicate_sb)); alts_zero_copy_grpc_protector_test_var_destroy(var); } @@ -307,8 +314,7 @@ static void alts_zero_copy_protector_seal_unseal_large_buffer_tests( alts_zero_copy_grpc_protector_test_fixture_destroy(fixture); } -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(&argc, argv); +TEST(AltsZeroCopyGrpcProtectorTest, MainTest) { grpc_init(); alts_zero_copy_protector_seal_unseal_small_buffer_tests( /*enable_extra_copy=*/false); @@ -319,5 +325,11 @@ int main(int argc, char** argv) { alts_zero_copy_protector_seal_unseal_large_buffer_tests( /*enable_extra_copy=*/true); grpc_shutdown(); - return 0; +} + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(&argc, argv); + ::testing::InitGoogleTest(&argc, argv); + grpc::testing::TestGrpcScope grpc_scope; + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/fake_transport_security_test.cc b/test/core/tsi/fake_transport_security_test.cc index 997bff07daf..350ebbb8501 100644 --- a/test/core/tsi/fake_transport_security_test.cc +++ b/test/core/tsi/fake_transport_security_test.cc @@ -22,6 +22,8 @@ #include #include +#include + #include #include #include @@ -43,19 +45,21 @@ static void fake_test_setup_handshakers(tsi_test_fixture* fixture) { } static void validate_handshaker_peers(tsi_handshaker_result* result) { - GPR_ASSERT(result != nullptr); + ASSERT_NE(result, nullptr); tsi_peer peer; - GPR_ASSERT(tsi_handshaker_result_extract_peer(result, &peer) == TSI_OK); + ASSERT_EQ(tsi_handshaker_result_extract_peer(result, &peer), TSI_OK); const tsi_peer_property* property = tsi_peer_get_property_by_name(&peer, TSI_CERTIFICATE_TYPE_PEER_PROPERTY); - GPR_ASSERT(property != nullptr); - GPR_ASSERT(memcmp(property->value.data, TSI_FAKE_CERTIFICATE_TYPE, - property->value.length) == 0); + ASSERT_NE(property, nullptr); + ASSERT_EQ(memcmp(property->value.data, TSI_FAKE_CERTIFICATE_TYPE, + property->value.length), + 0); property = tsi_peer_get_property_by_name(&peer, TSI_SECURITY_LEVEL_PEER_PROPERTY); - GPR_ASSERT(property != nullptr); - GPR_ASSERT(memcmp(property->value.data, TSI_FAKE_SECURITY_LEVEL, - property->value.length) == 0); + ASSERT_NE(property, nullptr); + ASSERT_EQ(memcmp(property->value.data, TSI_FAKE_SECURITY_LEVEL, + property->value.length), + 0); tsi_peer_destruct(&peer); } @@ -78,27 +82,27 @@ static tsi_test_fixture* fake_tsi_test_fixture_create() { return &fake_fixture->base; } -void fake_tsi_test_do_handshake_tiny_handshake_buffer() { +TEST(FakeTransportSecurityTest, FakeTsiTestDoHandshakeTinyHandshakeBuffer) { tsi_test_fixture* fixture = fake_tsi_test_fixture_create(); fixture->handshake_buffer_size = TSI_TEST_TINY_HANDSHAKE_BUFFER_SIZE; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } -void fake_tsi_test_do_handshake_small_handshake_buffer() { +TEST(FakeTransportSecurityTest, FakeTsiTestDoHandshakeSmallHandshakeBuffer) { tsi_test_fixture* fixture = fake_tsi_test_fixture_create(); fixture->handshake_buffer_size = TSI_TEST_SMALL_HANDSHAKE_BUFFER_SIZE; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } -void fake_tsi_test_do_handshake() { +TEST(FakeTransportSecurityTest, FakeTsiTestDoHandshake) { tsi_test_fixture* fixture = fake_tsi_test_fixture_create(); tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } -void fake_tsi_test_do_round_trip_for_all_configs() { +TEST(FakeTransportSecurityTest, FakeTsiTestDoRoundTripForAllConfigs) { unsigned int* bit_array = static_cast( gpr_zalloc(sizeof(unsigned int) * TSI_TEST_NUM_OF_ARGUMENTS)); const unsigned int mask = 1U << (TSI_TEST_NUM_OF_ARGUMENTS - 1); @@ -121,7 +125,7 @@ void fake_tsi_test_do_round_trip_for_all_configs() { gpr_free(bit_array); } -void fake_tsi_test_do_round_trip_odd_buffer_size() { +TEST(FakeTransportSecurityTest, FakeTsiTestDoRoundTripOddBufferSize) { const size_t odd_sizes[] = {1025, 2051, 4103, 8207, 16409}; const size_t size = sizeof(odd_sizes) / sizeof(size_t); for (size_t ind1 = 0; ind1 < size; ind1++) { @@ -146,12 +150,7 @@ void fake_tsi_test_do_round_trip_odd_buffer_size() { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); - grpc_init(); - fake_tsi_test_do_handshake_tiny_handshake_buffer(); - fake_tsi_test_do_handshake_small_handshake_buffer(); - fake_tsi_test_do_handshake(); - fake_tsi_test_do_round_trip_for_all_configs(); - fake_tsi_test_do_round_trip_odd_buffer_size(); - grpc_shutdown(); - return 0; + ::testing::InitGoogleTest(&argc, argv); + grpc::testing::TestGrpcScope grpc_scope; + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/ssl_transport_security_test.cc b/test/core/tsi/ssl_transport_security_test.cc index 6b5755925e8..27860167be7 100644 --- a/test/core/tsi/ssl_transport_security_test.cc +++ b/test/core/tsi/ssl_transport_security_test.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -108,9 +109,9 @@ typedef struct ssl_tsi_test_fixture { static void ssl_test_setup_handshakers(tsi_test_fixture* fixture) { ssl_tsi_test_fixture* ssl_fixture = reinterpret_cast(fixture); - GPR_ASSERT(ssl_fixture != nullptr); - GPR_ASSERT(ssl_fixture->key_cert_lib != nullptr); - GPR_ASSERT(ssl_fixture->alpn_lib != nullptr); + ASSERT_NE(ssl_fixture, nullptr); + ASSERT_NE(ssl_fixture->key_cert_lib, nullptr); + ASSERT_NE(ssl_fixture->alpn_lib, nullptr); ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib; ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib; /* Create client handshaker factory. */ @@ -135,9 +136,9 @@ static void ssl_test_setup_handshakers(tsi_test_fixture* fixture) { } client_options.min_tls_version = test_tls_version; client_options.max_tls_version = test_tls_version; - GPR_ASSERT(tsi_create_ssl_client_handshaker_factory_with_options( - &client_options, &ssl_fixture->client_handshaker_factory) == - TSI_OK); + ASSERT_EQ(tsi_create_ssl_client_handshaker_factory_with_options( + &client_options, &ssl_fixture->client_handshaker_factory), + TSI_OK); /* Create server handshaker factory. */ tsi_ssl_server_handshaker_options server_options; if (alpn_lib->alpn_mode == ALPN_SERVER_NO_CLIENT || @@ -169,59 +170,64 @@ static void ssl_test_setup_handshakers(tsi_test_fixture* fixture) { server_options.session_ticket_key_size = ssl_fixture->session_ticket_key_size; server_options.min_tls_version = test_tls_version; server_options.max_tls_version = test_tls_version; - GPR_ASSERT(tsi_create_ssl_server_handshaker_factory_with_options( - &server_options, &ssl_fixture->server_handshaker_factory) == - TSI_OK); + ASSERT_EQ(tsi_create_ssl_server_handshaker_factory_with_options( + &server_options, &ssl_fixture->server_handshaker_factory), + TSI_OK); /* Create server and client handshakers. */ - GPR_ASSERT(tsi_ssl_client_handshaker_factory_create_handshaker( - ssl_fixture->client_handshaker_factory, - ssl_fixture->server_name_indication, - ssl_fixture->network_bio_buf_size, - ssl_fixture->ssl_bio_buf_size, - &ssl_fixture->base.client_handshaker) == TSI_OK); - GPR_ASSERT(tsi_ssl_server_handshaker_factory_create_handshaker( - ssl_fixture->server_handshaker_factory, - ssl_fixture->network_bio_buf_size, - ssl_fixture->ssl_bio_buf_size, - &ssl_fixture->base.server_handshaker) == TSI_OK); + ASSERT_EQ( + tsi_ssl_client_handshaker_factory_create_handshaker( + ssl_fixture->client_handshaker_factory, + ssl_fixture->server_name_indication, + ssl_fixture->network_bio_buf_size, ssl_fixture->ssl_bio_buf_size, + &ssl_fixture->base.client_handshaker), + TSI_OK); + ASSERT_EQ( + tsi_ssl_server_handshaker_factory_create_handshaker( + ssl_fixture->server_handshaker_factory, + ssl_fixture->network_bio_buf_size, ssl_fixture->ssl_bio_buf_size, + &ssl_fixture->base.server_handshaker), + TSI_OK); } static void check_alpn(ssl_tsi_test_fixture* ssl_fixture, const tsi_peer* peer) { - GPR_ASSERT(ssl_fixture != nullptr); - GPR_ASSERT(ssl_fixture->alpn_lib != nullptr); + ASSERT_NE(ssl_fixture, nullptr); + ASSERT_NE(ssl_fixture->alpn_lib, nullptr); ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib; const tsi_peer_property* alpn_property = tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL); if (alpn_lib->alpn_mode != ALPN_CLIENT_SERVER_OK) { - GPR_ASSERT(alpn_property == nullptr); + ASSERT_EQ(alpn_property, nullptr); } else { - GPR_ASSERT(alpn_property != nullptr); + ASSERT_NE(alpn_property, nullptr); const char* expected_match = "baz"; - GPR_ASSERT(memcmp(alpn_property->value.data, expected_match, - alpn_property->value.length) == 0); + ASSERT_EQ(memcmp(alpn_property->value.data, expected_match, + alpn_property->value.length), + 0); } } static void check_security_level(const tsi_peer* peer) { const tsi_peer_property* security_level = tsi_peer_get_property_by_name(peer, TSI_SECURITY_LEVEL_PEER_PROPERTY); - GPR_ASSERT(security_level != nullptr); + ASSERT_NE(security_level, nullptr); const char* expected_match = "TSI_PRIVACY_AND_INTEGRITY"; - GPR_ASSERT(memcmp(security_level->value.data, expected_match, - security_level->value.length) == 0); + ASSERT_EQ(memcmp(security_level->value.data, expected_match, + security_level->value.length), + 0); } static const tsi_peer_property* check_basic_authenticated_peer_and_get_common_name(const tsi_peer* peer) { const tsi_peer_property* cert_type_property = tsi_peer_get_property_by_name(peer, TSI_CERTIFICATE_TYPE_PEER_PROPERTY); - GPR_ASSERT(cert_type_property != nullptr); - GPR_ASSERT(memcmp(cert_type_property->value.data, TSI_X509_CERTIFICATE_TYPE, - cert_type_property->value.length) == 0); + EXPECT_NE(cert_type_property, nullptr); + EXPECT_EQ(memcmp(cert_type_property->value.data, TSI_X509_CERTIFICATE_TYPE, + cert_type_property->value.length), + 0); const tsi_peer_property* property = tsi_peer_get_property_by_name( peer, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY); - GPR_ASSERT(property != nullptr); + EXPECT_NE(property, nullptr); return property; } @@ -229,13 +235,15 @@ static void check_session_reusage(ssl_tsi_test_fixture* ssl_fixture, tsi_peer* peer) { const tsi_peer_property* session_reused = tsi_peer_get_property_by_name(peer, TSI_SSL_SESSION_REUSED_PEER_PROPERTY); - GPR_ASSERT(session_reused != nullptr); + ASSERT_NE(session_reused, nullptr); if (ssl_fixture->session_reused) { - GPR_ASSERT(strncmp(session_reused->value.data, "true", - session_reused->value.length) == 0); + ASSERT_EQ(strncmp(session_reused->value.data, "true", + session_reused->value.length), + 0); } else { - GPR_ASSERT(strncmp(session_reused->value.data, "false", - session_reused->value.length) == 0); + ASSERT_EQ(strncmp(session_reused->value.data, "false", + session_reused->value.length), + 0); } } @@ -243,20 +251,19 @@ void check_server0_peer(tsi_peer* peer) { const tsi_peer_property* property = check_basic_authenticated_peer_and_get_common_name(peer); const char* expected_match = "*.test.google.com.au"; - GPR_ASSERT(memcmp(property->value.data, expected_match, - property->value.length) == 0); - GPR_ASSERT(tsi_peer_get_property_by_name( - peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == - nullptr); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "foo.test.google.com.au") == 1); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "bar.test.google.com.au") == 1); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "BAR.TEST.GOOGLE.COM.AU") == 1); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "Bar.Test.Google.Com.Au") == 1); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "bAr.TeST.gOOgle.cOm.AU") == 1); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "bar.test.google.blah") == 0); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "foo.bar.test.google.com.au") == - 0); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "test.google.com.au") == 0); + ASSERT_EQ( + memcmp(property->value.data, expected_match, property->value.length), 0); + ASSERT_EQ(tsi_peer_get_property_by_name( + peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY), + nullptr); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "foo.test.google.com.au"), 1); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "bar.test.google.com.au"), 1); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "BAR.TEST.GOOGLE.COM.AU"), 1); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "Bar.Test.Google.Com.Au"), 1); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "bAr.TeST.gOOgle.cOm.AU"), 1); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "bar.test.google.blah"), 0); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "foo.bar.test.google.com.au"), 0); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "test.google.com.au"), 0); tsi_peer_destruct(peer); } @@ -278,39 +285,42 @@ void check_server1_peer(tsi_peer* peer) { const tsi_peer_property* property = check_basic_authenticated_peer_and_get_common_name(peer); const char* expected_match = "*.test.google.com"; - GPR_ASSERT(memcmp(property->value.data, expected_match, - property->value.length) == 0); - GPR_ASSERT(check_property(peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "*.test.google.fr") == 1); - GPR_ASSERT(check_property(peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "waterzooi.test.google.be") == 1); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "foo.test.google.fr") == 1); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "bar.test.google.fr") == 1); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "waterzooi.test.google.be") == 1); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "foo.test.youtube.com") == 1); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "bar.foo.test.google.com") == 0); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "test.google.fr") == 0); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "tartines.test.google.be") == 0); - GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "tartines.youtube.com") == 0); + ASSERT_EQ( + memcmp(property->value.data, expected_match, property->value.length), 0); + ASSERT_EQ( + check_property(peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "*.test.google.fr"), + 1); + ASSERT_EQ( + check_property(peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "waterzooi.test.google.be"), + 1); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "foo.test.google.fr"), 1); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "bar.test.google.fr"), 1); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "waterzooi.test.google.be"), 1); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "foo.test.youtube.com"), 1); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "bar.foo.test.google.com"), 0); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "test.google.fr"), 0); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "tartines.test.google.be"), 0); + ASSERT_EQ(tsi_ssl_peer_matches_name(peer, "tartines.youtube.com"), 0); tsi_peer_destruct(peer); } static void check_client_peer(ssl_tsi_test_fixture* ssl_fixture, tsi_peer* peer) { - GPR_ASSERT(ssl_fixture != nullptr); - GPR_ASSERT(ssl_fixture->alpn_lib != nullptr); + ASSERT_NE(ssl_fixture, nullptr); + ASSERT_NE(ssl_fixture->alpn_lib, nullptr); ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib; if (!ssl_fixture->force_client_auth) { - GPR_ASSERT(peer->property_count == - (alpn_lib->alpn_mode == ALPN_CLIENT_SERVER_OK ? 3 : 2)); + ASSERT_EQ(peer->property_count, + (alpn_lib->alpn_mode == ALPN_CLIENT_SERVER_OK ? 3 : 2)); } else { const tsi_peer_property* property = check_basic_authenticated_peer_and_get_common_name(peer); const char* expected_match = "testclient"; - GPR_ASSERT(memcmp(property->value.data, expected_match, - property->value.length) == 0); + ASSERT_EQ( + memcmp(property->value.data, expected_match, property->value.length), + 0); } tsi_peer_destruct(peer); } @@ -318,8 +328,8 @@ static void check_client_peer(ssl_tsi_test_fixture* ssl_fixture, static void ssl_test_check_handshaker_peers(tsi_test_fixture* fixture) { ssl_tsi_test_fixture* ssl_fixture = reinterpret_cast(fixture); - GPR_ASSERT(ssl_fixture != nullptr); - GPR_ASSERT(ssl_fixture->key_cert_lib != nullptr); + ASSERT_NE(ssl_fixture, nullptr); + ASSERT_NE(ssl_fixture->key_cert_lib, nullptr); ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib; tsi_peer peer; // In TLS 1.3, the client-side handshake succeeds even if the client sends a @@ -342,8 +352,9 @@ static void ssl_test_check_handshaker_peers(tsi_test_fixture* fixture) { bool expect_client_success = expect_server_success; #endif if (expect_client_success) { - GPR_ASSERT(tsi_handshaker_result_extract_peer( - ssl_fixture->base.client_result, &peer) == TSI_OK); + ASSERT_EQ(tsi_handshaker_result_extract_peer( + ssl_fixture->base.client_result, &peer), + TSI_OK); check_session_reusage(ssl_fixture, &peer); check_alpn(ssl_fixture, &peer); check_security_level(&peer); @@ -357,17 +368,18 @@ static void ssl_test_check_handshaker_peers(tsi_test_fixture* fixture) { check_server1_peer(&peer); } } else { - GPR_ASSERT(ssl_fixture->base.client_result == nullptr); + ASSERT_EQ(ssl_fixture->base.client_result, nullptr); } if (expect_server_success) { - GPR_ASSERT(tsi_handshaker_result_extract_peer( - ssl_fixture->base.server_result, &peer) == TSI_OK); + ASSERT_EQ(tsi_handshaker_result_extract_peer( + ssl_fixture->base.server_result, &peer), + TSI_OK); check_session_reusage(ssl_fixture, &peer); check_alpn(ssl_fixture, &peer); check_security_level(&peer); check_client_peer(ssl_fixture, &peer); } else { - GPR_ASSERT(ssl_fixture->base.server_result == nullptr); + ASSERT_EQ(ssl_fixture->base.server_result, nullptr); } } @@ -432,7 +444,7 @@ static char* load_file(const char* dir_path, const char* file_name) { memcpy(file_path, dir_path, strlen(dir_path)); memcpy(file_path + strlen(dir_path), file_name, strlen(file_name)); grpc_slice slice; - GPR_ASSERT(grpc_load_file(file_path, 1, &slice) == GRPC_ERROR_NONE); + EXPECT_EQ(grpc_load_file(file_path, 1, &slice), GRPC_ERROR_NONE); char* data = grpc_slice_to_c_string(slice); grpc_slice_unref(slice); gpr_free(file_path); @@ -484,7 +496,7 @@ static tsi_test_fixture* ssl_tsi_test_fixture_create() { key_cert_lib->root_cert = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "ca.pem"); key_cert_lib->root_store = tsi_ssl_root_certs_store_create(key_cert_lib->root_cert); - GPR_ASSERT(key_cert_lib->root_store != nullptr); + EXPECT_NE(key_cert_lib->root_store, nullptr); ssl_fixture->key_cert_lib = key_cert_lib; /* Create ssl_alpn_lib. */ ssl_alpn_lib* alpn_lib = grpc_core::Zalloc(); @@ -699,8 +711,8 @@ void ssl_tsi_test_do_round_trip_with_error_on_stack() { gpr_log(GPR_INFO, "ssl_tsi_test_do_round_trip_with_error_on_stack"); // Invoke an SSL function that causes an error, and ensure the error // makes it to the stack. - GPR_ASSERT(!EC_KEY_new_by_curve_name(NID_rsa)); - GPR_ASSERT(ERR_peek_error() != 0); + ASSERT_FALSE(EC_KEY_new_by_curve_name(NID_rsa)); + ASSERT_NE(ERR_peek_error(), 0); tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); tsi_test_do_round_trip(fixture); tsi_test_fixture_destroy(fixture); @@ -784,7 +796,7 @@ static bool handshaker_factory_destructor_called; static void ssl_tsi_test_handshaker_factory_destructor( tsi_ssl_handshaker_factory* factory) { - GPR_ASSERT(factory != nullptr); + ASSERT_NE(factory, nullptr); handshaker_factory_destructor_called = true; if (original_vtable != nullptr && original_vtable->destroy != nullptr) { original_vtable->destroy(factory); @@ -801,8 +813,9 @@ void test_tsi_ssl_client_handshaker_factory_refcounting() { tsi_ssl_client_handshaker_options options; options.pem_root_certs = cert_chain; tsi_ssl_client_handshaker_factory* client_handshaker_factory; - GPR_ASSERT(tsi_create_ssl_client_handshaker_factory_with_options( - &options, &client_handshaker_factory) == TSI_OK); + ASSERT_EQ(tsi_create_ssl_client_handshaker_factory_with_options( + &options, &client_handshaker_factory), + TSI_OK); handshaker_factory_destructor_called = false; original_vtable = tsi_ssl_handshaker_factory_swap_vtable( @@ -812,22 +825,23 @@ void test_tsi_ssl_client_handshaker_factory_refcounting() { tsi_handshaker* handshaker[3]; for (i = 0; i < 3; ++i) { - GPR_ASSERT(tsi_ssl_client_handshaker_factory_create_handshaker( - client_handshaker_factory, "google.com", 0, 0, - &handshaker[i]) == TSI_OK); + ASSERT_EQ( + tsi_ssl_client_handshaker_factory_create_handshaker( + client_handshaker_factory, "google.com", 0, 0, &handshaker[i]), + TSI_OK); } tsi_handshaker_destroy(handshaker[1]); - GPR_ASSERT(!handshaker_factory_destructor_called); + ASSERT_FALSE(handshaker_factory_destructor_called); tsi_handshaker_destroy(handshaker[0]); - GPR_ASSERT(!handshaker_factory_destructor_called); + ASSERT_FALSE(handshaker_factory_destructor_called); tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory); - GPR_ASSERT(!handshaker_factory_destructor_called); + ASSERT_FALSE(handshaker_factory_destructor_called); tsi_handshaker_destroy(handshaker[2]); - GPR_ASSERT(handshaker_factory_destructor_called); + ASSERT_TRUE(handshaker_factory_destructor_called); gpr_free(cert_chain); } @@ -848,8 +862,9 @@ void test_tsi_ssl_server_handshaker_factory_refcounting() { options.num_key_cert_pairs = 1; options.pem_client_root_certs = cert_chain; - GPR_ASSERT(tsi_create_ssl_server_handshaker_factory_with_options( - &options, &server_handshaker_factory) == TSI_OK); + ASSERT_EQ(tsi_create_ssl_server_handshaker_factory_with_options( + &options, &server_handshaker_factory), + TSI_OK); handshaker_factory_destructor_called = false; original_vtable = tsi_ssl_handshaker_factory_swap_vtable( @@ -857,21 +872,22 @@ void test_tsi_ssl_server_handshaker_factory_refcounting() { &test_handshaker_factory_vtable); for (i = 0; i < 3; ++i) { - GPR_ASSERT(tsi_ssl_server_handshaker_factory_create_handshaker( - server_handshaker_factory, 0, 0, &handshaker[i]) == TSI_OK); + ASSERT_EQ(tsi_ssl_server_handshaker_factory_create_handshaker( + server_handshaker_factory, 0, 0, &handshaker[i]), + TSI_OK); } tsi_handshaker_destroy(handshaker[1]); - GPR_ASSERT(!handshaker_factory_destructor_called); + ASSERT_FALSE(handshaker_factory_destructor_called); tsi_handshaker_destroy(handshaker[0]); - GPR_ASSERT(!handshaker_factory_destructor_called); + ASSERT_FALSE(handshaker_factory_destructor_called); tsi_ssl_server_handshaker_factory_unref(server_handshaker_factory); - GPR_ASSERT(!handshaker_factory_destructor_called); + ASSERT_FALSE(handshaker_factory_destructor_called); tsi_handshaker_destroy(handshaker[2]); - GPR_ASSERT(handshaker_factory_destructor_called); + ASSERT_TRUE(handshaker_factory_destructor_called); ssl_test_pem_key_cert_pair_destroy(cert_pair); } @@ -884,8 +900,9 @@ void test_tsi_ssl_client_handshaker_factory_bad_params() { tsi_ssl_client_handshaker_factory* client_handshaker_factory; tsi_ssl_client_handshaker_options options; options.pem_root_certs = cert_chain; - GPR_ASSERT(tsi_create_ssl_client_handshaker_factory_with_options( - &options, &client_handshaker_factory) == TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_create_ssl_client_handshaker_factory_with_options( + &options, &client_handshaker_factory), + TSI_INVALID_ARGUMENT); tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory); } @@ -905,7 +922,7 @@ void ssl_tsi_test_duplicate_root_certificates() { memcpy(dup_root_cert + strlen(root_cert), root_cert, strlen(root_cert)); tsi_ssl_root_certs_store* root_store = tsi_ssl_root_certs_store_create(dup_root_cert); - GPR_ASSERT(root_store != nullptr); + ASSERT_NE(root_store, nullptr); // Free memory. tsi_ssl_root_certs_store_destroy(root_store); gpr_free(root_cert); @@ -916,84 +933,101 @@ void ssl_tsi_test_extract_x509_subject_names() { gpr_log(GPR_INFO, "ssl_tsi_test_extract_x509_subject_names"); char* cert = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "multi-domain.pem"); tsi_peer peer; - GPR_ASSERT(tsi_ssl_extract_x509_subject_names_from_pem_cert(cert, &peer) == - TSI_OK); + ASSERT_EQ(tsi_ssl_extract_x509_subject_names_from_pem_cert(cert, &peer), + TSI_OK); // tsi_peer should include one subject, one common name, one certificate, one // security level, ten SAN fields, two DNS SAN fields, three URI fields, two // email addresses and two IP addresses. size_t expected_property_count = 22; - GPR_ASSERT(peer.property_count == expected_property_count); + ASSERT_EQ(peer.property_count, expected_property_count); // Check subject const char* expected_subject = "CN=xpigors,OU=Google,L=SF,ST=CA,C=US"; const tsi_peer_property* property = tsi_peer_get_property_by_name(&peer, TSI_X509_SUBJECT_PEER_PROPERTY); - GPR_ASSERT(property != nullptr); - GPR_ASSERT(memcmp(property->value.data, expected_subject, - property->value.length) == 0); + ASSERT_NE(property, nullptr); + ASSERT_EQ( + memcmp(property->value.data, expected_subject, property->value.length), + 0); // Check common name const char* expected_cn = "xpigors"; property = tsi_peer_get_property_by_name( &peer, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY); - GPR_ASSERT(property != nullptr); - GPR_ASSERT( - memcmp(property->value.data, expected_cn, property->value.length) == 0); + ASSERT_NE(property, nullptr); + ASSERT_EQ(memcmp(property->value.data, expected_cn, property->value.length), + 0); // Check certificate data property = tsi_peer_get_property_by_name(&peer, TSI_X509_PEM_CERT_PROPERTY); - GPR_ASSERT(property != nullptr); - GPR_ASSERT(memcmp(property->value.data, cert, property->value.length) == 0); + ASSERT_NE(property, nullptr); + ASSERT_EQ(memcmp(property->value.data, cert, property->value.length), 0); // Check DNS - GPR_ASSERT(check_property(&peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "foo.test.domain.com") == 1); - GPR_ASSERT(check_property(&peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "bar.test.domain.com") == 1); - GPR_ASSERT(check_property(&peer, TSI_X509_DNS_PEER_PROPERTY, - "foo.test.domain.com") == 1); - GPR_ASSERT(check_property(&peer, TSI_X509_DNS_PEER_PROPERTY, - "bar.test.domain.com") == 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "foo.test.domain.com"), + 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "bar.test.domain.com"), + 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_DNS_PEER_PROPERTY, "foo.test.domain.com"), + 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_DNS_PEER_PROPERTY, "bar.test.domain.com"), + 1); // Check URI // Note that a valid SPIFFE certificate should only have one URI. - GPR_ASSERT(check_property(&peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "spiffe://foo.com/bar/baz") == 1); - GPR_ASSERT(check_property(&peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "https://foo.test.domain.com/test") == 1); - GPR_ASSERT(check_property(&peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "https://bar.test.domain.com/test") == 1); - GPR_ASSERT(check_property(&peer, TSI_X509_URI_PEER_PROPERTY, - "spiffe://foo.com/bar/baz") == 1); - GPR_ASSERT(check_property(&peer, TSI_X509_URI_PEER_PROPERTY, - "https://foo.test.domain.com/test") == 1); - GPR_ASSERT(check_property(&peer, TSI_X509_URI_PEER_PROPERTY, - "https://bar.test.domain.com/test") == 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "spiffe://foo.com/bar/baz"), + 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "https://foo.test.domain.com/test"), + 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "https://bar.test.domain.com/test"), + 1); + ASSERT_EQ(check_property(&peer, TSI_X509_URI_PEER_PROPERTY, + "spiffe://foo.com/bar/baz"), + 1); + ASSERT_EQ(check_property(&peer, TSI_X509_URI_PEER_PROPERTY, + "https://foo.test.domain.com/test"), + 1); + ASSERT_EQ(check_property(&peer, TSI_X509_URI_PEER_PROPERTY, + "https://bar.test.domain.com/test"), + 1); // Check email address - GPR_ASSERT(check_property(&peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "foo@test.domain.com") == 1); - GPR_ASSERT(check_property(&peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "bar@test.domain.com") == 1); - GPR_ASSERT(check_property(&peer, TSI_X509_EMAIL_PEER_PROPERTY, - "foo@test.domain.com") == 1); - GPR_ASSERT(check_property(&peer, TSI_X509_EMAIL_PEER_PROPERTY, - "bar@test.domain.com") == 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "foo@test.domain.com"), + 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "bar@test.domain.com"), + 1); + ASSERT_EQ(check_property(&peer, TSI_X509_EMAIL_PEER_PROPERTY, + "foo@test.domain.com"), + 1); + ASSERT_EQ(check_property(&peer, TSI_X509_EMAIL_PEER_PROPERTY, + "bar@test.domain.com"), + 1); // Check ip address - GPR_ASSERT(check_property(&peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "192.168.7.1") == 1); - GPR_ASSERT(check_property(&peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "13::17") == 1); - GPR_ASSERT(check_property(&peer, TSI_X509_IP_PEER_PROPERTY, "192.168.7.1") == - 1); - GPR_ASSERT(check_property(&peer, TSI_X509_IP_PEER_PROPERTY, "13::17") == 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "192.168.7.1"), + 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "13::17"), + 1); + ASSERT_EQ(check_property(&peer, TSI_X509_IP_PEER_PROPERTY, "192.168.7.1"), 1); + ASSERT_EQ(check_property(&peer, TSI_X509_IP_PEER_PROPERTY, "13::17"), 1); // Check other fields - GPR_ASSERT(check_property(&peer, - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, - "other types of SAN") == 1); + ASSERT_EQ( + check_property(&peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + "other types of SAN"), + 1); // Free memory gpr_free(cert); tsi_peer_destruct(&peer); @@ -1008,16 +1042,16 @@ void ssl_tsi_test_extract_cert_chain() { memcpy(chain, cert, strlen(cert)); memcpy(chain + strlen(cert), ca, strlen(ca)); STACK_OF(X509)* cert_chain = sk_X509_new_null(); - GPR_ASSERT(cert_chain != nullptr); + ASSERT_NE(cert_chain, nullptr); BIO* bio = BIO_new_mem_buf(chain, strlen(chain)); - GPR_ASSERT(bio != nullptr); + ASSERT_NE(bio, nullptr); STACK_OF(X509_INFO)* certInfos = PEM_X509_INFO_read_bio(bio, nullptr, nullptr, nullptr); - GPR_ASSERT(certInfos != nullptr); + ASSERT_NE(certInfos, nullptr); for (size_t i = 0; i < sk_X509_INFO_num(certInfos); i++) { X509_INFO* certInfo = sk_X509_INFO_value(certInfos, i); if (certInfo->x509 != nullptr) { - GPR_ASSERT(sk_X509_push(cert_chain, certInfo->x509) != 0); + ASSERT_NE(sk_X509_push(cert_chain, certInfo->x509), 0); #if OPENSSL_VERSION_NUMBER >= 0x10100000 X509_up_ref(certInfo->x509); #else @@ -1026,10 +1060,10 @@ void ssl_tsi_test_extract_cert_chain() { } } tsi_peer_property chain_property; - GPR_ASSERT(tsi_ssl_get_cert_chain_contents(cert_chain, &chain_property) == - TSI_OK); - GPR_ASSERT(memcmp(chain, chain_property.value.data, - chain_property.value.length) == 0); + ASSERT_EQ(tsi_ssl_get_cert_chain_contents(cert_chain, &chain_property), + TSI_OK); + ASSERT_EQ( + memcmp(chain, chain_property.value.data, chain_property.value.length), 0); BIO_free(bio); gpr_free(chain); gpr_free(cert); @@ -1053,8 +1087,7 @@ void ssl_tsi_test_do_handshake_with_custom_bio_pair() { tsi_test_fixture_destroy(fixture); } -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(&argc, argv); +TEST(SslTransportSecurityTest, MainTest) { grpc_init(); const size_t number_tls_versions = 2; const tsi_tls_version tls_versions[] = {tsi_tls_version::TSI_TLS1_2, @@ -1092,5 +1125,11 @@ int main(int argc, char** argv) { ssl_tsi_test_do_handshake_with_custom_bio_pair(); } grpc_shutdown(); - return 0; +} + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(&argc, argv); + ::testing::InitGoogleTest(&argc, argv); + grpc::testing::TestGrpcScope grpc_scope; + return RUN_ALL_TESTS(); } diff --git a/test/core/tsi/transport_security_test.cc b/test/core/tsi/transport_security_test.cc index ded71cf4ba6..31491eef573 100644 --- a/test/core/tsi/transport_security_test.cc +++ b/test/core/tsi/transport_security_test.cc @@ -22,6 +22,7 @@ #include +#include #include #include "absl/strings/str_format.h" @@ -265,18 +266,20 @@ static tsi_peer peer_from_cert_name_test_entry( parsed_names dns_entries = parse_names(entry->dns_names); parsed_names ip_entries = parse_names(entry->ip_names); nl = dns_entries.names; - GPR_ASSERT(tsi_construct_peer( - 1 + dns_entries.name_count + ip_entries.name_count, &peer) == - TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, entry->common_name, - &peer.properties[0]) == TSI_OK); + EXPECT_EQ(tsi_construct_peer( + 1 + dns_entries.name_count + ip_entries.name_count, &peer), + TSI_OK); + EXPECT_EQ(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, entry->common_name, + &peer.properties[0]), + TSI_OK); i = 1; while (nl != nullptr) { char* processed = processed_name(nl->name); - GPR_ASSERT(tsi_construct_string_peer_property( - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed, - strlen(nl->name), &peer.properties[i++]) == TSI_OK); + EXPECT_EQ(tsi_construct_string_peer_property( + TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed, + strlen(nl->name), &peer.properties[i++]), + TSI_OK); nl = nl->next; gpr_free(processed); } @@ -284,9 +287,10 @@ static tsi_peer peer_from_cert_name_test_entry( nl = ip_entries.names; while (nl != nullptr) { char* processed = processed_name(nl->name); - GPR_ASSERT(tsi_construct_string_peer_property( - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed, - strlen(nl->name), &peer.properties[i++]) == TSI_OK); + EXPECT_EQ(tsi_construct_string_peer_property( + TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed, + strlen(nl->name), &peer.properties[i++]), + TSI_OK); nl = nl->next; gpr_free(processed); } @@ -304,7 +308,7 @@ std::string cert_name_test_entry_to_string(const cert_name_test_entry* entry) { entry->ip_names != nullptr ? entry->ip_names : ""); } -static void test_peer_matches_name(void) { +TEST(TransportSecurityTest, TestPeerMatchesName) { size_t i = 0; for (i = 0; i < GPR_ARRAY_SIZE(cert_name_test_entries); i++) { const cert_name_test_entry* entry = &cert_name_test_entries[i]; @@ -312,7 +316,7 @@ static void test_peer_matches_name(void) { int result = tsi_ssl_peer_matches_name(&peer, entry->host_name); if (result != entry->expected) { gpr_log(GPR_ERROR, "%s", cert_name_test_entry_to_string(entry).c_str()); - GPR_ASSERT(0); /* Unexpected result. */ + ASSERT_TRUE(0); /* Unexpected result. */ } tsi_peer_destruct(&peer); } @@ -323,7 +327,7 @@ typedef struct { const char* str; } tsi_result_string_pair; -static void test_result_strings(void) { +TEST(TransportSecurityTest, TestResultStrings) { const tsi_result_string_pair results[] = { {TSI_OK, "TSI_OK"}, {TSI_UNKNOWN_ERROR, "TSI_UNKNOWN_ERROR"}, @@ -340,51 +344,50 @@ static void test_result_strings(void) { {TSI_OUT_OF_RESOURCES, "TSI_OUT_OF_RESOURCES"}}; size_t i; for (i = 0; i < GPR_ARRAY_SIZE(results); i++) { - GPR_ASSERT(strcmp(results[i].str, tsi_result_to_string(results[i].res)) == - 0); + ASSERT_STREQ(results[i].str, tsi_result_to_string(results[i].res)); } - GPR_ASSERT(strcmp("UNKNOWN", tsi_result_to_string((tsi_result)42)) == 0); + ASSERT_STREQ("UNKNOWN", tsi_result_to_string((tsi_result)42)); } -static void test_protector_invalid_args(void) { - GPR_ASSERT(tsi_frame_protector_protect(nullptr, nullptr, nullptr, nullptr, - nullptr) == TSI_INVALID_ARGUMENT); - GPR_ASSERT(tsi_frame_protector_protect_flush( - nullptr, nullptr, nullptr, nullptr) == TSI_INVALID_ARGUMENT); - GPR_ASSERT(tsi_frame_protector_unprotect(nullptr, nullptr, nullptr, nullptr, - nullptr) == TSI_INVALID_ARGUMENT); +TEST(TransportSecurityTest, TestProtectorInvalidArgs) { + ASSERT_EQ( + tsi_frame_protector_protect(nullptr, nullptr, nullptr, nullptr, nullptr), + TSI_INVALID_ARGUMENT); + ASSERT_EQ( + tsi_frame_protector_protect_flush(nullptr, nullptr, nullptr, nullptr), + TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_frame_protector_unprotect(nullptr, nullptr, nullptr, nullptr, + nullptr), + TSI_INVALID_ARGUMENT); } -static void test_handshaker_invalid_args(void) { - GPR_ASSERT(tsi_handshaker_get_result(nullptr) == TSI_INVALID_ARGUMENT); - GPR_ASSERT(tsi_handshaker_extract_peer(nullptr, nullptr) == - TSI_INVALID_ARGUMENT); - GPR_ASSERT(tsi_handshaker_create_frame_protector(nullptr, nullptr, nullptr) == - TSI_INVALID_ARGUMENT); - GPR_ASSERT(tsi_handshaker_process_bytes_from_peer( - nullptr, nullptr, nullptr) == TSI_INVALID_ARGUMENT); - GPR_ASSERT(tsi_handshaker_get_bytes_to_send_to_peer( - nullptr, nullptr, nullptr) == TSI_INVALID_ARGUMENT); - GPR_ASSERT(tsi_handshaker_next(nullptr, nullptr, 0, nullptr, nullptr, nullptr, - nullptr, nullptr) == TSI_INVALID_ARGUMENT); +TEST(TransportSecurityTest, TestHandshakerInvalidArgs) { + ASSERT_EQ(tsi_handshaker_get_result(nullptr), TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_handshaker_extract_peer(nullptr, nullptr), + TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_handshaker_create_frame_protector(nullptr, nullptr, nullptr), + TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_handshaker_process_bytes_from_peer(nullptr, nullptr, nullptr), + TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_handshaker_get_bytes_to_send_to_peer(nullptr, nullptr, nullptr), + TSI_INVALID_ARGUMENT); + ASSERT_EQ(tsi_handshaker_next(nullptr, nullptr, 0, nullptr, nullptr, nullptr, + nullptr, nullptr), + TSI_INVALID_ARGUMENT); } -static void test_handshaker_invalid_state(void) { +TEST(TransportSecurityTest, TestHandshakerInvalidState) { tsi_handshaker* h = tsi_create_fake_handshaker(0); tsi_peer peer; tsi_frame_protector* p; - GPR_ASSERT(tsi_handshaker_extract_peer(h, &peer) == TSI_FAILED_PRECONDITION); - GPR_ASSERT(tsi_handshaker_create_frame_protector(h, nullptr, &p) == - TSI_FAILED_PRECONDITION); + ASSERT_EQ(tsi_handshaker_extract_peer(h, &peer), TSI_FAILED_PRECONDITION); + ASSERT_EQ(tsi_handshaker_create_frame_protector(h, nullptr, &p), + TSI_FAILED_PRECONDITION); tsi_handshaker_destroy(h); } int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); - test_peer_matches_name(); - test_result_strings(); - test_protector_invalid_args(); - test_handshaker_invalid_args(); - test_handshaker_invalid_state(); - return 0; + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 5c4493da790..ef36f623add 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -64,31 +64,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "alts_counter_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": true - }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "alts_crypt_test", + "name": "alts_security_connector_test", "platforms": [ "linux", "mac", @@ -112,14 +88,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "alts_crypter_test", + "name": "auth_context_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -136,14 +112,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "alts_frame_protector_test", + "name": "b64_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -160,7 +136,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "alts_grpc_record_protocol_test", + "name": "bad_server_response_test", "platforms": [ "linux", "mac", @@ -175,8 +151,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -184,12 +159,11 @@ "flaky": false, "gtest": false, "language": "c", - "name": "alts_handshaker_client_test", + "name": "bad_ssl_alpn_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "uses_polling": true }, @@ -199,8 +173,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -208,12 +181,11 @@ "flaky": false, "gtest": false, "language": "c", - "name": "alts_iovec_record_protocol_test", + "name": "bad_ssl_cert_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "uses_polling": true }, @@ -232,14 +204,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "alts_security_connector_test", + "name": "bin_decoder_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -256,14 +228,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "alts_tsi_handshaker_test", + "name": "bin_encoder_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -280,7 +252,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "alts_tsi_utils_test", + "name": "buffer_list_test", "platforms": [ "linux", "mac", @@ -304,14 +276,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "alts_zero_copy_grpc_protector_test", + "name": "c_slice_buffer_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -328,7 +300,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "auth_context_test", + "name": "channel_stack_test", "platforms": [ "linux", "mac", @@ -352,14 +324,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "b64_test", + "name": "check_gcp_environment_linux_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -376,7 +348,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "bad_server_response_test", + "name": "check_gcp_environment_windows_test", "platforms": [ "linux", "mac", @@ -399,29 +371,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "bad_ssl_alpn_test", - "platforms": [ - "linux", - "mac", - "posix" - ], - "uses_polling": true - }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "bad_ssl_cert_test", + "name": "client_ssl_test", "platforms": [ "linux", "mac", @@ -444,7 +394,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "bin_decoder_test", + "name": "cmdline_test", "platforms": [ "linux", "mac", @@ -459,8 +409,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -468,14 +417,13 @@ "flaky": false, "gtest": false, "language": "c", - "name": "bin_encoder_test", + "name": "combiner_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -492,14 +440,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "buffer_list_test", + "name": "compression_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -516,14 +464,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "c_slice_buffer_test", + "name": "connection_refused_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -540,7 +488,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "channel_stack_test", + "name": "cpu_test", "platforms": [ "linux", "mac", @@ -555,8 +503,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -564,12 +511,11 @@ "flaky": false, "gtest": false, "language": "c", - "name": "check_gcp_environment_linux_test", + "name": "dualstack_socket_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "uses_polling": true }, @@ -588,7 +534,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "check_gcp_environment_windows_test", + "name": "endpoint_pair_test", "platforms": [ "linux", "mac", @@ -597,28 +543,6 @@ ], "uses_polling": true }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "client_ssl_test", - "platforms": [ - "linux", - "mac", - "posix" - ], - "uses_polling": true - }, { "args": [], "benchmark": false, @@ -634,7 +558,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "cmdline_test", + "name": "env_test", "platforms": [ "linux", "mac", @@ -657,7 +581,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "combiner_test", + "name": "fd_conservation_posix_test", "platforms": [ "linux", "mac", @@ -671,8 +595,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -680,14 +603,13 @@ "flaky": false, "gtest": false, "language": "c", - "name": "compression_test", + "name": "fd_posix_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -695,8 +617,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -704,12 +625,11 @@ "flaky": false, "gtest": false, "language": "c", - "name": "connection_refused_test", + "name": "fling_stream_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "uses_polling": true }, @@ -719,8 +639,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -728,14 +647,13 @@ "flaky": false, "gtest": false, "language": "c", - "name": "cpu_test", + "name": "fling_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -751,13 +669,13 @@ "flaky": false, "gtest": false, "language": "c", - "name": "dualstack_socket_test", + "name": "fork_test", "platforms": [ "linux", "mac", "posix" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -774,7 +692,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "endpoint_pair_test", + "name": "format_request_test", "platforms": [ "linux", "mac", @@ -798,14 +716,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "env_test", + "name": "goaway_server_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -822,7 +740,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "fake_transport_security_test", + "name": "grpc_alts_credentials_options_test", "platforms": [ "linux", "mac", @@ -837,29 +755,8 @@ "ci_platforms": [ "linux", "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "fd_conservation_posix_test", - "platforms": [ - "linux", - "mac", - "posix" - ], - "uses_polling": true - }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -867,11 +764,12 @@ "flaky": false, "gtest": false, "language": "c", - "name": "fd_posix_test", + "name": "grpc_ipv6_loopback_available_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "uses_polling": true }, @@ -889,7 +787,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "fling_stream_test", + "name": "handshake_server_with_readahead_handshaker_test", "platforms": [ "linux", "mac", @@ -903,7 +801,8 @@ "ci_platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -911,13 +810,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "fling_test", + "name": "histogram_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -925,7 +825,8 @@ "ci_platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -933,11 +834,12 @@ "flaky": false, "gtest": false, "language": "c", - "name": "fork_test", + "name": "host_port_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "uses_polling": false }, @@ -956,14 +858,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "format_request_test", + "name": "hpack_encoder_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -980,14 +882,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "frame_handler_test", + "name": "inproc_callback_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -1004,7 +906,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "goaway_server_test", + "name": "invalid_call_argument_test", "platforms": [ "linux", "mac", @@ -1028,14 +930,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "grpc_alts_credentials_options_test", + "name": "json_token_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -1052,14 +954,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "grpc_ipv6_loopback_available_test", + "name": "jwt_verifier_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -1067,7 +969,8 @@ "ci_platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1075,13 +978,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "handshake_server_with_readahead_handshaker_test", + "name": "load_file_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -1098,7 +1002,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "histogram_test", + "name": "message_compress_test", "platforms": [ "linux", "mac", @@ -1122,7 +1026,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "host_port_test", + "name": "minimal_stack_is_minimal_test", "platforms": [ "linux", "mac", @@ -1146,7 +1050,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "hpack_encoder_test", + "name": "mpmcqueue_test", "platforms": [ "linux", "mac", @@ -1161,8 +1065,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1170,12 +1073,11 @@ "flaky": false, "gtest": false, "language": "c", - "name": "inproc_callback_test", + "name": "mpscq_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "uses_polling": false }, @@ -1194,7 +1096,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "invalid_call_argument_test", + "name": "multiple_server_queues_test", "platforms": [ "linux", "mac", @@ -1218,7 +1120,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "json_token_test", + "name": "murmur_hash_test", "platforms": [ "linux", "mac", @@ -1242,14 +1144,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "jwt_verifier_test", + "name": "no_server_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -1266,7 +1168,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "load_file_test", + "name": "parser_test", "platforms": [ "linux", "mac", @@ -1290,7 +1192,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "message_compress_test", + "name": "percent_encoding_test", "platforms": [ "linux", "mac", @@ -1314,23 +1216,24 @@ "flaky": false, "gtest": false, "language": "c", - "name": "minimal_stack_is_minimal_test", + "name": "public_headers_must_be_c89", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": false + "uses_polling": true }, { - "args": [], + "args": [ + "--resolver=ares" + ], "benchmark": false, "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1338,17 +1241,18 @@ "flaky": false, "gtest": false, "language": "c", - "name": "mpmcqueue_test", + "name": "resolve_address_using_ares_resolver_posix_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], - "uses_polling": false + "uses_polling": true }, { - "args": [], + "args": [ + "--resolver=native" + ], "benchmark": false, "ci_platforms": [ "linux", @@ -1361,13 +1265,13 @@ "flaky": false, "gtest": false, "language": "c", - "name": "mpscq_test", + "name": "resolve_address_using_native_resolver_posix_test", "platforms": [ "linux", "mac", "posix" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -1384,7 +1288,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "multiple_server_queues_test", + "name": "secure_endpoint_test", "platforms": [ "linux", "mac", @@ -1408,14 +1312,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "murmur_hash_test", + "name": "security_connector_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -1423,8 +1327,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1432,12 +1335,11 @@ "flaky": false, "gtest": false, "language": "c", - "name": "no_server_test", + "name": "server_ssl_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "uses_polling": true }, @@ -1456,7 +1358,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "parser_test", + "name": "slice_string_helpers_test", "platforms": [ "linux", "mac", @@ -1471,8 +1373,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1480,14 +1381,13 @@ "flaky": false, "gtest": false, "language": "c", - "name": "percent_encoding_test", + "name": "socket_utils_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -1504,48 +1404,23 @@ "flaky": false, "gtest": false, "language": "c", - "name": "public_headers_must_be_c89", + "name": "spinlock_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true - }, - { - "args": [ - "--resolver=ares" - ], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "resolve_address_using_ares_resolver_posix_test", - "platforms": [ - "linux", - "mac", - "posix" - ], - "uses_polling": true + "uses_polling": false }, { - "args": [ - "--resolver=native" - ], + "args": [], "benchmark": false, "ci_platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1553,11 +1428,12 @@ "flaky": false, "gtest": false, "language": "c", - "name": "resolve_address_using_native_resolver_posix_test", + "name": "ssl_credentials_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "uses_polling": true }, @@ -1576,14 +1452,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "secure_endpoint_test", + "name": "status_conversion_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -1600,7 +1476,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "security_connector_test", + "name": "stream_map_test", "platforms": [ "linux", "mac", @@ -1615,7 +1491,8 @@ "ci_platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1623,13 +1500,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "server_ssl_test", + "name": "string_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -1646,7 +1524,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "slice_string_helpers_test", + "name": "sync_test", "platforms": [ "linux", "mac", @@ -1669,7 +1547,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "socket_utils_test", + "name": "tcp_client_posix_test", "platforms": [ "linux", "mac", @@ -1682,9 +1560,7 @@ "benchmark": false, "ci_platforms": [ "linux", - "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1692,14 +1568,12 @@ "flaky": false, "gtest": false, "language": "c", - "name": "spinlock_test", + "name": "tcp_posix_test", "platforms": [ "linux", - "mac", - "posix", - "windows" + "posix" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -1707,8 +1581,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1716,12 +1589,11 @@ "flaky": false, "gtest": false, "language": "c", - "name": "ssl_credentials_test", + "name": "tcp_server_posix_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "uses_polling": true }, @@ -1731,7 +1603,8 @@ "ci_platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1739,13 +1612,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "ssl_transport_security_test", + "name": "test_core_gpr_time_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -1762,7 +1636,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "status_conversion_test", + "name": "test_core_iomgr_time_averaged_stats_test", "platforms": [ "linux", "mac", @@ -1786,14 +1660,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "stream_map_test", + "name": "test_core_iomgr_timer_heap_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -1810,7 +1684,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "string_test", + "name": "test_core_iomgr_timer_list_test", "platforms": [ "linux", "mac", @@ -1834,7 +1708,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "sync_test", + "name": "thd_test", "platforms": [ "linux", "mac", @@ -1849,7 +1723,8 @@ "ci_platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1857,20 +1732,23 @@ "flaky": false, "gtest": false, "language": "c", - "name": "tcp_client_posix_test", + "name": "threadpool_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], "benchmark": false, "ci_platforms": [ "linux", - "posix" + "mac", + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -1878,12 +1756,14 @@ "flaky": false, "gtest": false, "language": "c", - "name": "tcp_posix_test", + "name": "varint_test", "platforms": [ "linux", - "posix" + "mac", + "posix", + "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -1891,21 +1771,23 @@ "ci_platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [], "flaky": false, - "gtest": false, - "language": "c", - "name": "tcp_server_posix_test", + "gtest": true, + "language": "c++", + "name": "activity_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], - "uses_polling": true + "uses_polling": false }, { "args": [], @@ -1913,23 +1795,21 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [], "flaky": false, - "gtest": false, - "language": "c", - "name": "test_core_gpr_time_test", + "gtest": true, + "language": "c++", + "name": "address_sorting_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -1937,23 +1817,21 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [], "flaky": false, - "gtest": false, - "language": "c", - "name": "test_core_iomgr_time_averaged_stats_test", + "gtest": true, + "language": "c++", + "name": "address_sorting_test_unsecure", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -1968,16 +1846,16 @@ "exclude_configs": [], "exclude_iomgrs": [], "flaky": false, - "gtest": false, - "language": "c", - "name": "test_core_iomgr_timer_heap_test", + "gtest": true, + "language": "c++", + "name": "admin_services_end2end_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -1985,47 +1863,41 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [], "flaky": false, - "gtest": false, - "language": "c", - "name": "test_core_iomgr_timer_list_test", + "gtest": true, + "language": "c++", + "name": "alarm_test", "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], - "uses_polling": false + "uses_polling": true }, { "args": [], "benchmark": false, "ci_platforms": [ "linux", - "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [], "flaky": false, - "gtest": false, - "language": "c", - "name": "thd_test", + "gtest": true, + "language": "c++", + "name": "alts_concurrent_connectivity_test", "platforms": [ "linux", - "mac", - "posix", - "windows" + "posix" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -2040,16 +1912,16 @@ "exclude_configs": [], "exclude_iomgrs": [], "flaky": false, - "gtest": false, - "language": "c", - "name": "threadpool_test", + "gtest": true, + "language": "c++", + "name": "alts_counter_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -2064,9 +1936,9 @@ "exclude_configs": [], "exclude_iomgrs": [], "flaky": false, - "gtest": false, - "language": "c", - "name": "transport_security_common_api_test", + "gtest": true, + "language": "c++", + "name": "alts_crypt_test", "platforms": [ "linux", "mac", @@ -2088,9 +1960,9 @@ "exclude_configs": [], "exclude_iomgrs": [], "flaky": false, - "gtest": false, - "language": "c", - "name": "transport_security_test", + "gtest": true, + "language": "c++", + "name": "alts_crypter_test", "platforms": [ "linux", "mac", @@ -2112,16 +1984,16 @@ "exclude_configs": [], "exclude_iomgrs": [], "flaky": false, - "gtest": false, - "language": "c", - "name": "varint_test", + "gtest": true, + "language": "c++", + "name": "alts_frame_protector_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -2138,14 +2010,14 @@ "flaky": false, "gtest": true, "language": "c++", - "name": "activity_test", + "name": "alts_grpc_record_protocol_test", "platforms": [ "linux", "mac", "posix", "windows" ], - "uses_polling": false + "uses_polling": true }, { "args": [], @@ -2153,7 +2025,8 @@ "ci_platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -2161,11 +2034,12 @@ "flaky": false, "gtest": true, "language": "c++", - "name": "address_sorting_test", + "name": "alts_handshaker_client_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "uses_polling": true }, @@ -2175,7 +2049,8 @@ "ci_platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -2183,11 +2058,12 @@ "flaky": false, "gtest": true, "language": "c++", - "name": "address_sorting_test_unsecure", + "name": "alts_iovec_record_protocol_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "uses_polling": true }, @@ -2206,7 +2082,7 @@ "flaky": false, "gtest": true, "language": "c++", - "name": "admin_services_end2end_test", + "name": "alts_tsi_handshaker_test", "platforms": [ "linux", "mac", @@ -2221,7 +2097,8 @@ "ci_platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -2229,11 +2106,12 @@ "flaky": false, "gtest": true, "language": "c++", - "name": "alarm_test", + "name": "alts_tsi_utils_test", "platforms": [ "linux", "mac", - "posix" + "posix", + "windows" ], "uses_polling": true }, @@ -2242,7 +2120,9 @@ "benchmark": false, "ci_platforms": [ "linux", - "posix" + "mac", + "posix", + "windows" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -2250,10 +2130,12 @@ "flaky": false, "gtest": true, "language": "c++", - "name": "alts_concurrent_connectivity_test", + "name": "alts_util_test", "platforms": [ "linux", - "posix" + "mac", + "posix", + "windows" ], "uses_polling": true }, @@ -2272,7 +2154,7 @@ "flaky": false, "gtest": true, "language": "c++", - "name": "alts_util_test", + "name": "alts_zero_copy_grpc_protector_test", "platforms": [ "linux", "mac", @@ -3883,6 +3765,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "fake_transport_security_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, @@ -3979,6 +3885,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "frame_handler_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, @@ -6613,6 +6543,28 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "ssl_transport_security_test", + "platforms": [ + "linux", + "mac", + "posix" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, @@ -7421,6 +7373,54 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "transport_security_common_api_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "transport_security_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false,