xref: /aosp_15_r20/external/grpc-grpc/test/cpp/util/BUILD (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
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    deps = [
49        "//:grpc++",
50        "//:grpc++_config_proto",
51        "//src/proto/grpc/reflection/v1alpha:reflection_proto",
52    ],
53)
54
55GRPCXX_TESTUTIL_SRCS = [
56    "byte_buffer_proto_helper.cc",
57    "string_ref_helper.cc",
58    "subprocess.cc",
59]
60
61GRPCXX_TESTUTIL_HDRS = [
62    "byte_buffer_proto_helper.h",
63    "credentials.h",
64    "string_ref_helper.h",
65    "subprocess.h",
66]
67
68grpc_cc_library(
69    name = "test_util",
70    srcs = GRPCXX_TESTUTIL_SRCS + [
71        "create_test_channel.cc",
72        "test_credentials_provider.cc",
73    ],
74    hdrs = GRPCXX_TESTUTIL_HDRS + [
75        "create_test_channel.h",
76        "test_credentials_provider.h",
77    ],
78    external_deps = [
79        "absl/flags:flag",
80        "protobuf",
81    ],
82    deps = [
83        "//:grpc++",
84        "//:subprocess",
85        "//test/core/end2end:ssl_test_data",
86        "//test/core/util:grpc_test_util",
87        "//test/core/util:grpc_test_util_base",
88    ],
89)
90
91grpc_cc_library(
92    name = "channel_trace_proto_helper",
93    testonly = 1,
94    srcs = [
95        "channel_trace_proto_helper.cc",
96    ],
97    hdrs = [
98        "channel_trace_proto_helper.h",
99    ],
100    external_deps = [
101        "gtest",
102        "protobuf",
103    ],
104    deps = [
105        "//:grpc++",
106        "//src/proto/grpc/channelz:channelz_proto",
107    ],
108)
109
110grpc_cc_library(
111    name = "test_util_unsecure",
112    srcs = GRPCXX_TESTUTIL_SRCS,
113    hdrs = GRPCXX_TESTUTIL_HDRS,
114    external_deps = [
115        "protobuf",
116    ],
117    deps = [
118        "//:grpc++_unsecure",
119        "//:subprocess",
120        "//test/core/util:grpc_test_util_base",
121        "//test/core/util:grpc_test_util_unsecure",
122    ],
123)
124
125grpc_cc_library(
126    name = "grpc_cli_utils",
127    srcs = [
128        "cli_call.cc",
129        "cli_credentials.cc",
130        "proto_file_parser.cc",
131        "service_describer.cc",
132    ],
133    hdrs = [
134        "cli_call.h",
135        "cli_credentials.h",
136        "config_grpc_cli.h",
137        "proto_file_parser.h",
138        "service_describer.h",
139    ],
140    external_deps = [
141        "absl/flags:flag",
142        "protobuf",
143        "protobuf_clib",
144    ],
145    deps = [
146        ":grpc++_proto_reflection_desc_db",
147        "//:grpc++",
148        "//src/proto/grpc/reflection/v1alpha:reflection_proto",
149    ],
150)
151
152grpc_cc_library(
153    name = "grpc_cli_libs",
154    srcs = [
155        "grpc_tool.cc",
156    ],
157    hdrs = [
158        "grpc_tool.h",
159    ],
160    external_deps = [
161        "absl/flags:flag",
162    ],
163    deps = [
164        ":grpc_cli_utils",
165    ],
166)
167
168grpc_cc_library(
169    name = "metrics_server_lib",
170    srcs = [
171        "metrics_server.cc",
172    ],
173    hdrs = [
174        "metrics_server.h",
175    ],
176    deps = [
177        "//:grpc++",
178        "//src/proto/grpc/testing:metrics_proto",
179    ],
180)
181
182grpc_cc_test(
183    name = "grpc_tool_test",
184    srcs = [
185        "grpc_tool_test.cc",
186    ],
187    data = [
188        "//src/core/tsi/test_creds:ca.pem",
189        "//src/core/tsi/test_creds:server1.key",
190        "//src/core/tsi/test_creds:server1.pem",
191        "//src/proto/grpc/testing:echo.proto",
192        "//src/proto/grpc/testing:echo_messages.proto",
193        "//src/proto/grpc/testing:simple_messages.proto",
194        "//src/proto/grpc/testing/xds/v3:orca_load_report.proto",
195    ],
196    external_deps = [
197        "absl/flags:flag",
198        "gtest",
199    ],
200    tags = [
201        "no_mac",
202        "no_test_ios",
203        "no_windows",
204        "nomsan",  # death tests seem to be incompatible with msan
205    ],
206    deps = [
207        ":grpc_cli_libs",
208        ":test_util",
209        "//:grpc++_reflection",
210        "//src/proto/grpc/testing:echo_messages_proto",
211        "//src/proto/grpc/testing:echo_proto",
212        "//src/proto/grpc/testing:simple_messages_proto",
213        "//src/proto/grpc/testing/xds/v3:orca_load_report_proto",
214        "//test/core/util:grpc_test_util",
215        "//test/cpp/util:test_config",
216    ],
217)
218
219grpc_cc_test(
220    name = "byte_buffer_test",
221    srcs = [
222        "byte_buffer_test.cc",
223    ],
224    external_deps = [
225        "gtest",
226    ],
227    uses_event_engine = False,
228    uses_polling = False,
229    deps = [
230        ":test_util",
231    ],
232)
233
234grpc_cc_test(
235    name = "slice_test",
236    srcs = [
237        "slice_test.cc",
238    ],
239    external_deps = [
240        "gtest",
241    ],
242    uses_event_engine = False,
243    uses_polling = False,
244    deps = [
245        ":test_util",
246    ],
247)
248
249grpc_cc_test(
250    name = "string_ref_test",
251    srcs = [
252        "string_ref_test.cc",
253    ],
254    external_deps = [
255        "gtest",
256    ],
257    uses_event_engine = False,
258    uses_polling = False,
259    deps = [
260        "//:grpc++",
261        "//test/core/util:grpc_test_util",
262    ],
263)
264
265grpc_cc_test(
266    name = "time_test",
267    srcs = [
268        "time_test.cc",
269    ],
270    external_deps = [
271        "gtest",
272    ],
273    uses_event_engine = False,
274    uses_polling = False,
275    deps = [
276        ":test_util",
277    ],
278)
279
280grpc_cc_test(
281    name = "cli_call_test",
282    srcs = [
283        "cli_call_test.cc",
284    ],
285    external_deps = [
286        "gtest",
287    ],
288    deps = [
289        ":grpc_cli_libs",
290        ":test_util",
291        "//src/proto/grpc/testing:echo_proto",
292        "//test/core/util:grpc_test_util",
293    ],
294)
295
296grpc_cc_test(
297    name = "error_details_test",
298    srcs = [
299        "error_details_test.cc",
300    ],
301    external_deps = [
302        "gtest",
303    ],
304    tags = ["no_test_ios"],
305    deps = [
306        "//:grpc++_error_details",
307        "//src/proto/grpc/status:status_proto",
308        "//src/proto/grpc/testing:echo_messages_proto",
309        "//test/core/util:grpc_test_util",
310    ],
311)
312
313grpc_cc_binary(
314    name = "grpc_cli",
315    srcs = [
316        "grpc_cli.cc",
317    ],
318    external_deps = [
319        "absl/flags:flag",
320    ],
321    visibility = [
322        "@grpc:cli",
323    ],
324    deps = [
325        ":grpc++_proto_reflection_desc_db",
326        ":grpc_cli_libs",
327        ":test_config",
328        "//:grpc++",
329        "//src/proto/grpc/reflection/v1alpha:reflection_proto",
330    ],
331)
332
333grpc_cc_binary(
334    name = "channelz_sampler",
335    srcs = ["channelz_sampler.cc"],
336    external_deps = [
337        "absl/flags:flag",
338        "absl/strings",
339    ],
340    language = "c++",
341    tags = [
342        "no_windows",  # unistd.h
343    ],
344    deps = [
345        "//:gpr",
346        "//:grpc++",
347        "//:grpcpp_channelz",
348        "//src/proto/grpc/channelz:channelz_proto",
349        "//test/cpp/util:test_config",
350        "//test/cpp/util:test_util",
351    ],
352)
353
354grpc_cc_test(
355    name = "channelz_sampler_test",
356    srcs = [
357        "channelz_sampler_test.cc",
358    ],
359    data = [
360        ":channelz_sampler",
361    ],
362    external_deps = [
363        "gtest",
364    ],
365    flaky = True,
366    tags = [
367        "no_mac",  # cmake does not build channelz_sampler in Basic Tests C/C++ MacOS test
368        "no_test_android",  # android_cc_test doesn't work with data dependency.
369        "no_test_ios",
370        "no_windows",  # unistd.h
371    ],
372    deps = [
373        "//:gpr",
374        "//:grpc",
375        "//:grpc++",
376        "//:grpcpp_channelz",
377        "//src/proto/grpc/channelz:channelz_proto",
378        "//src/proto/grpc/testing:test_proto",
379        "//test/core/util:grpc_test_util",
380        "//test/cpp/util:test_util",
381    ],
382)
383
384grpc_cc_library(
385    name = "tls_test_utils",
386    srcs = [
387        "tls_test_utils.cc",
388    ],
389    hdrs = [
390        "tls_test_utils.h",
391    ],
392    deps = [
393        "//:gpr",
394        "//:grpc",
395        "//:grpc++",
396        "//test/core/util:grpc_test_util",
397    ],
398)
399
400grpc_cc_test(
401    name = "proto_buffer_reader_test",
402    srcs = [
403        "proto_buffer_reader_test.cc",
404    ],
405    external_deps = [
406        "gtest",
407    ],
408    uses_event_engine = False,
409    uses_polling = False,
410    deps = [
411        ":test_util",
412    ],
413)
414
415grpc_cc_test(
416    name = "proto_buffer_writer_test",
417    srcs = [
418        "proto_buffer_writer_test.cc",
419    ],
420    external_deps = [
421        "gtest",
422    ],
423    uses_event_engine = False,
424    uses_polling = False,
425    deps = [
426        ":test_util",
427    ],
428)
429
430grpc_cc_library(
431    name = "get_grpc_test_runfile_dir",
432    srcs = [
433        "get_grpc_test_runfile_dir.cc",
434    ],
435    hdrs = [
436        "get_grpc_test_runfile_dir.h",
437    ],
438    external_deps = [
439        "absl/types:optional",
440    ],
441    deps = [
442        "//src/core:env",
443    ],
444)
445