Imported Upstream version 1.36.0
[platform/upstream/grpc.git] / test / cpp / util / BUILD
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
15 licenses(["notice"])  # Apache v2
16
17 load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package")
18
19 grpc_package(
20     name = "test/cpp/util",
21     visibility = "public",
22 )
23
24 grpc_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
40 grpc_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
55 GRPCXX_TESTUTIL_SRCS = [
56     "byte_buffer_proto_helper.cc",
57     "string_ref_helper.cc",
58     "subprocess.cc",
59 ]
60
61 GRPCXX_TESTUTIL_HDRS = [
62     "byte_buffer_proto_helper.h",
63     "string_ref_helper.h",
64     "subprocess.h",
65 ]
66
67 grpc_cc_library(
68     name = "test_util",
69     srcs = GRPCXX_TESTUTIL_SRCS + [
70         "create_test_channel.cc",
71         "test_credentials_provider.cc",
72     ],
73     hdrs = GRPCXX_TESTUTIL_HDRS + [
74         "create_test_channel.h",
75         "test_credentials_provider.h",
76     ],
77     external_deps = [
78         "absl/flags:flag",
79         "protobuf",
80     ],
81     deps = [
82         "//:grpc++",
83         "//test/core/end2end:ssl_test_data",
84         "//test/core/util:grpc_test_util",
85     ],
86 )
87
88 grpc_cc_library(
89     name = "channel_trace_proto_helper",
90     testonly = 1,
91     srcs = [
92         "channel_trace_proto_helper.cc",
93     ],
94     hdrs = [
95         "channel_trace_proto_helper.h",
96     ],
97     external_deps = [
98         "gtest",
99         "protobuf",
100     ],
101     deps = [
102         "//:grpc++",
103         "//src/proto/grpc/channelz:channelz_proto",
104     ],
105 )
106
107 grpc_cc_library(
108     name = "test_util_unsecure",
109     srcs = GRPCXX_TESTUTIL_SRCS,
110     hdrs = GRPCXX_TESTUTIL_HDRS,
111     external_deps = [
112         "protobuf",
113     ],
114     deps = [
115         "//:grpc++_unsecure",
116         "//test/core/util:grpc_test_util_unsecure",
117     ],
118 )
119
120 grpc_cc_library(
121     name = "grpc_cli_utils",
122     srcs = [
123         "cli_call.cc",
124         "cli_credentials.cc",
125         "proto_file_parser.cc",
126         "service_describer.cc",
127     ],
128     hdrs = [
129         "cli_call.h",
130         "cli_credentials.h",
131         "config_grpc_cli.h",
132         "proto_file_parser.h",
133         "service_describer.h",
134     ],
135     external_deps = [
136         "absl/flags:flag",
137         "protobuf",
138         "protobuf_clib",
139     ],
140     deps = [
141         ":grpc++_proto_reflection_desc_db",
142         "//:grpc++",
143         "//src/proto/grpc/reflection/v1alpha:reflection_proto",
144     ],
145 )
146
147 grpc_cc_library(
148     name = "grpc_cli_libs",
149     srcs = [
150         "grpc_tool.cc",
151     ],
152     hdrs = [
153         "grpc_tool.h",
154     ],
155     external_deps = [
156         "absl/flags:flag",
157     ],
158     deps = [
159         ":grpc_cli_utils",
160     ],
161 )
162
163 grpc_cc_library(
164     name = "metrics_server_lib",
165     srcs = [
166         "metrics_server.cc",
167     ],
168     hdrs = [
169         "metrics_server.h",
170     ],
171     deps = [
172         "//:grpc++",
173         "//src/proto/grpc/testing:metrics_proto",
174     ],
175 )
176
177 grpc_cc_test(
178     name = "grpc_tool_test",
179     srcs = [
180         "grpc_tool_test.cc",
181     ],
182     data = [
183         "//src/core/tsi/test_creds:ca.pem",
184         "//src/core/tsi/test_creds:server1.key",
185         "//src/core/tsi/test_creds:server1.pem",
186         "//src/proto/grpc/testing:echo.proto",
187         "//src/proto/grpc/testing:echo_messages.proto",
188         "//src/proto/grpc/testing:simple_messages.proto",
189     ],
190     external_deps = [
191         "absl/flags:flag",
192         "gtest",
193     ],
194     tags = [
195         "no_test_ios",
196         "no_windows",
197         "nomsan",  # death tests seem to be incompatible with msan
198     ],
199     deps = [
200         ":grpc_cli_libs",
201         ":test_util",
202         "//:grpc++_reflection",
203         "//src/proto/grpc/testing:echo_messages_proto",
204         "//src/proto/grpc/testing:echo_proto",
205         "//src/proto/grpc/testing:simple_messages_proto",
206         "//test/core/util:grpc_test_util",
207     ],
208 )
209
210 grpc_cc_test(
211     name = "byte_buffer_test",
212     srcs = [
213         "byte_buffer_test.cc",
214     ],
215     external_deps = [
216         "gtest",
217     ],
218     uses_polling = False,
219     deps = [
220         ":test_util",
221     ],
222 )
223
224 grpc_cc_test(
225     name = "slice_test",
226     srcs = [
227         "slice_test.cc",
228     ],
229     external_deps = [
230         "gtest",
231     ],
232     uses_polling = False,
233     deps = [
234         ":test_util",
235     ],
236 )
237
238 grpc_cc_test(
239     name = "string_ref_test",
240     srcs = [
241         "string_ref_test.cc",
242     ],
243     external_deps = [
244         "gtest",
245     ],
246     uses_polling = False,
247     deps = [
248         "//:grpc++",
249         "//test/core/util:grpc_test_util",
250     ],
251 )
252
253 grpc_cc_test(
254     name = "time_test",
255     srcs = [
256         "time_test.cc",
257     ],
258     external_deps = [
259         "gtest",
260     ],
261     uses_polling = False,
262     deps = [
263         ":test_util",
264     ],
265 )
266
267 grpc_cc_test(
268     name = "cli_call_test",
269     srcs = [
270         "cli_call_test.cc",
271     ],
272     external_deps = [
273         "gtest",
274     ],
275     deps = [
276         ":grpc_cli_libs",
277         ":test_util",
278         "//src/proto/grpc/testing:echo_proto",
279         "//test/core/util:grpc_test_util",
280     ],
281 )
282
283 grpc_cc_test(
284     name = "error_details_test",
285     srcs = [
286         "error_details_test.cc",
287     ],
288     external_deps = [
289         "gtest",
290     ],
291     tags = ["no_test_ios"],
292     deps = [
293         "//:grpc++_error_details",
294         "//src/proto/grpc/status:status_proto",
295         "//src/proto/grpc/testing:echo_messages_proto",
296         "//test/core/util:grpc_test_util",
297     ],
298 )
299
300 grpc_cc_binary(
301     name = "grpc_cli",
302     srcs = [
303         "grpc_cli.cc",
304     ],
305     external_deps = [
306         "absl/flags:flag",
307     ],
308     deps = [
309         ":grpc++_proto_reflection_desc_db",
310         ":grpc_cli_libs",
311         ":test_config",
312         "//:grpc++",
313         "//src/proto/grpc/reflection/v1alpha:reflection_proto",
314     ],
315 )
316
317 grpc_cc_binary(
318     name = "channelz_sampler",
319     srcs = ["channelz_sampler.cc"],
320     external_deps = [
321         "absl/flags:flag",
322     ],
323     language = "c++",
324     tags = [
325         "no_windows",  # unistd.h
326     ],
327     deps = [
328         "//:gpr",
329         "//:grpc++",
330         "//:grpcpp_channelz",
331         "//src/proto/grpc/channelz:channelz_proto",
332         "//test/cpp/util:test_config",
333         "//test/cpp/util:test_util",
334     ],
335 )
336
337 grpc_cc_test(
338     name = "channelz_sampler_test",
339     srcs = [
340         "channelz_sampler_test.cc",
341     ],
342     data = [
343         ":channelz_sampler",
344     ],
345     external_deps = [
346         "gtest",
347     ],
348     tags = [
349         "no_mac",  # cmake does not build channelz_sampler in Basic Tests C/C++ MacOS test
350         "no_test_android",  # android_cc_test doesn't work with data dependency.
351         "no_test_ios",
352         "no_windows",  # unistd.h
353     ],
354     deps = [
355         "//:gpr",
356         "//:grpc",
357         "//:grpc++",
358         "//:grpcpp_channelz",
359         "//src/proto/grpc/channelz:channelz_proto",
360         "//src/proto/grpc/testing:test_proto",
361         "//test/core/util:grpc_test_util",
362         "//test/core/util:grpc_test_util_base",
363         "//test/cpp/util:test_util",
364     ],
365 )