From 03412ee9de902e378bc4cea933397ebe5faddc29 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 28 Nov 2017 18:06:23 -0800 Subject: Remove TLS_NO_SUPPORT and always use GPR_TLS. Reorder statements in grpc_init and grpc_shutdown. Add grpc_init and grpc_shutdown in failing test/cpp tests --- test/core/end2end/fuzzers/api_fuzzer.cc | 2 +- test/core/http/httpscli_test.cc | 6 +++--- test/core/slice/percent_decode_fuzzer.cc | 3 +++ test/core/slice/percent_encode_fuzzer.cc | 3 +++ test/core/util/one_corpus_entry_fuzzer.cc | 2 -- test/cpp/common/channel_arguments_test.cc | 5 ++++- test/cpp/grpclb/grpclb_api_test.cc | 6 +++++- test/cpp/server/server_builder_test.cc | 7 ++++++- test/cpp/util/byte_buffer_test.cc | 6 +++++- test/cpp/util/slice_test.cc | 6 +++++- 10 files changed, 35 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc index f3127e92cc..ce916bd341 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.cc +++ b/test/core/end2end/fuzzers/api_fuzzer.cc @@ -745,8 +745,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { input_stream inp = {data, data + size}; grpc_tcp_client_connect_impl = my_tcp_client_connect; gpr_now_impl = now_impl; - grpc_timer_manager_set_threading(false); grpc_init(); + grpc_timer_manager_set_threading(false); { grpc_core::ExecCtx _local_exec_ctx; grpc_executor_set_threading(false); diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index ee2bff18db..418afb6992 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -89,7 +89,7 @@ static void test_get(int port) { "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops), &worker, n_seconds_time(1)))); gpr_mu_unlock(g_mu); - + grpc_core::ExecCtx::Get()->Flush(); gpr_mu_lock(g_mu); } gpr_mu_unlock(g_mu); @@ -129,7 +129,7 @@ static void test_post(int port) { "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops), &worker, n_seconds_time(1)))); gpr_mu_unlock(g_mu); - + grpc_core::ExecCtx::Get()->Flush(); gpr_mu_lock(g_mu); } gpr_mu_unlock(g_mu); @@ -144,7 +144,6 @@ static void destroy_pops(void* p, grpc_error* error) { int main(int argc, char** argv) { grpc_closure destroyed; - grpc_core::ExecCtx _local_exec_ctx; gpr_subprocess* server; char* me = argv[0]; char* lslash = strrchr(me, '/'); @@ -196,6 +195,7 @@ int main(int argc, char** argv) { test_post(port); { + grpc_core::ExecCtx _local_exec_ctx; grpc_httpcli_context_destroy(&g_context); GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops, grpc_schedule_on_exec_ctx); diff --git a/test/core/slice/percent_decode_fuzzer.cc b/test/core/slice/percent_decode_fuzzer.cc index 3603177c47..81eb031014 100644 --- a/test/core/slice/percent_decode_fuzzer.cc +++ b/test/core/slice/percent_decode_fuzzer.cc @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -31,6 +32,7 @@ bool leak_check = true; extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { struct grpc_memory_counters counters; + grpc_init(); grpc_memory_counters_init(); grpc_slice input = grpc_slice_from_copied_buffer((const char*)data, size); grpc_slice output; @@ -46,6 +48,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_slice_unref(input); counters = grpc_memory_counters_snapshot(); grpc_memory_counters_destroy(); + grpc_shutdown(); GPR_ASSERT(counters.total_size_relative == 0); return 0; } diff --git a/test/core/slice/percent_encode_fuzzer.cc b/test/core/slice/percent_encode_fuzzer.cc index c8e3849fc8..201ae2790e 100644 --- a/test/core/slice/percent_encode_fuzzer.cc +++ b/test/core/slice/percent_encode_fuzzer.cc @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -31,6 +32,7 @@ bool leak_check = true; static void test(const uint8_t* data, size_t size, const uint8_t* dict) { struct grpc_memory_counters counters; + grpc_init(); grpc_memory_counters_init(); grpc_slice input = grpc_slice_from_copied_buffer((const char*)data, size); grpc_slice output = grpc_percent_encode_slice(input, dict); @@ -48,6 +50,7 @@ static void test(const uint8_t* data, size_t size, const uint8_t* dict) { grpc_slice_unref(permissive_decoded_output); counters = grpc_memory_counters_snapshot(); grpc_memory_counters_destroy(); + grpc_shutdown(); GPR_ASSERT(counters.total_size_relative == 0); } diff --git a/test/core/util/one_corpus_entry_fuzzer.cc b/test/core/util/one_corpus_entry_fuzzer.cc index fc75125a9b..c745eb5dc6 100644 --- a/test/core/util/one_corpus_entry_fuzzer.cc +++ b/test/core/util/one_corpus_entry_fuzzer.cc @@ -36,12 +36,10 @@ int main(int argc, char** argv) { /* TODO(yashkt) Calling grpc_init breaks tests. Fix the tests and replace * grpc_core::ExecCtx::GlobalInit with grpc_init and GlobalShutdown with * grpc_shutdown */ - grpc_core::ExecCtx::GlobalInit(); GPR_ASSERT( GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer))); LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer), GRPC_SLICE_LENGTH(buffer)); - grpc_core::ExecCtx::GlobalShutdown(); grpc_core::ExecCtx::GlobalInit(); grpc_slice_unref(buffer); grpc_core::ExecCtx::GlobalShutdown(); diff --git a/test/cpp/common/channel_arguments_test.cc b/test/cpp/common/channel_arguments_test.cc index d6ed2e5aa2..f330c01281 100644 --- a/test/cpp/common/channel_arguments_test.cc +++ b/test/cpp/common/channel_arguments_test.cc @@ -249,5 +249,8 @@ TEST_F(ChannelArgumentsTest, SetUserAgentPrefix) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + grpc_init(); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; } diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc index 7b62080b49..a494d6f519 100644 --- a/test/cpp/grpclb/grpclb_api_test.cc +++ b/test/cpp/grpclb/grpclb_api_test.cc @@ -17,6 +17,7 @@ */ #include +#include #include #include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h" @@ -135,5 +136,8 @@ TEST_F(GrpclbTest, ParseResponseServerList) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + grpc_init(); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; } diff --git a/test/cpp/server/server_builder_test.cc b/test/cpp/server/server_builder_test.cc index d18459cec9..694ce549c0 100644 --- a/test/cpp/server/server_builder_test.cc +++ b/test/cpp/server/server_builder_test.cc @@ -22,6 +22,8 @@ #include #include +#include + #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/util/port.h" @@ -77,5 +79,8 @@ TEST(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + grpc_init(); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; } diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc index 8fb51bc663..d603b289c8 100644 --- a/test/cpp/util/byte_buffer_test.cc +++ b/test/cpp/util/byte_buffer_test.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -109,5 +110,8 @@ TEST_F(ByteBufferTest, SerializationMakesCopy) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + grpc_init(); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; } diff --git a/test/cpp/util/slice_test.cc b/test/cpp/util/slice_test.cc index 8a8962d7ee..c2e55f3374 100644 --- a/test/cpp/util/slice_test.cc +++ b/test/cpp/util/slice_test.cc @@ -18,6 +18,7 @@ #include +#include #include #include @@ -127,5 +128,8 @@ TEST_F(SliceTest, Cslice) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + grpc_init(); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; } -- cgit v1.2.3