Rollback gtestified minimal_stack_is_minimal_test (#30275)

pull/30279/head
Esun Kim 2 years ago committed by GitHub
parent 0e16835fe4
commit 89fedf9a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 64
      CMakeLists.txt
  2. 19
      build_autogenerated.yaml
  3. 1
      test/core/channel/BUILD
  4. 121
      test/core/channel/minimal_stack_is_minimal_test.cc
  5. 48
      tools/run_tests/generated/tests.json

64
CMakeLists.txt generated

@ -821,6 +821,7 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_c invalid_call_argument_test)
add_dependencies(buildtests_c load_file_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 murmur_hash_test)
add_dependencies(buildtests_c no_server_test)
@ -1062,7 +1063,6 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_cxx memory_quota_test)
add_dependencies(buildtests_cxx message_allocator_end2end_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 mock_stream_test)
add_dependencies(buildtests_cxx mock_test)
@ -5097,6 +5097,33 @@ 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()
if(gRPC_BUILD_TESTS)
@ -13030,41 +13057,6 @@ 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()
if(gRPC_BUILD_TESTS)

@ -3501,6 +3501,15 @@ targets:
deps:
- grpc_test_util
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
build: test
language: c
@ -6833,16 +6842,6 @@ targets:
- test/core/transport/metadata_map_test.cc
deps:
- 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
gtest: true
build: test

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

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

@ -681,6 +681,30 @@
],
"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": [],
"benchmark": false,
@ -4903,30 +4927,6 @@
],
"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": [],
"benchmark": false,

Loading…
Cancel
Save