gtestify test/core/channel (#30201)

* gtestify test/core/channel

* Update by review

* Fix 2
pull/30195/head
Esun Kim 3 years ago committed by GitHub
parent dfe6a8b903
commit 98c423503c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 128
      CMakeLists.txt
  2. 38
      build_autogenerated.yaml
  3. 2
      test/core/channel/BUILD
  4. 43
      test/core/channel/channel_stack_test.cc
  5. 120
      test/core/channel/minimal_stack_is_minimal_test.cc
  6. 96
      tools/run_tests/generated/tests.json

128
CMakeLists.txt generated

@ -790,7 +790,6 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_c bin_encoder_test) add_dependencies(buildtests_c bin_encoder_test)
add_dependencies(buildtests_c buffer_list_test) add_dependencies(buildtests_c buffer_list_test)
add_dependencies(buildtests_c c_slice_buffer_test) add_dependencies(buildtests_c c_slice_buffer_test)
add_dependencies(buildtests_c channel_stack_test)
add_dependencies(buildtests_c cmdline_test) add_dependencies(buildtests_c cmdline_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c combiner_test) add_dependencies(buildtests_c combiner_test)
@ -824,7 +823,6 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_c invalid_call_argument_test) add_dependencies(buildtests_c invalid_call_argument_test)
add_dependencies(buildtests_c load_file_test) add_dependencies(buildtests_c load_file_test)
add_dependencies(buildtests_c message_compress_test) add_dependencies(buildtests_c message_compress_test)
add_dependencies(buildtests_c minimal_stack_is_minimal_test)
add_dependencies(buildtests_c multiple_server_queues_test) add_dependencies(buildtests_c multiple_server_queues_test)
add_dependencies(buildtests_c murmur_hash_test) add_dependencies(buildtests_c murmur_hash_test)
add_dependencies(buildtests_c no_server_test) add_dependencies(buildtests_c no_server_test)
@ -920,6 +918,7 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_cxx channel_creds_registry_test) add_dependencies(buildtests_cxx channel_creds_registry_test)
add_dependencies(buildtests_cxx channel_filter_test) add_dependencies(buildtests_cxx channel_filter_test)
add_dependencies(buildtests_cxx channel_stack_builder_test) add_dependencies(buildtests_cxx channel_stack_builder_test)
add_dependencies(buildtests_cxx channel_stack_test)
add_dependencies(buildtests_cxx channel_trace_test) add_dependencies(buildtests_cxx channel_trace_test)
add_dependencies(buildtests_cxx channelz_registry_test) add_dependencies(buildtests_cxx channelz_registry_test)
add_dependencies(buildtests_cxx channelz_service_test) add_dependencies(buildtests_cxx channelz_service_test)
@ -1063,6 +1062,7 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_cxx memory_quota_test) add_dependencies(buildtests_cxx memory_quota_test)
add_dependencies(buildtests_cxx message_allocator_end2end_test) add_dependencies(buildtests_cxx message_allocator_end2end_test)
add_dependencies(buildtests_cxx metadata_map_test) add_dependencies(buildtests_cxx metadata_map_test)
add_dependencies(buildtests_cxx minimal_stack_is_minimal_test)
add_dependencies(buildtests_cxx miscompile_with_no_unique_address_test) add_dependencies(buildtests_cxx miscompile_with_no_unique_address_test)
add_dependencies(buildtests_cxx mock_stream_test) add_dependencies(buildtests_cxx mock_stream_test)
add_dependencies(buildtests_cxx mock_test) add_dependencies(buildtests_cxx mock_test)
@ -4554,33 +4554,6 @@ target_link_libraries(c_slice_buffer_test
) )
endif()
if(gRPC_BUILD_TESTS)
add_executable(channel_stack_test
test/core/channel/channel_stack_test.cc
)
target_include_directories(channel_stack_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(channel_stack_test
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif() endif()
if(gRPC_BUILD_TESTS) if(gRPC_BUILD_TESTS)
@ -5178,33 +5151,6 @@ 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
)
target_include_directories(minimal_stack_is_minimal_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(minimal_stack_is_minimal_test
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif() endif()
if(gRPC_BUILD_TESTS) if(gRPC_BUILD_TESTS)
@ -7811,6 +7757,41 @@ target_link_libraries(channel_stack_builder_test
) )
endif()
if(gRPC_BUILD_TESTS)
add_executable(channel_stack_test
test/core/channel/channel_stack_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(channel_stack_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(channel_stack_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif() endif()
if(gRPC_BUILD_TESTS) if(gRPC_BUILD_TESTS)
@ -13033,6 +13014,41 @@ target_link_libraries(metadata_map_test
) )
endif()
if(gRPC_BUILD_TESTS)
add_executable(minimal_stack_is_minimal_test
test/core/channel/minimal_stack_is_minimal_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(minimal_stack_is_minimal_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(minimal_stack_is_minimal_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif() endif()
if(gRPC_BUILD_TESTS) if(gRPC_BUILD_TESTS)

@ -3291,15 +3291,6 @@ targets:
deps: deps:
- grpc_test_util - grpc_test_util
uses_polling: false uses_polling: false
- name: channel_stack_test
build: test
language: c
headers: []
src:
- test/core/channel/channel_stack_test.cc
deps:
- grpc_test_util
uses_polling: false
- name: cmdline_test - name: cmdline_test
build: test build: test
language: c language: c
@ -3528,15 +3519,6 @@ targets:
deps: deps:
- grpc_test_util - grpc_test_util
uses_polling: false uses_polling: false
- name: minimal_stack_is_minimal_test
build: test
language: c
headers: []
src:
- test/core/channel/minimal_stack_is_minimal_test.cc
deps:
- grpc_test_util
uses_polling: false
- name: multiple_server_queues_test - name: multiple_server_queues_test
build: test build: test
language: c language: c
@ -4628,6 +4610,16 @@ targets:
- test/core/channel/channel_stack_builder_test.cc - test/core/channel/channel_stack_builder_test.cc
deps: deps:
- grpc_test_util - grpc_test_util
- name: channel_stack_test
gtest: true
build: test
language: c++
headers: []
src:
- test/core/channel/channel_stack_test.cc
deps:
- grpc_test_util
uses_polling: false
- name: channel_trace_test - name: channel_trace_test
gtest: true gtest: true
build: test build: test
@ -6839,6 +6831,16 @@ targets:
- test/core/transport/metadata_map_test.cc - test/core/transport/metadata_map_test.cc
deps: deps:
- grpc_test_util - grpc_test_util
- name: minimal_stack_is_minimal_test
gtest: true
build: test
language: c++
headers: []
src:
- test/core/channel/minimal_stack_is_minimal_test.cc
deps:
- grpc_test_util
uses_polling: false
- name: miscompile_with_no_unique_address_test - name: miscompile_with_no_unique_address_test
gtest: true gtest: true
build: test build: test

@ -35,6 +35,7 @@ grpc_cc_test(
grpc_cc_test( grpc_cc_test(
name = "channel_stack_test", name = "channel_stack_test",
srcs = ["channel_stack_test.cc"], srcs = ["channel_stack_test.cc"],
external_deps = ["gtest"],
language = "C++", language = "C++",
uses_event_engine = False, uses_event_engine = False,
uses_polling = False, uses_polling = False,
@ -62,6 +63,7 @@ grpc_cc_test(
grpc_cc_test( grpc_cc_test(
name = "minimal_stack_is_minimal_test", name = "minimal_stack_is_minimal_test",
srcs = ["minimal_stack_is_minimal_test.cc"], srcs = ["minimal_stack_is_minimal_test.cc"],
external_deps = ["gtest"],
language = "C++", language = "C++",
uses_event_engine = False, uses_event_engine = False,
uses_polling = False, uses_polling = False,

@ -20,6 +20,8 @@
#include <string.h> #include <string.h>
#include <gtest/gtest.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -30,12 +32,12 @@
static grpc_error_handle channel_init_func(grpc_channel_element* elem, static grpc_error_handle channel_init_func(grpc_channel_element* elem,
grpc_channel_element_args* args) { grpc_channel_element_args* args) {
GPR_ASSERT(args->channel_args->num_args == 1); EXPECT_EQ(args->channel_args->num_args, 1);
GPR_ASSERT(args->channel_args->args[0].type == GRPC_ARG_INTEGER); EXPECT_EQ(args->channel_args->args[0].type, GRPC_ARG_INTEGER);
GPR_ASSERT(0 == strcmp(args->channel_args->args[0].key, "test_key")); EXPECT_STREQ(args->channel_args->args[0].key, "test_key");
GPR_ASSERT(args->channel_args->args[0].value.integer == 42); EXPECT_EQ(args->channel_args->args[0].value.integer, 42);
GPR_ASSERT(args->is_first); EXPECT_TRUE(args->is_first);
GPR_ASSERT(args->is_last); EXPECT_TRUE(args->is_last);
*static_cast<int*>(elem->channel_data) = 0; *static_cast<int*>(elem->channel_data) = 0;
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
@ -75,7 +77,7 @@ static void free_call(void* arg, grpc_error_handle /*error*/) {
gpr_free(arg); gpr_free(arg);
} }
static void test_create_channel_stack(void) { TEST(ChannelStackTest, CreateChannelStack) {
const grpc_channel_filter filter = { const grpc_channel_filter filter = {
call_func, call_func,
nullptr, nullptr,
@ -111,14 +113,14 @@ static void test_create_channel_stack(void) {
channel_stack = static_cast<grpc_channel_stack*>( channel_stack = static_cast<grpc_channel_stack*>(
gpr_malloc(grpc_channel_stack_size(&filters, 1))); gpr_malloc(grpc_channel_stack_size(&filters, 1)));
GPR_ASSERT(GRPC_LOG_IF_ERROR( ASSERT_TRUE(GRPC_LOG_IF_ERROR(
"grpc_channel_stack_init", "grpc_channel_stack_init",
grpc_channel_stack_init(1, free_channel, channel_stack, &filters, 1, grpc_channel_stack_init(1, free_channel, channel_stack, &filters, 1,
&chan_args, "test", channel_stack))); &chan_args, "test", channel_stack)));
GPR_ASSERT(channel_stack->count == 1); EXPECT_EQ(channel_stack->count, 1);
channel_elem = grpc_channel_stack_element(channel_stack, 0); channel_elem = grpc_channel_stack_element(channel_stack, 0);
channel_data = static_cast<int*>(channel_elem->channel_data); channel_data = static_cast<int*>(channel_elem->channel_data);
GPR_ASSERT(*channel_data == 0); EXPECT_EQ(*channel_data, 0);
call_stack = call_stack =
static_cast<grpc_call_stack*>(gpr_malloc(channel_stack->call_stack_size)); static_cast<grpc_call_stack*>(gpr_malloc(channel_stack->call_stack_size));
@ -134,18 +136,18 @@ static void test_create_channel_stack(void) {
}; };
grpc_error_handle error = grpc_error_handle error =
grpc_call_stack_init(channel_stack, 1, free_call, call_stack, &args); grpc_call_stack_init(channel_stack, 1, free_call, call_stack, &args);
GPR_ASSERT(GRPC_ERROR_IS_NONE(error)); ASSERT_TRUE(GRPC_ERROR_IS_NONE(error)) << grpc_error_std_string(error);
GPR_ASSERT(call_stack->count == 1); EXPECT_EQ(call_stack->count, 1);
call_elem = grpc_call_stack_element(call_stack, 0); call_elem = grpc_call_stack_element(call_stack, 0);
GPR_ASSERT(call_elem->filter == channel_elem->filter); EXPECT_EQ(call_elem->filter, channel_elem->filter);
GPR_ASSERT(call_elem->channel_data == channel_elem->channel_data); EXPECT_EQ(call_elem->channel_data, channel_elem->channel_data);
call_data = static_cast<int*>(call_elem->call_data); call_data = static_cast<int*>(call_elem->call_data);
GPR_ASSERT(*call_data == 0); EXPECT_EQ(*call_data, 0);
GPR_ASSERT(*channel_data == 1); EXPECT_EQ(*channel_data, 1);
GRPC_CALL_STACK_UNREF(call_stack, "done"); GRPC_CALL_STACK_UNREF(call_stack, "done");
grpc_core::ExecCtx::Get()->Flush(); grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(*channel_data == 2); EXPECT_EQ(*channel_data, 2);
GRPC_CHANNEL_STACK_UNREF(channel_stack, "done"); GRPC_CHANNEL_STACK_UNREF(channel_stack, "done");
@ -154,8 +156,7 @@ static void test_create_channel_stack(void) {
int main(int argc, char** argv) { int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(&argc, argv); grpc::testing::TestEnvironment env(&argc, argv);
grpc_init(); ::testing::InitGoogleTest(&argc, argv);
test_create_channel_stack(); grpc::testing::TestGrpcScope grpc_scope;
grpc_shutdown(); return RUN_ALL_TESTS();
return 0;
} }

@ -31,6 +31,8 @@
#include <string.h> #include <string.h>
#include <gtest/gtest.h>
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/strings/str_join.h" #include "absl/strings/str_join.h"
@ -49,9 +51,9 @@
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
// use CHECK_STACK instead // use CHECK_STACK instead
static int check_stack(const char* file, int line, const char* transport_name, static void check_stack(const char* file, int line, const char* transport_name,
grpc_channel_args* init_args, grpc_channel_args* init_args,
unsigned channel_stack_type, ...); unsigned channel_stack_type, ...);
// arguments: const char *transport_name - the name of the transport type to // arguments: const char *transport_name - the name of the transport type to
// simulate // simulate
@ -62,68 +64,54 @@ static int check_stack(const char* file, int line, const char* transport_name,
// filters to instantiate, terminated with NULL // filters to instantiate, terminated with NULL
#define CHECK_STACK(...) check_stack(__FILE__, __LINE__, __VA_ARGS__) #define CHECK_STACK(...) check_stack(__FILE__, __LINE__, __VA_ARGS__)
int main(int argc, char** argv) { TEST(MinimalStackIsMinimalTest, MainTest) {
grpc::testing::TestEnvironment env(&argc, argv);
grpc_init();
int errors = 0;
// tests with a minimal stack // tests with a minimal stack
grpc_arg minimal_stack_arg; grpc_arg minimal_stack_arg;
minimal_stack_arg.type = GRPC_ARG_INTEGER; minimal_stack_arg.type = GRPC_ARG_INTEGER;
minimal_stack_arg.key = const_cast<char*>(GRPC_ARG_MINIMAL_STACK); minimal_stack_arg.key = const_cast<char*>(GRPC_ARG_MINIMAL_STACK);
minimal_stack_arg.value.integer = 1; minimal_stack_arg.value.integer = 1;
grpc_channel_args minimal_stack_args = {1, &minimal_stack_arg}; grpc_channel_args minimal_stack_args = {1, &minimal_stack_arg};
errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_DIRECT_CHANNEL,
CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_DIRECT_CHANNEL, "authority", "connected", NULL);
"authority", "connected", NULL); CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL,
errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL, "authority", "connected", NULL);
"authority", "connected", NULL); CHECK_STACK("unknown", &minimal_stack_args, GRPC_SERVER_CHANNEL, "server",
errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_SERVER_CHANNEL, "connected", NULL);
"server", "connected", NULL); CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_DIRECT_CHANNEL,
errors += "authority", "http-client", "connected", NULL);
CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_DIRECT_CHANNEL, CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL,
"authority", "http-client", "connected", NULL); "authority", "http-client", "connected", NULL);
errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL, CHECK_STACK("chttp2", &minimal_stack_args, GRPC_SERVER_CHANNEL, "server",
"authority", "http-client", "connected", NULL); "http-server", "connected", NULL);
errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_SERVER_CHANNEL, CHECK_STACK(nullptr, &minimal_stack_args, GRPC_CLIENT_CHANNEL,
"server", "http-server", "connected", NULL); "client-channel", NULL);
errors += CHECK_STACK(nullptr, &minimal_stack_args, GRPC_CLIENT_CHANNEL,
"client-channel", NULL);
// tests with a default stack // tests with a default stack
errors += CHECK_STACK("unknown", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, "authority",
CHECK_STACK("unknown", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, "authority", "message_size", "deadline", "connected", NULL);
"message_size", "deadline", "connected", NULL); CHECK_STACK("unknown", nullptr, GRPC_CLIENT_SUBCHANNEL, "authority",
errors += CHECK_STACK("unknown", nullptr, GRPC_CLIENT_SUBCHANNEL, "authority", "message_size", "connected", NULL);
"message_size", "connected", NULL); CHECK_STACK("unknown", nullptr, GRPC_SERVER_CHANNEL, "server", "message_size",
errors += CHECK_STACK("unknown", nullptr, GRPC_SERVER_CHANNEL, "server", "deadline", "connected", NULL);
"message_size", "deadline", "connected", NULL); CHECK_STACK("chttp2", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, "authority",
errors += "message_size", "deadline", "http-client", "message_decompress",
CHECK_STACK("chttp2", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, "authority", "message_compress", "connected", NULL);
"message_size", "deadline", "http-client", CHECK_STACK("chttp2", nullptr, GRPC_CLIENT_SUBCHANNEL, "authority",
"message_decompress", "message_compress", "connected", NULL); "message_size", "http-client", "message_decompress",
errors += CHECK_STACK("chttp2", nullptr, GRPC_CLIENT_SUBCHANNEL, "authority", "message_compress", "connected", NULL);
"message_size", "http-client", "message_decompress", CHECK_STACK("chttp2", nullptr, GRPC_SERVER_CHANNEL, "server", "message_size",
"message_compress", "connected", NULL); "deadline", "http-server", "message_decompress",
errors += "message_compress", "connected", NULL);
CHECK_STACK("chttp2", nullptr, GRPC_SERVER_CHANNEL, "server", CHECK_STACK(nullptr, nullptr, GRPC_CLIENT_CHANNEL, "client-channel", NULL);
"message_size", "deadline", "http-server",
"message_decompress", "message_compress", "connected", NULL);
errors += CHECK_STACK(nullptr, nullptr, GRPC_CLIENT_CHANNEL, "client-channel",
NULL);
GPR_ASSERT(errors == 0);
grpc_shutdown();
return 0;
} }
/******************************************************************************* /*******************************************************************************
* End of tests definitions, start of test infrastructure * End of tests definitions, start of test infrastructure
*/ */
static int check_stack(const char* file, int line, const char* transport_name, static void check_stack(const char* file, int line, const char* transport_name,
grpc_channel_args* init_args, grpc_channel_args* init_args,
unsigned channel_stack_type, ...) { unsigned channel_stack_type, ...) {
// create phony channel stack // create phony channel stack
grpc_core::ChannelStackBuilderImpl builder( grpc_core::ChannelStackBuilderImpl builder(
"test", static_cast<grpc_channel_stack_type>(channel_stack_type)); "test", static_cast<grpc_channel_stack_type>(channel_stack_type));
@ -139,7 +127,7 @@ static int check_stack(const char* file, int line, const char* transport_name,
} }
{ {
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(grpc_core::CoreConfiguration::Get().channel_init().CreateStack( ASSERT_TRUE(grpc_core::CoreConfiguration::Get().channel_init().CreateStack(
&builder)); &builder));
} }
@ -165,22 +153,16 @@ static int check_stack(const char* file, int line, const char* transport_name,
std::string got = absl::StrJoin(parts, ", "); std::string got = absl::StrJoin(parts, ", ");
// figure out result, log if there's an error // figure out result, log if there's an error
int result = 0; EXPECT_EQ(got, expect) << "transport=" << transport_name << " stack_type="
if (got != expect) { << grpc_channel_stack_type_string(
std::string args_str = channel_args.ToString(); static_cast<grpc_channel_stack_type>(
channel_stack_type))
gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, << " channel_args=" << channel_args.ToString();
"**************************************************"); }
gpr_log(
file, line, GPR_LOG_SEVERITY_ERROR,
"FAILED transport=%s; stack_type=%s; channel_args=%s:", transport_name,
grpc_channel_stack_type_string(
static_cast<grpc_channel_stack_type>(channel_stack_type)),
args_str.c_str());
gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "EXPECTED: %s", expect.c_str());
gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "GOT: %s", got.c_str());
result = 1;
}
return result; 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();
} }

@ -237,30 +237,6 @@
], ],
"uses_polling": false "uses_polling": false
}, },
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "channel_stack_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": false
},
{ {
"args": [], "args": [],
"benchmark": false, "benchmark": false,
@ -753,30 +729,6 @@
], ],
"uses_polling": false "uses_polling": false
}, },
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "minimal_stack_is_minimal_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": false
},
{ {
"args": [], "args": [],
"benchmark": false, "benchmark": false,
@ -2435,6 +2387,30 @@
], ],
"uses_polling": true "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": "channel_stack_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": false
},
{ {
"args": [], "args": [],
"benchmark": false, "benchmark": false,
@ -4927,6 +4903,30 @@
], ],
"uses_polling": true "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": "minimal_stack_is_minimal_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": false
},
{ {
"args": [], "args": [],
"benchmark": false, "benchmark": false,

Loading…
Cancel
Save