1# Copyright 2017 gRPC authors. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package") 16 17licenses(["notice"]) 18 19grpc_package( 20 name = "test/cpp/util", 21 visibility = "public", 22) 23 24grpc_cc_library( 25 name = "test_config", 26 srcs = [ 27 "test_config_cc.cc", 28 ], 29 hdrs = [ 30 "test_config.h", 31 ], 32 external_deps = [ 33 "absl/flags:parse", 34 ], 35 deps = [ 36 "//:gpr", 37 ], 38) 39 40grpc_cc_library( 41 name = "grpc++_proto_reflection_desc_db", 42 srcs = [ 43 "proto_reflection_descriptor_database.cc", 44 ], 45 hdrs = [ 46 "proto_reflection_descriptor_database.h", 47 ], 48 external_deps = ["absl/log:log"], 49 deps = [ 50 "//:grpc++", 51 "//:grpc++_config_proto", 52 "//src/proto/grpc/reflection/v1alpha:reflection_proto", 53 ], 54) 55 56GRPCXX_TESTUTIL_SRCS = [ 57 "byte_buffer_proto_helper.cc", 58 "string_ref_helper.cc", 59 "subprocess.cc", 60] 61 62GRPCXX_TESTUTIL_HDRS = [ 63 "byte_buffer_proto_helper.h", 64 "credentials.h", 65 "string_ref_helper.h", 66 "subprocess.h", 67] 68 69grpc_cc_library( 70 name = "test_util", 71 srcs = GRPCXX_TESTUTIL_SRCS + [ 72 "create_test_channel.cc", 73 "test_credentials_provider.cc", 74 ], 75 hdrs = GRPCXX_TESTUTIL_HDRS + [ 76 "create_test_channel.h", 77 "test_credentials_provider.h", 78 ], 79 external_deps = [ 80 "absl/flags:flag", 81 "absl/log:check", 82 "absl/log:log", 83 "protobuf", 84 ], 85 deps = [ 86 "//:grpc++", 87 "//:subprocess", 88 "//test/core/end2end:ssl_test_data", 89 "//test/core/test_util:grpc_test_util", 90 "//test/core/test_util:grpc_test_util_base", 91 ], 92) 93 94grpc_cc_library( 95 name = "channel_trace_proto_helper", 96 testonly = 1, 97 srcs = [ 98 "channel_trace_proto_helper.cc", 99 ], 100 hdrs = [ 101 "channel_trace_proto_helper.h", 102 ], 103 external_deps = [ 104 "gtest", 105 "protobuf", 106 ], 107 deps = [ 108 "//:grpc++", 109 "//src/proto/grpc/channelz:channelz_proto", 110 ], 111) 112 113grpc_cc_library( 114 name = "test_util_unsecure", 115 srcs = GRPCXX_TESTUTIL_SRCS, 116 hdrs = GRPCXX_TESTUTIL_HDRS, 117 external_deps = [ 118 "protobuf", 119 ], 120 deps = [ 121 "//:grpc++_unsecure", 122 "//:subprocess", 123 "//test/core/test_util:grpc_test_util_base", 124 "//test/core/test_util:grpc_test_util_unsecure", 125 ], 126) 127 128grpc_cc_library( 129 name = "grpc_cli_utils", 130 srcs = [ 131 "cli_call.cc", 132 "cli_credentials.cc", 133 "proto_file_parser.cc", 134 "service_describer.cc", 135 ], 136 hdrs = [ 137 "cli_call.h", 138 "cli_credentials.h", 139 "config_grpc_cli.h", 140 "proto_file_parser.h", 141 "service_describer.h", 142 ], 143 external_deps = [ 144 "absl/flags:flag", 145 "absl/log:check", 146 "absl/log:log", 147 "protobuf", 148 "protobuf_clib", 149 ], 150 deps = [ 151 ":grpc++_proto_reflection_desc_db", 152 "//:grpc++", 153 "//src/proto/grpc/reflection/v1alpha:reflection_proto", 154 ], 155) 156 157grpc_cc_library( 158 name = "grpc_cli_libs", 159 srcs = [ 160 "grpc_tool.cc", 161 ], 162 hdrs = [ 163 "grpc_tool.h", 164 ], 165 external_deps = [ 166 "absl/flags:flag", 167 ], 168 deps = [ 169 ":grpc_cli_utils", 170 ], 171) 172 173grpc_cc_library( 174 name = "metrics_server_lib", 175 srcs = [ 176 "metrics_server.cc", 177 ], 178 hdrs = [ 179 "metrics_server.h", 180 ], 181 external_deps = ["absl/log:log"], 182 deps = [ 183 "//:grpc++", 184 "//src/proto/grpc/testing:metrics_cc_grpc", 185 ], 186) 187 188grpc_cc_test( 189 name = "grpc_tool_test", 190 srcs = [ 191 "grpc_tool_test.cc", 192 ], 193 data = [ 194 "//src/core/tsi/test_creds:ca.pem", 195 "//src/core/tsi/test_creds:server1.key", 196 "//src/core/tsi/test_creds:server1.pem", 197 "//src/proto/grpc/testing:echo.proto", 198 "//src/proto/grpc/testing:echo_messages.proto", 199 "//src/proto/grpc/testing:simple_messages.proto", 200 ], 201 external_deps = [ 202 "absl/flags:flag", 203 "gtest", 204 ], 205 tags = [ 206 "no_mac", 207 "no_test_ios", 208 "no_windows", 209 "nomsan", # death tests seem to be incompatible with msan 210 ], 211 deps = [ 212 ":grpc_cli_libs", 213 ":test_util", 214 "//:grpc++_reflection", 215 "//src/proto/grpc/testing:echo_cc_grpc", 216 "//src/proto/grpc/testing:echo_messages_cc_proto", 217 "//src/proto/grpc/testing:simple_messages_cc_proto", 218 "//test/core/test_util:grpc_test_util", 219 "//test/cpp/util:test_config", 220 ], 221) 222 223grpc_cc_test( 224 name = "byte_buffer_test", 225 srcs = [ 226 "byte_buffer_test.cc", 227 ], 228 external_deps = [ 229 "gtest", 230 ], 231 uses_event_engine = False, 232 uses_polling = False, 233 deps = [ 234 ":test_util", 235 ], 236) 237 238grpc_cc_test( 239 name = "slice_test", 240 srcs = [ 241 "slice_test.cc", 242 ], 243 external_deps = [ 244 "gtest", 245 ], 246 uses_event_engine = False, 247 uses_polling = False, 248 deps = [ 249 ":test_util", 250 ], 251) 252 253grpc_cc_test( 254 name = "string_ref_test", 255 srcs = [ 256 "string_ref_test.cc", 257 ], 258 external_deps = [ 259 "gtest", 260 ], 261 uses_event_engine = False, 262 uses_polling = False, 263 deps = [ 264 "//:grpc++", 265 "//test/core/test_util:grpc_test_util", 266 ], 267) 268 269grpc_cc_test( 270 name = "time_test", 271 srcs = [ 272 "time_test.cc", 273 ], 274 external_deps = [ 275 "gtest", 276 ], 277 uses_event_engine = False, 278 uses_polling = False, 279 deps = [ 280 ":test_util", 281 ], 282) 283 284grpc_cc_test( 285 name = "cli_call_test", 286 srcs = [ 287 "cli_call_test.cc", 288 ], 289 external_deps = [ 290 "gtest", 291 ], 292 deps = [ 293 ":grpc_cli_libs", 294 ":test_util", 295 "//src/proto/grpc/testing:echo_cc_grpc", 296 "//test/core/test_util:grpc_test_util", 297 ], 298) 299 300grpc_cc_test( 301 name = "error_details_test", 302 srcs = [ 303 "error_details_test.cc", 304 ], 305 external_deps = [ 306 "gtest", 307 ], 308 tags = ["no_test_ios"], 309 deps = [ 310 "//:grpc++_error_details", 311 "//src/proto/grpc/testing:echo_messages_cc_proto", 312 "//test/core/test_util:grpc_test_util", 313 "@com_google_googleapis//google/rpc:status_cc_proto", 314 ], 315) 316 317grpc_cc_binary( 318 name = "grpc_cli", 319 srcs = [ 320 "grpc_cli.cc", 321 ], 322 external_deps = [ 323 "absl/flags:flag", 324 ], 325 visibility = [ 326 "@grpc:cli", 327 ], 328 deps = [ 329 ":grpc++_proto_reflection_desc_db", 330 ":grpc_cli_libs", 331 ":test_config", 332 "//:grpc++", 333 "//src/proto/grpc/reflection/v1alpha:reflection_proto", 334 ], 335) 336 337grpc_cc_binary( 338 name = "channelz_sampler", 339 srcs = ["channelz_sampler.cc"], 340 external_deps = [ 341 "absl/flags:flag", 342 "absl/log:check", 343 "absl/log:log", 344 "absl/strings", 345 ], 346 language = "c++", 347 tags = [ 348 "no_windows", # unistd.h 349 ], 350 deps = [ 351 "//:gpr", 352 "//:grpc++", 353 "//:grpcpp_channelz", 354 "//src/proto/grpc/channelz:channelz_proto", 355 "//test/cpp/util:test_config", 356 "//test/cpp/util:test_util", 357 ], 358) 359 360grpc_cc_test( 361 name = "channelz_sampler_test", 362 srcs = [ 363 "channelz_sampler_test.cc", 364 ], 365 data = [ 366 ":channelz_sampler", 367 ], 368 external_deps = [ 369 "absl/log:check", 370 "absl/log:log", 371 "gtest", 372 ], 373 flaky = True, 374 tags = [ 375 "no_mac", # cmake does not build channelz_sampler in Basic Tests C/C++ MacOS test 376 "no_test_android", # android_cc_test doesn't work with data dependency. 377 "no_test_ios", 378 "no_windows", # unistd.h 379 ], 380 deps = [ 381 "//:gpr", 382 "//:grpc", 383 "//:grpc++", 384 "//:grpcpp_channelz", 385 "//src/proto/grpc/channelz:channelz_proto", 386 "//src/proto/grpc/testing:test_cc_grpc", 387 "//test/core/test_util:grpc_test_util", 388 "//test/cpp/util:test_util", 389 ], 390) 391 392grpc_cc_library( 393 name = "tls_test_utils", 394 srcs = [ 395 "tls_test_utils.cc", 396 ], 397 hdrs = [ 398 "tls_test_utils.h", 399 ], 400 deps = [ 401 "//:gpr", 402 "//:grpc", 403 "//:grpc++", 404 "//test/core/test_util:grpc_test_util", 405 ], 406) 407 408grpc_cc_test( 409 name = "proto_buffer_reader_test", 410 srcs = [ 411 "proto_buffer_reader_test.cc", 412 ], 413 external_deps = [ 414 "gtest", 415 ], 416 uses_event_engine = False, 417 uses_polling = False, 418 deps = [ 419 ":test_util", 420 ], 421) 422 423grpc_cc_test( 424 name = "proto_buffer_writer_test", 425 srcs = [ 426 "proto_buffer_writer_test.cc", 427 ], 428 external_deps = [ 429 "gtest", 430 ], 431 uses_event_engine = False, 432 uses_polling = False, 433 deps = [ 434 ":test_util", 435 ], 436) 437 438grpc_cc_library( 439 name = "get_grpc_test_runfile_dir", 440 srcs = [ 441 "get_grpc_test_runfile_dir.cc", 442 ], 443 hdrs = [ 444 "get_grpc_test_runfile_dir.h", 445 ], 446 external_deps = [ 447 "absl/types:optional", 448 ], 449 deps = [ 450 "//src/core:env", 451 ], 452) 453