xref: /aosp_15_r20/external/grpc-grpc/src/objective-c/tests/BUILD (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1# gRPC Bazel BUILD file.
2#
3# Copyright 2019 gRPC authors.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17load("@build_bazel_rules_apple//apple:macos.bzl", "macos_unit_test")
18load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle")
19load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_application", "tvos_unit_test")
20load("//bazel:grpc_build_system.bzl", "grpc_sh_test")
21load(
22    "//src/objective-c:grpc_objc_internal_library.bzl",
23    "grpc_objc_ios_unit_test",
24    "grpc_objc_testing_library",
25    "local_objc_grpc_library",
26    "proto_library_objc_wrapper",
27)
28
29licenses(["notice"])
30
31package(default_visibility = ["//visibility:public"])
32
33exports_files(["LICENSE"])
34
35proto_library_objc_wrapper(
36    name = "messages_proto",
37    srcs = ["RemoteTestClient/messages.proto"],
38)
39
40proto_library_objc_wrapper(
41    name = "test_proto",
42    srcs = ["RemoteTestClient/test.proto"],
43    use_well_known_protos = True,
44    deps = [":messages_proto"],
45)
46
47local_objc_grpc_library(
48    name = "RemoteTest",
49    srcs = ["RemoteTestClient/test.proto"],
50    testing = True,
51    use_well_known_protos = True,
52    deps = [":test_proto"],
53)
54
55apple_resource_bundle(
56    name = "TestCertificates",
57    resources = ["TestCertificates.bundle/test-certificates.pem"],
58)
59
60# TestConfigs is added to each grpc_objc_testing_library's deps
61grpc_objc_testing_library(
62    name = "TestConfigs",
63    srcs = glob([
64        "Common/**/*.m",
65    ]),
66    hdrs = glob([
67        "Common/**/*.h",
68    ]) + ["version.h"],
69    data = [":TestCertificates"],
70    defines = [
71        "DEBUG=1",
72        "HOST_PORT_LOCALSSL=localhost:5051",
73        "HOST_PORT_LOCAL=localhost:5050",
74        "HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com",
75    ],
76)
77
78objc_library(
79    name = "host-lib",
80    srcs = glob(["Hosts/ios-host/*.m"]),
81    hdrs = glob(["Hosts/ios-host/*.h"]),
82)
83
84tvos_application(
85    name = "tvos-host",
86    bundle_id = "grpc.objc.tests.tvos-host",
87    infoplists = ["Hosts/ios-host/Info.plist"],
88    minimum_os_version = "10.0",
89    deps = ["host-lib"],
90)
91
92grpc_objc_testing_library(
93    name = "InteropTests-lib",
94    srcs = ["InteropTests/InteropTests.m"],
95    hdrs = ["InteropTests/InteropTests.h"],
96    deps = [
97        ":InteropTestsBlockCallbacks-lib",
98    ],
99)
100
101grpc_objc_testing_library(
102    name = "InteropTestsRemote-lib",
103    srcs = ["InteropTests/InteropTestsRemote.m"],
104    deps = [":InteropTests-lib"],
105)
106
107grpc_objc_testing_library(
108    name = "InteropTestsBlockCallbacks-lib",
109    srcs = ["InteropTests/InteropTestsBlockCallbacks.m"],
110    hdrs = ["InteropTests/InteropTestsBlockCallbacks.h"],
111)
112
113grpc_objc_testing_library(
114    name = "InteropTestsLocalSSL-lib",
115    srcs = ["InteropTests/InteropTestsLocalSSL.m"],
116    deps = [":InteropTests-lib"],
117)
118
119grpc_objc_testing_library(
120    name = "InteropTestsLocalCleartext-lib",
121    srcs = ["InteropTests/InteropTestsLocalCleartext.m"],
122    deps = [":InteropTests-lib"],
123)
124
125grpc_objc_testing_library(
126    name = "InteropTestsMultipleChannels-lib",
127    srcs = ["InteropTests/InteropTestsMultipleChannels.m"],
128    deps = [":InteropTests-lib"],
129)
130
131grpc_objc_testing_library(
132    name = "RxLibraryUnitTests-lib",
133    srcs = ["UnitTests/RxLibraryUnitTests.m"],
134)
135
136grpc_objc_testing_library(
137    name = "GRPCClientTests-lib",
138    srcs = ["UnitTests/GRPCClientTests.m"],
139)
140
141grpc_objc_testing_library(
142    name = "GRPCBasicUnitTests-lib",
143    srcs = ["UnitTests/GRPCCallOptionsTests.m"],
144)
145
146grpc_objc_testing_library(
147    name = "APIv2Tests-lib",
148    srcs = ["UnitTests/APIv2Tests.m"],
149)
150
151grpc_objc_testing_library(
152    name = "ChannelPoolTest-lib",
153    srcs = ["UnitTests/ChannelPoolTest.m"],
154)
155
156grpc_objc_testing_library(
157    name = "ChannelTests-lib",
158    srcs = ["UnitTests/ChannelTests.m"],
159)
160
161grpc_objc_testing_library(
162    name = "NSErrorUnitTests-lib",
163    srcs = ["UnitTests/NSErrorUnitTests.m"],
164)
165
166grpc_objc_testing_library(
167    name = "MacStressTests-lib",
168    srcs = glob([
169        "MacTests/*.m",
170    ]),
171    hdrs = ["MacTests/StressTests.h"],
172)
173
174# TODO: Enable this again once @CronetFramework is working
175#grpc_objc_testing_library(
176#    name = "CronetTests-lib",
177#    srcs = [
178#        "ConfigureCronet.m",
179#    ] + glob([
180#        "CronetTests/*.m",
181#        "CronetTests/*.mm",
182#    ]),
183#    hdrs = [
184#        "ConfigureCronet.h",
185#    ],
186#    deps = [
187#        "InteropTests-lib",
188#        "//src/objective-c:grpc_objc_client_core_cronet_testing",
189#        "//test/core/end2end:cq_verifier",
190#        "//test/core/end2end:ssl_test_data",
191#        "//third_party/objective_c/Cronet:cronet_c_for_grpc",
192#    ],
193#)
194#
195#grpc_objc_testing_library(
196#    name = "CppCronetTests-lib",
197#    srcs = glob([
198#        "CppCronetTests/*.m",
199#        "CppCronetTests/*.mm",
200#    ]),
201#    hdrs = glob([
202#        "CppCronetTests/*.h",
203#    ]),
204#    deps = [
205#        "//:grpc++_cronet_credentials",
206#        "//src/objective-c:grpc_objc_client_core_cronet_testing",
207#        "//src/proto/grpc/testing:echo_proto",
208#        "//test/core/end2end:ssl_test_data",
209#    ],
210#)
211#
212#grpc_objc_testing_library(
213#    name = "PerfTests-lib-Posix",
214#    srcs = [
215#        "ConfigureCronet.m",
216#        "PerfTests/PerfTests.m",
217#        "PerfTests/PerfTestsBlockCallbacks.m",
218#        "PerfTests/PerfTestsNoCFStreamSSL.m",
219#    ],
220#    hdrs = ["ConfigureCronet.h"] + glob(["PerfTests/*.h"]),
221#    deps = [
222#        "//src/objective-c:grpc_objc_client_core_cronet_testing",
223#    ],
224#)
225#
226#grpc_objc_testing_library(
227#    name = "PerfTests-lib",
228#    srcs = [
229#        "ConfigureCronet.m",
230#        "PerfTests/PerfTests.m",
231#        "PerfTests/PerfTestsBlockCallbacks.m",
232#        "PerfTests/PerfTestsCFStreamSSL.m",
233#        "PerfTests/PerfTestsCronet.m",
234#    ],
235#    hdrs = ["ConfigureCronet.h"] + glob(["PerfTests/*.h"]),
236#    deps = [
237#        "//src/objective-c:grpc_objc_client_core_cronet_testing",
238#    ],
239#)
240
241grpc_objc_testing_library(
242    name = "UnitTests",
243    deps = [
244        ":APIv2Tests-lib",
245        ":ChannelPoolTest-lib",
246        ":ChannelTests-lib",
247        ":GRPCBasicUnitTests-lib",
248        ":GRPCClientTests-lib",
249        ":NSErrorUnitTests-lib",
250        ":RxLibraryUnitTests-lib",
251    ],
252)
253
254grpc_objc_ios_unit_test(
255    name = "InteropTestsLocalCleartext",
256    deps = [
257        ":InteropTestsLocalCleartext-lib",
258    ],
259)
260
261grpc_objc_ios_unit_test(
262    name = "InteropTestsLocalSSL",
263    deps = [
264        ":InteropTestsLocalSSL-lib",
265    ],
266)
267
268grpc_objc_ios_unit_test(
269    name = "InteropTestsRemote",
270    deps = [
271        ":InteropTestsRemote-lib",
272    ],
273)
274
275# TODO: Enable this again once @CronetFramework is working
276# grpc_objc_ios_unit_test(
277#     name = "CronetTests",
278#     deps = [
279#         "CronetTests-lib",
280#     ],
281# )
282#
283# grpc_objc_ios_unit_test(
284#     name = "CppCronetTests",
285#     deps = [
286#         "CppCronetTests-lib",
287#     ],
288# )
289#
290# grpc_objc_ios_unit_test(
291#     name = "PerfTestsPosix",
292#     deps = [
293#         "PerfTests-lib-Posix",
294#     ],
295# )
296#
297# grpc_objc_ios_unit_test(
298#     name = "PerfTests",
299#     env = {
300#         "GRPC_CFSTREAM_RUN_LOOP": "1",
301#     },
302#     deps = [
303#         "PerfTests-lib",
304#     ],
305# )
306
307macos_unit_test(
308    name = "MacTests",
309    minimum_os_version = "10.10",
310    deps = [
311        ":APIv2Tests-lib",
312        ":InteropTestsLocalCleartext-lib",
313        ":InteropTestsLocalSSL-lib",
314        ":InteropTestsRemote-lib",
315        ":MacStressTests-lib",
316        ":NSErrorUnitTests-lib",
317        ":RxLibraryUnitTests-lib",
318    ],
319)
320
321grpc_objc_testing_library(
322    name = "CFStreamTests-lib",
323    srcs = glob(["CFStreamTests/*.mm"]),
324    deps = [
325        "//:gpr_platform",
326        "//src/core:iomgr_port",
327        "//test/core/util:grpc_test_util",
328    ],
329)
330
331grpc_objc_ios_unit_test(
332    name = "CFStreamTests",
333    deps = [":CFStreamTests-lib"],
334)
335
336grpc_objc_testing_library(
337    name = "EventEngineClientTests-lib",
338    srcs = ["EventEngineTests/CFEventEngineClientTests.mm"],
339    # defines = ["GRPC_IOS_EVENT_ENGINE_CLIENT=1"],
340    deps = [
341        "//src/core:cf_event_engine",
342        "//test/core/event_engine/test_suite/posix:oracle_event_engine_posix",
343        "//test/core/event_engine/test_suite/tests:client",
344    ],
345)
346
347grpc_objc_testing_library(
348    name = "EventEngineUnitTests-lib",
349    srcs = ["EventEngineTests/CFEventEngineUnitTests.mm"],
350    defines = ["GRPC_IOS_EVENT_ENGINE_CLIENT=1"],
351    deps = [
352        "//src/core:cf_event_engine",
353        "//test/core/event_engine/cf:cf_engine_unit_test_lib",
354        "//test/core/event_engine/test_suite/tests:dns",
355        "//test/core/event_engine/test_suite/tests:timer",
356    ],
357)
358
359grpc_objc_ios_unit_test(
360    name = "EventEngineClientTests",
361    deps = [":EventEngineClientTests-lib"],
362)
363
364grpc_objc_ios_unit_test(
365    name = "EventEngineUnitTests",
366    deps = [":EventEngineUnitTests-lib"],
367)
368
369# Note that bazel currently doesn't support running tvos_unit_test
370# See https://github.com/bazelbuild/rules_apple/blob/8d841342c238457896cd7596cc29b2d06c9a75f0/apple/testing/default_runner/tvos_test_runner.template.sh
371tvos_unit_test(
372    name = "TvTests",
373    minimum_os_version = "10.0",
374    test_host = ":tvos-host",
375    deps = [
376        ":APIv2Tests-lib",
377        ":InteropTestsLocalCleartext-lib",
378        ":InteropTestsLocalSSL-lib",
379        ":InteropTestsRemote-lib",
380        ":NSErrorUnitTests-lib",
381        ":RxLibraryUnitTests-lib",
382    ],
383)
384
385# TvTests is not runnable with bazel, so the best we can do is to test
386# that the testsuite builds correctly. This is achieved by having
387# a dummy sh_test depend on :TvTests.
388grpc_sh_test(
389    name = "tvtests_build_test",
390    srcs = [
391        "tvtests_build_test.sh",
392    ],
393    data = [
394        ":TvTests",
395    ],
396    uses_polling = False,
397)
398
399grpc_sh_test(
400    name = "objc_codegen_plugin_test",
401    srcs = ["PluginTest/plugin_test.sh"],
402    data = [
403        "//src/compiler:grpc_objective_c_plugin",
404        "@com_google_protobuf//:protoc",
405    ] + glob(["PluginTest/*.proto"]),
406    uses_polling = False,
407)
408
409grpc_sh_test(
410    name = "objc_codegen_plugin_option_test",
411    srcs = ["PluginTest/plugin_option_test.sh"],
412    data = [
413        "//src/compiler:grpc_objective_c_plugin",
414        "@com_google_protobuf//:protoc",
415        "@com_google_protobuf//:well_known_type_protos",
416    ] + glob(["RemoteTestClient/*.proto"]),
417    uses_polling = False,
418)
419