From 78888d786129e207a4c0cc535a0ff38d86fb4a14 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 17 Oct 2019 18:55:00 +0200 Subject: [PATCH] avoid thread local unitialized problem under GRPC_PTHREAD_TLS --- test/core/backoff/backoff_test.cc | 3 +++ test/core/bad_client/tests/large_metadata.cc | 3 ++- test/core/surface/byte_buffer_reader_test.cc | 2 ++ test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc | 2 ++ .../alts_grpc_record_protocol_test.cc | 2 ++ .../alts_zero_copy_grpc_protector_test.cc | 2 ++ test/cpp/end2end/client_callback_end2end_test.cc | 5 ++++- 7 files changed, 17 insertions(+), 2 deletions(-) diff --git a/test/core/backoff/backoff_test.cc b/test/core/backoff/backoff_test.cc index 8fd120e0428..f81b3fa9cbe 100644 --- a/test/core/backoff/backoff_test.cc +++ b/test/core/backoff/backoff_test.cc @@ -21,6 +21,7 @@ #include #include +#include #include #include "test/core/util/test_config.h" @@ -171,7 +172,9 @@ TEST(BackOffTest, JitterBackOff) { } // namespace grpc int main(int argc, char** argv) { + grpc_init(); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); + grpc_shutdown(); } diff --git a/test/core/bad_client/tests/large_metadata.cc b/test/core/bad_client/tests/large_metadata.cc index 686a701dfed..8206afa5afb 100644 --- a/test/core/bad_client/tests/large_metadata.cc +++ b/test/core/bad_client/tests/large_metadata.cc @@ -140,7 +140,7 @@ static void server_verifier_sends_too_much_metadata( int main(int argc, char** argv) { int i; - + grpc_init(); grpc::testing::TestEnvironment env(argc, argv); // Test sending more metadata than the server will accept. @@ -173,5 +173,6 @@ int main(int argc, char** argv) { GRPC_RUN_BAD_CLIENT_TEST(server_verifier_sends_too_much_metadata, rst_stream_client_validator, PFX_TOO_MUCH_METADATA_FROM_SERVER_STR, 0); + grpc_shutdown(); return 0; } diff --git a/test/core/surface/byte_buffer_reader_test.cc b/test/core/surface/byte_buffer_reader_test.cc index bc368c49657..fc2654426d7 100644 --- a/test/core/surface/byte_buffer_reader_test.cc +++ b/test/core/surface/byte_buffer_reader_test.cc @@ -334,6 +334,7 @@ static void test_byte_buffer_copy(void) { } int main(int argc, char** argv) { + grpc_init(); grpc::testing::TestEnvironment env(argc, argv); test_read_one_slice(); test_read_one_slice_malloc(); @@ -347,5 +348,6 @@ int main(int argc, char** argv) { test_byte_buffer_from_reader(); test_byte_buffer_copy(); test_readall(); + grpc_shutdown(); return 0; } 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 2d5a2b21ffc..2a3ea934ac0 100644 --- a/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc +++ b/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc @@ -68,7 +68,9 @@ static void deserialize_response_test() { int main(int /*argc*/, char** /*argv*/) { /* Tests. */ + grpc_init(); deserialize_response_test(); convert_to_tsi_result_test(); + grpc_shutdown(); return 0; } 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 11933f1fa91..13837ccaa95 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 @@ -445,6 +445,7 @@ static void alts_grpc_record_protocol_tests( } int main(int /*argc*/, char** /*argv*/) { + grpc_init(); alts_grpc_record_protocol_tests( &test_fixture_integrity_only_no_rekey_no_extra_copy_create); alts_grpc_record_protocol_tests(&test_fixture_integrity_only_rekey_create); @@ -453,6 +454,7 @@ int main(int /*argc*/, char** /*argv*/) { alts_grpc_record_protocol_tests( &test_fixture_privacy_integrity_no_rekey_create); alts_grpc_record_protocol_tests(&test_fixture_privacy_integrity_rekey_create); + grpc_shutdown(); return 0; } 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 f730c9f0cff..9a426b055b4 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 @@ -296,6 +296,7 @@ static void alts_zero_copy_protector_seal_unseal_large_buffer_tests( } int main(int /*argc*/, char** /*argv*/) { + grpc_init(); alts_zero_copy_protector_seal_unseal_small_buffer_tests( /*enable_extra_copy=*/false); alts_zero_copy_protector_seal_unseal_small_buffer_tests( @@ -304,5 +305,6 @@ int main(int /*argc*/, char** /*argv*/) { /*enable_extra_copy=*/false); alts_zero_copy_protector_seal_unseal_large_buffer_tests( /*enable_extra_copy=*/true); + grpc_shutdown(); return 0; } diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index 8f1f3b07500..1d3f531c124 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -1386,7 +1386,10 @@ INSTANTIATE_TEST_SUITE_P(ClientCallbackEnd2endTest, ClientCallbackEnd2endTest, } // namespace grpc int main(int argc, char** argv) { + grpc_init(); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; }