Added googletest clang-tidy checks (#31610)

* Added google-googletest

* Autofix

* Fix test names

* Fix
pull/31708/head
Esun Kim 2 years ago committed by GitHub
parent d44e1520a7
commit 0ba0c4bf74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .clang-tidy
  2. 8
      test/core/surface/init_test.cc
  3. 8
      test/cpp/codegen/proto_utils_test.cc
  4. 4
      test/cpp/common/channel_arguments_test.cc
  5. 2
      test/cpp/end2end/channelz_service_test.cc
  6. 22
      test/cpp/end2end/client_lb_end2end_test.cc
  7. 4
      test/cpp/end2end/context_allocator_end2end_test.cc
  8. 4
      test/cpp/end2end/end2end_test.cc
  9. 2
      test/cpp/end2end/filter_end2end_test.cc
  10. 12
      test/cpp/end2end/grpclb_end2end_test.cc
  11. 20
      test/cpp/end2end/hybrid_end2end_test.cc
  12. 2
      test/cpp/end2end/service_config_end2end_test.cc
  13. 4
      test/cpp/end2end/time_change_test.cc
  14. 2
      test/cpp/ext/filters/census/stats_plugin_end2end_test.cc
  15. 4
      test/cpp/grpclb/grpclb_api_test.cc
  16. 4
      test/cpp/naming/cancel_ares_query_test.cc
  17. 4
      test/cpp/server/server_builder_test.cc
  18. 4
      test/cpp/server/server_builder_with_socket_mutator_test.cc
  19. 4
      test/cpp/util/byte_buffer_test.cc
  20. 2
      test/cpp/util/grpc_tool_test.cc
  21. 4
      test/cpp/util/slice_test.cc

@ -7,9 +7,6 @@
# - bugprone-reserved-identifier
# Some macros need to be defined for portability purpose; e.g. _BSD_SOURCE.
#
# - google-upgrade-googletest-case
# This requires googletest 1.10 which is higher than ones installed on many linux distributions.
#
# - modernize-redundant-void-arg
# Some source should be strictly C99 and func(void) should be used.
#
@ -30,7 +27,6 @@
# - bugprone-unchecked-optional-access
# - clang-diagnostic-deprecated-declarations
# - clang-diagnostic-unused-function
# - google-readability-avoid-underscore-in-googletest-name
# - google-runtime-int
# - google-runtime-references
# - modernize-avoid-bind
@ -70,10 +66,8 @@ Checks: '-*,
-bugprone-too-small-loop-variable,
-bugprone-unchecked-optional-access,
google-*,
-google-readability-avoid-underscore-in-googletest-name,
-google-runtime-int,
-google-runtime-references,
-google-upgrade-googletest-case,
performance-*,
-performance-no-automatic-move,
-performance-no-int-to-ptr,

@ -69,7 +69,7 @@ TEST(Init, blocking) {
test_blocking(3);
}
TEST(Init, shutdown_with_thread) {
TEST(Init, ShutdownWithThread) {
grpc_init();
{
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx(
@ -90,7 +90,7 @@ TEST(Init, mixed) {
EXPECT_FALSE(grpc_is_initialized());
}
TEST(Init, mixed_with_thread) {
TEST(Init, MixedWithThread) {
grpc_init();
{
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx(
@ -105,7 +105,7 @@ TEST(Init, mixed_with_thread) {
EXPECT_FALSE(grpc_is_initialized());
}
TEST(Init, repeatedly) {
TEST(Init, Repeatedly) {
for (int i = 0; i < 10; i++) {
grpc_init();
{
@ -118,7 +118,7 @@ TEST(Init, repeatedly) {
EXPECT_FALSE(grpc_is_initialized());
}
TEST(Init, repeatedly_blocking) {
TEST(Init, RepeatedlyBlocking) {
for (int i = 0; i < 10; i++) {
grpc_init();
{

@ -53,7 +53,7 @@ class GrpcByteBufferPeer {
class ProtoUtilsTest : public ::testing::Test {
protected:
static void SetUpTestCase() {
static void SetUpTestSuite() {
// Ensure the ProtoBufferWriter internals are initialized.
grpc::internal::GrpcLibraryInitializer init;
init.summon();
@ -61,7 +61,7 @@ class ProtoUtilsTest : public ::testing::Test {
grpc_init();
}
static void TearDownTestCase() { grpc_shutdown(); }
static void TearDownTestSuite() { grpc_shutdown(); }
};
// Regression test for a memory corruption bug where a series of
@ -151,7 +151,7 @@ void BufferWriterTest(int block_size, int total_size, int backup_size) {
class WriterTest : public ::testing::Test {
protected:
static void SetUpTestCase() {
static void SetUpTestSuite() {
grpc::internal::GrpcLibraryInitializer init;
init.summon();
grpc::internal::GrpcLibrary lib;
@ -159,7 +159,7 @@ class WriterTest : public ::testing::Test {
grpc_init();
}
static void TearDownTestCase() { grpc_shutdown(); }
static void TearDownTestSuite() { grpc_shutdown(); }
};
TEST_F(WriterTest, TinyBlockTinyBackup) {

@ -86,9 +86,9 @@ class ChannelArgumentsTest : public ::testing::Test {
channel_args.SetChannelArgs(args);
}
static void SetUpTestCase() { grpc_init(); }
static void SetUpTestSuite() { grpc_init(); }
static void TearDownTestCase() { grpc_shutdown(); }
static void TearDownTestSuite() { grpc_shutdown(); }
std::string GetDefaultUserAgentPrefix() {
std::ostringstream user_agent_prefix;

@ -183,7 +183,7 @@ std::string RemoveWhitespaces(std::string input) {
class ChannelzServerTest : public ::testing::TestWithParam<CredentialsType> {
public:
ChannelzServerTest() {}
static void SetUpTestCase() {
static void SetUpTestSuite() {
#if TARGET_OS_IPHONE
// Workaround Apple CFStream bug
grpc_core::SetEnv("grpc_cfstream", "0");

@ -233,7 +233,7 @@ class ClientLbEnd2endTest : public ::testing::Test {
creds_(new SecureChannelCredentials(
grpc_fake_transport_security_credentials_create())) {}
static void SetUpTestCase() {
static void SetUpTestSuite() {
// Make the backup poller poll very frequently in order to pick up
// updates from all the subchannels's FDs.
GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1);
@ -2184,7 +2184,7 @@ class ClientLbPickArgsTest : public ClientLbEnd2endTest {
current_test_instance_ = this;
}
static void SetUpTestCase() {
static void SetUpTestSuite() {
grpc_core::CoreConfiguration::Reset();
grpc_core::CoreConfiguration::RegisterBuilder(
[](grpc_core::CoreConfiguration::Builder* builder) {
@ -2194,7 +2194,7 @@ class ClientLbPickArgsTest : public ClientLbEnd2endTest {
grpc_init();
}
static void TearDownTestCase() {
static void TearDownTestSuite() {
grpc_shutdown();
grpc_core::CoreConfiguration::Reset();
}
@ -2289,7 +2289,7 @@ class ClientLbInterceptTrailingMetadataTest : public ClientLbEnd2endTest {
current_test_instance_ = this;
}
static void SetUpTestCase() {
static void SetUpTestSuite() {
grpc_core::CoreConfiguration::Reset();
grpc_core::CoreConfiguration::RegisterBuilder(
[](grpc_core::CoreConfiguration::Builder* builder) {
@ -2299,7 +2299,7 @@ class ClientLbInterceptTrailingMetadataTest : public ClientLbEnd2endTest {
grpc_init();
}
static void TearDownTestCase() {
static void TearDownTestSuite() {
grpc_shutdown();
grpc_core::CoreConfiguration::Reset();
}
@ -2570,7 +2570,7 @@ class ClientLbAddressTest : public ClientLbEnd2endTest {
current_test_instance_ = this;
}
static void SetUpTestCase() {
static void SetUpTestSuite() {
grpc_core::CoreConfiguration::Reset();
grpc_core::CoreConfiguration::RegisterBuilder(
[](grpc_core::CoreConfiguration::Builder* builder) {
@ -2580,7 +2580,7 @@ class ClientLbAddressTest : public ClientLbEnd2endTest {
grpc_init();
}
static void TearDownTestCase() {
static void TearDownTestSuite() {
grpc_shutdown();
grpc_core::CoreConfiguration::Reset();
}
@ -2643,7 +2643,7 @@ class OobBackendMetricTest : public ClientLbEnd2endTest {
current_test_instance_ = this;
}
static void SetUpTestCase() {
static void SetUpTestSuite() {
grpc_core::CoreConfiguration::Reset();
grpc_core::CoreConfiguration::RegisterBuilder(
[](grpc_core::CoreConfiguration::Builder* builder) {
@ -2653,7 +2653,7 @@ class OobBackendMetricTest : public ClientLbEnd2endTest {
grpc_init();
}
static void TearDownTestCase() {
static void TearDownTestSuite() {
grpc_shutdown();
grpc_core::CoreConfiguration::Reset();
}
@ -2746,7 +2746,7 @@ TEST_F(OobBackendMetricTest, Basic) {
class ControlPlaneStatusRewritingTest : public ClientLbEnd2endTest {
protected:
static void SetUpTestCase() {
static void SetUpTestSuite() {
grpc_core::CoreConfiguration::Reset();
grpc_core::CoreConfiguration::RegisterBuilder(
[](grpc_core::CoreConfiguration::Builder* builder) {
@ -2756,7 +2756,7 @@ class ControlPlaneStatusRewritingTest : public ClientLbEnd2endTest {
grpc_init();
}
static void TearDownTestCase() {
static void TearDownTestSuite() {
grpc_shutdown();
grpc_core::CoreConfiguration::Reset();
}

@ -74,8 +74,8 @@ void TestScenario::Log() const {
class ContextAllocatorEnd2endTestBase
: public ::testing::TestWithParam<TestScenario> {
protected:
static void SetUpTestCase() { grpc_init(); }
static void TearDownTestCase() { grpc_shutdown(); }
static void SetUpTestSuite() { grpc_init(); }
static void TearDownTestSuite() { grpc_shutdown(); }
ContextAllocatorEnd2endTestBase() {}
~ContextAllocatorEnd2endTestBase() override = default;

@ -318,8 +318,8 @@ std::string TestScenario::AsString() const {
class End2endTest : public ::testing::TestWithParam<TestScenario> {
protected:
static void SetUpTestCase() { grpc_init(); }
static void TearDownTestCase() { grpc_shutdown(); }
static void SetUpTestSuite() { grpc_init(); }
static void TearDownTestSuite() { grpc_shutdown(); }
End2endTest()
: is_server_started_(false),
kMaxMessageSize_(8192),

@ -120,7 +120,7 @@ class FilterEnd2endTest : public ::testing::Test {
protected:
FilterEnd2endTest() : server_host_("localhost") {}
static void SetUpTestCase() {
static void SetUpTestSuite() {
// Workaround for
// https://github.com/google/google-toolbox-for-mac/issues/242
static bool setup_done = false;

@ -371,7 +371,7 @@ class GrpclbEnd2endTest : public ::testing::Test {
client_load_reporting_interval_seconds_(
client_load_reporting_interval_seconds) {}
static void SetUpTestCase() {
static void SetUpTestSuite() {
// Make the backup poller poll very frequently in order to pick up
// updates from all the subchannels's FDs.
GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1);
@ -382,7 +382,7 @@ class GrpclbEnd2endTest : public ::testing::Test {
grpc_init();
}
static void TearDownTestCase() { grpc_shutdown(); }
static void TearDownTestSuite() { grpc_shutdown(); }
void SetUp() override {
bool localhost_resolves_to_ipv4 = false;
@ -1252,7 +1252,7 @@ TEST_F(SingleBalancerTest, FallbackUpdate) {
}
TEST_F(SingleBalancerTest,
FallbackAfterStartup_LoseContactWithBalancerThenBackends) {
FallbackAfterStartupLoseContactWithBalancerThenBackends) {
// First two backends are fallback, last two are pointed to by balancer.
const size_t kNumFallbackBackends = 2;
const size_t kNumBalancerBackends = backends_.size() - kNumFallbackBackends;
@ -1305,7 +1305,7 @@ TEST_F(SingleBalancerTest,
}
TEST_F(SingleBalancerTest,
FallbackAfterStartup_LoseContactWithBackendsThenBalancer) {
FallbackAfterStartupLoseContactWithBackendsThenBalancer) {
// First two backends are fallback, last two are pointed to by balancer.
const size_t kNumFallbackBackends = 2;
const size_t kNumBalancerBackends = backends_.size() - kNumFallbackBackends;
@ -1388,7 +1388,7 @@ TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerCallFails) {
/* wait_for_ready */ false);
}
TEST_F(SingleBalancerTest, FallbackControlledByBalancer_BeforeFirstServerlist) {
TEST_F(SingleBalancerTest, FallbackControlledByBalancerBeforeFirstServerlist) {
const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor();
ResetStub(kFallbackTimeoutMs);
// Return one balancer and one fallback backend.
@ -1407,7 +1407,7 @@ TEST_F(SingleBalancerTest, FallbackControlledByBalancer_BeforeFirstServerlist) {
/* wait_for_ready */ false);
}
TEST_F(SingleBalancerTest, FallbackControlledByBalancer_AfterFirstServerlist) {
TEST_F(SingleBalancerTest, FallbackControlledByBalancerAfterFirstServerlist) {
// Return one balancer and one fallback backend (backend 0).
std::vector<AddressData> balancer_addresses;
balancer_addresses.emplace_back(AddressData{balancers_[0]->port_, ""});

@ -230,7 +230,7 @@ class HybridEnd2endTest : public ::testing::TestWithParam<bool> {
protected:
HybridEnd2endTest() {}
static void SetUpTestCase() {
static void SetUpTestSuite() {
#if TARGET_OS_IPHONE
// Workaround Apple CFStream bug
grpc_core::SetEnv("grpc_cfstream", "0");
@ -540,7 +540,7 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream) {
}
// Add a second service with one sync method.
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) {
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStreamSyncDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
@ -579,7 +579,7 @@ class StreamedUnaryDupPkg
};
TEST_F(HybridEnd2endTest,
AsyncRequestStreamResponseStream_SyncStreamedUnaryDupService) {
AsyncRequestStreamResponseStreamSyncStreamedUnaryDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
@ -617,7 +617,7 @@ class FullyStreamedUnaryDupPkg
};
TEST_F(HybridEnd2endTest,
AsyncRequestStreamResponseStream_SyncFullyStreamedUnaryDupService) {
AsyncRequestStreamResponseStreamSyncFullyStreamedUnaryDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
@ -658,7 +658,7 @@ class SplitResponseStreamDupPkg
};
TEST_F(HybridEnd2endTest,
AsyncRequestStreamResponseStream_SyncSplitStreamedDupService) {
AsyncRequestStreamResponseStreamSyncSplitStreamedDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
@ -698,7 +698,7 @@ class FullySplitStreamedDupPkg
};
TEST_F(HybridEnd2endTest,
AsyncRequestStreamResponseStream_FullySplitStreamedDupService) {
asyncRequestStreamResponseStreamFullySplitStreamedDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
@ -750,7 +750,7 @@ class FullyStreamedDupPkg : public duplicate::EchoTestService::StreamedService {
};
TEST_F(HybridEnd2endTest,
AsyncRequestStreamResponseStream_FullyStreamedDupService) {
AsyncRequestStreamResponseStreamFullyStreamedDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
@ -770,7 +770,7 @@ TEST_F(HybridEnd2endTest,
}
// Add a second service with one async method.
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) {
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStreamAsyncDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
@ -866,7 +866,7 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream) {
}
// Add a second service with one sync method.
TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_SyncDupService) {
TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStreamSyncDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl>>
SType;
@ -886,7 +886,7 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_SyncDupService) {
}
// Add a second service with one async method.
TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_AsyncDupService) {
TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStreamAsyncDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl>>
SType;

@ -120,7 +120,7 @@ class ServiceConfigEnd2endTest : public ::testing::Test {
creds_(new SecureChannelCredentials(
grpc_fake_transport_security_credentials_create())) {}
static void SetUpTestCase() {
static void SetUpTestSuite() {
// Make the backup poller poll very frequently in order to pick up
// updates from all the subchannels's FDs.
GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1);

@ -131,7 +131,7 @@ class TimeChangeTest : public ::testing::Test {
protected:
TimeChangeTest() {}
static void SetUpTestCase() {
static void SetUpTestSuite() {
auto port = grpc_pick_unused_port_or_die();
std::ostringstream addr_stream;
addr_stream << "localhost:" << port;
@ -149,7 +149,7 @@ class TimeChangeTest : public ::testing::Test {
grpc_timeout_milliseconds_to_deadline(30000)));
}
static void TearDownTestCase() { server_.reset(); }
static void TearDownTestSuite() { server_.reset(); }
void SetUp() override {
channel_ =

@ -143,7 +143,7 @@ class ExportedTracesRecorder
class StatsPluginEnd2EndTest : public ::testing::Test {
protected:
static void SetUpTestCase() {
static void SetUpTestSuite() {
RegisterOpenCensusPlugin();
// OpenCensus C++ has no API to unregister a previously-registered handler,
// therefore we register this handler once, and enable/disable recording in

@ -38,9 +38,9 @@ using grpc::lb::v1::LoadBalanceResponse;
class GrpclbTest : public ::testing::Test {
protected:
static void SetUpTestCase() { grpc_init(); }
static void SetUpTestSuite() { grpc_init(); }
static void TearDownTestCase() { grpc_shutdown(); }
static void TearDownTestSuite() { grpc_shutdown(); }
};
std::string Ip4ToPackedString(const char* ip_str) {

@ -181,7 +181,7 @@ void TestCancelActiveDNSQuery(ArgsStruct* args) {
class CancelDuringAresQuery : public ::testing::Test {
protected:
static void SetUpTestCase() {
static void SetUpTestSuite() {
GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares");
// Sanity check the time that it takes to run the test
// including the teardown time (the teardown
@ -191,7 +191,7 @@ class CancelDuringAresQuery : public ::testing::Test {
grpc_init();
}
static void TearDownTestCase() {
static void TearDownTestSuite() {
grpc_shutdown();
if (gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), overall_deadline) > 0) {
gpr_log(GPR_ERROR, "Test took too long");

@ -46,9 +46,9 @@ const std::string& GetPort() {
class ServerBuilderTest : public ::testing::Test {
protected:
static void SetUpTestCase() { grpc_init(); }
static void SetUpTestSuite() { grpc_init(); }
static void TearDownTestCase() { grpc_shutdown(); }
static void TearDownTestSuite() { grpc_shutdown(); }
};
TEST_F(ServerBuilderTest, NoOp) { ServerBuilder b; }

@ -91,9 +91,9 @@ class MockSocketMutatorServerBuilderOption : public grpc::ServerBuilderOption {
class ServerBuilderWithSocketMutatorTest : public ::testing::Test {
protected:
static void SetUpTestCase() { grpc_init(); }
static void SetUpTestSuite() { grpc_init(); }
static void TearDownTestCase() { grpc_shutdown(); }
static void TearDownTestSuite() { grpc_shutdown(); }
};
TEST_F(ServerBuilderWithSocketMutatorTest, CreateServerWithSocketMutator) {

@ -40,9 +40,9 @@ const char* kContent2 = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy world";
class ByteBufferTest : public ::testing::Test {
protected:
static void SetUpTestCase() { grpc_init(); }
static void SetUpTestSuite() { grpc_init(); }
static void TearDownTestCase() { grpc_shutdown(); }
static void TearDownTestSuite() { grpc_shutdown(); }
};
TEST_F(ByteBufferTest, CopyCtor) {

@ -1381,7 +1381,7 @@ TEST_F(GrpcToolTest, CallMaxRecvMessageSizeUnlimited) {
ShutdownServer();
}
TEST_F(GrpcToolTest, ListCommand_OverrideSslHostName) {
TEST_F(GrpcToolTest, ListCommandOverrideSslHostName) {
const std::string server_address = SetUpServer(true);
// Test input "grpc_cli ls localhost:<port> --channel_creds_type=ssl

@ -35,9 +35,9 @@ const char* kContent = "hello xxxxxxxxxxxxxxxxxxxx world";
class SliceTest : public ::testing::Test {
protected:
static void SetUpTestCase() { grpc_init(); }
static void SetUpTestSuite() { grpc_init(); }
static void TearDownTestCase() { grpc_shutdown(); }
static void TearDownTestSuite() { grpc_shutdown(); }
void CheckSliceSize(const Slice& s, const std::string& content) {
EXPECT_EQ(content.size(), s.size());

Loading…
Cancel
Save