| 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 |
|
| 17 |
load("//bazel:grpc_build_system.bzl", "grpc_sh_test") |
| 18 |
load( |
| 19 |
"//src/objective-c:grpc_objc_internal_library.bzl", |
| 20 |
"grpc_objc_ios_unit_test", |
| 21 |
"grpc_objc_testing_library", |
| 22 |
"local_objc_grpc_library", |
| 23 |
"proto_library_objc_wrapper", |
| 24 |
) |
| 25 |
load("//test/core/end2end:generate_tests.bzl", "grpc_end2end_tests") |
| 26 |
load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") |
| 27 |
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_unit_test") |
| 28 |
load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_application", "tvos_unit_test") |
| 29 |
|
| 30 |
licenses(["notice"]) |
| 31 |
|
| 32 |
package(default_visibility = ["//visibility:public"]) |
| 33 |
|
| 34 |
exports_files(["LICENSE"]) |
| 35 |
|
| 36 |
grpc_end2end_tests() |
| 37 |
|
| 38 |
proto_library_objc_wrapper( |
| 39 |
name = "messages_proto", |
| 40 |
srcs = ["RemoteTestClient/messages.proto"], |
| 41 |
) |
| 42 |
|
| 43 |
proto_library_objc_wrapper( |
| 44 |
name = "test_proto", |
| 45 |
srcs = ["RemoteTestClient/test.proto"], |
| 46 |
use_well_known_protos = True, |
| 47 |
deps = [":messages_proto"], |
| 48 |
) |
| 49 |
|
| 50 |
local_objc_grpc_library( |
| 51 |
name = "RemoteTest", |
| 52 |
srcs = ["RemoteTestClient/test.proto"], |
| 53 |
testing = True, |
| 54 |
use_well_known_protos = True, |
| 55 |
deps = [":test_proto"], |
| 56 |
) |
| 57 |
|
| 58 |
apple_resource_bundle( |
| 59 |
name = "TestCertificates", |
| 60 |
resources = ["TestCertificates.bundle/test-certificates.pem"], |
| 61 |
) |
| 62 |
|
| 63 |
# TestConfigs is added to each grpc_objc_testing_library's deps |
| 64 |
grpc_objc_testing_library( |
| 65 |
name = "TestConfigs", |
| 66 |
srcs = glob([ |
| 67 |
"Common/**/*.m", |
| 68 |
]), |
| 69 |
hdrs = glob([ |
| 70 |
"Common/**/*.h", |
| 71 |
]) + ["version.h"], |
| 72 |
data = [":TestCertificates"], |
| 73 |
defines = [ |
| 74 |
"DEBUG=1", |
| 75 |
"HOST_PORT_LOCALSSL=localhost:5051", |
| 76 |
"HOST_PORT_LOCAL=localhost:5050", |
| 77 |
"HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com", |
| 78 |
], |
| 79 |
) |
| 80 |
|
| 81 |
objc_library( |
| 82 |
name = "host-lib", |
| 83 |
srcs = glob(["Hosts/ios-host/*.m"]), |
| 84 |
hdrs = glob(["Hosts/ios-host/*.h"]), |
| 85 |
) |
| 86 |
|
| 87 |
tvos_application( |
| 88 |
name = "tvos-host", |
| 89 |
bundle_id = "grpc.objc.tests.tvos-host", |
| 90 |
infoplists = ["Hosts/ios-host/Info.plist"], |
| 91 |
minimum_os_version = "10.0", |
| 92 |
deps = ["host-lib"], |
| 93 |
) |
| 94 |
|
| 95 |
grpc_objc_testing_library( |
| 96 |
name = "InteropTests-lib", |
| 97 |
srcs = ["InteropTests/InteropTests.m"], |
| 98 |
hdrs = ["InteropTests/InteropTests.h"], |
| 99 |
deps = [ |
| 100 |
":InteropTestsBlockCallbacks-lib", |
| 101 |
], |
| 102 |
) |
| 103 |
|
| 104 |
grpc_objc_testing_library( |
| 105 |
name = "InteropTestsRemote-lib", |
| 106 |
srcs = ["InteropTests/InteropTestsRemote.m"], |
| 107 |
deps = [":InteropTests-lib"], |
| 108 |
) |
| 109 |
|
| 110 |
grpc_objc_testing_library( |
| 111 |
name = "InteropTestsBlockCallbacks-lib", |
| 112 |
srcs = ["InteropTests/InteropTestsBlockCallbacks.m"], |
| 113 |
hdrs = ["InteropTests/InteropTestsBlockCallbacks.h"], |
| 114 |
) |
| 115 |
|
| 116 |
grpc_objc_testing_library( |
| 117 |
name = "InteropTestsLocalSSL-lib", |
| 118 |
srcs = ["InteropTests/InteropTestsLocalSSL.m"], |
| 119 |
deps = [":InteropTests-lib"], |
| 120 |
) |
| 121 |
|
| 122 |
grpc_objc_testing_library( |
| 123 |
name = "InteropTestsLocalCleartext-lib", |
| 124 |
srcs = ["InteropTests/InteropTestsLocalCleartext.m"], |
| 125 |
deps = [":InteropTests-lib"], |
| 126 |
) |
| 127 |
|
| 128 |
grpc_objc_testing_library( |
| 129 |
name = "InteropTestsMultipleChannels-lib", |
| 130 |
srcs = ["InteropTests/InteropTestsMultipleChannels.m"], |
| 131 |
deps = [":InteropTests-lib"], |
| 132 |
) |
| 133 |
|
| 134 |
grpc_objc_testing_library( |
| 135 |
name = "RxLibraryUnitTests-lib", |
| 136 |
srcs = ["UnitTests/RxLibraryUnitTests.m"], |
| 137 |
) |
| 138 |
|
| 139 |
grpc_objc_testing_library( |
| 140 |
name = "GRPCClientTests-lib", |
| 141 |
srcs = ["UnitTests/GRPCClientTests.m"], |
| 142 |
) |
| 143 |
|
| 144 |
grpc_objc_testing_library( |
| 145 |
name = "GRPCBasicUnitTests-lib", |
| 146 |
srcs = ["UnitTests/GRPCCallOptionsTests.m"], |
| 147 |
) |
| 148 |
|
| 149 |
grpc_objc_testing_library( |
| 150 |
name = "APIv2Tests-lib", |
| 151 |
srcs = ["UnitTests/APIv2Tests.m"], |
| 152 |
) |
| 153 |
|
| 154 |
grpc_objc_testing_library( |
| 155 |
name = "ChannelPoolTest-lib", |
| 156 |
srcs = ["UnitTests/ChannelPoolTest.m"], |
| 157 |
) |
| 158 |
|
| 159 |
grpc_objc_testing_library( |
| 160 |
name = "ChannelTests-lib", |
| 161 |
srcs = ["UnitTests/ChannelTests.m"], |
| 162 |
) |
| 163 |
|
| 164 |
grpc_objc_testing_library( |
| 165 |
name = "NSErrorUnitTests-lib", |
| 166 |
srcs = ["UnitTests/NSErrorUnitTests.m"], |
| 167 |
) |
| 168 |
|
| 169 |
grpc_objc_testing_library( |
| 170 |
name = "MacStressTests-lib", |
| 171 |
srcs = glob([ |
| 172 |
"MacTests/*.m", |
| 173 |
]), |
| 174 |
hdrs = ["MacTests/StressTests.h"], |
| 175 |
) |
| 176 |
|
| 177 |
grpc_objc_testing_library( |
| 178 |
name = "CronetTests-lib", |
| 179 |
srcs = [ |
| 180 |
"ConfigureCronet.m", |
| 181 |
] + glob([ |
| 182 |
"CronetTests/*.m", |
| 183 |
"CronetTests/*.mm", |
| 184 |
]), |
| 185 |
hdrs = [ |
| 186 |
"ConfigureCronet.h", |
| 187 |
], |
| 188 |
deps = [ |
| 189 |
"InteropTests-lib", |
| 190 |
"//src/objective-c:grpc_objc_client_core_cronet_testing", |
| 191 |
"//test/core/end2end:end2end_tests", |
| 192 |
"//third_party/objective_c/Cronet:cronet_c_for_grpc", |
| 193 |
], |
| 194 |
) |
| 195 |
|
| 196 |
grpc_objc_testing_library( |
| 197 |
name = "PerfTests-lib-Posix", |
| 198 |
srcs = [ |
| 199 |
"ConfigureCronet.m", |
| 200 |
"PerfTests/PerfTests.m", |
| 201 |
"PerfTests/PerfTestsBlockCallbacks.m", |
| 202 |
"PerfTests/PerfTestsNoCFStreamSSL.m", |
| 203 |
], |
| 204 |
hdrs = ["ConfigureCronet.h"] + glob(["PerfTests/*.h"]), |
| 205 |
deps = [ |
| 206 |
"//src/objective-c:grpc_objc_client_core_cronet_testing", |
| 207 |
], |
| 208 |
) |
| 209 |
|
| 210 |
grpc_objc_testing_library( |
| 211 |
name = "PerfTests-lib", |
| 212 |
srcs = [ |
| 213 |
"ConfigureCronet.m", |
| 214 |
"PerfTests/PerfTests.m", |
| 215 |
"PerfTests/PerfTestsBlockCallbacks.m", |
| 216 |
"PerfTests/PerfTestsCFStreamSSL.m", |
| 217 |
"PerfTests/PerfTestsCronet.m", |
| 218 |
], |
| 219 |
hdrs = ["ConfigureCronet.h"] + glob(["PerfTests/*.h"]), |
| 220 |
deps = [ |
| 221 |
"//src/objective-c:grpc_objc_client_core_cronet_testing", |
| 222 |
], |
| 223 |
) |
| 224 |
|
| 225 |
grpc_objc_testing_library( |
| 226 |
name = "UnitTests", |
| 227 |
deps = [ |
| 228 |
":APIv2Tests-lib", |
| 229 |
":ChannelPoolTest-lib", |
| 230 |
":ChannelTests-lib", |
| 231 |
":GRPCBasicUnitTests-lib", |
| 232 |
":GRPCClientTests-lib", |
| 233 |
":NSErrorUnitTests-lib", |
| 234 |
":RxLibraryUnitTests-lib", |
| 235 |
], |
| 236 |
) |
| 237 |
|
| 238 |
grpc_objc_ios_unit_test( |
| 239 |
name = "InteropTestsLocalCleartext", |
| 240 |
deps = [ |
| 241 |
":InteropTestsLocalCleartext-lib", |
| 242 |
], |
| 243 |
) |
| 244 |
|
| 245 |
grpc_objc_ios_unit_test( |
| 246 |
name = "InteropTestsLocalSSL", |
| 247 |
deps = [ |
| 248 |
":InteropTestsLocalSSL-lib", |
| 249 |
], |
| 250 |
) |
| 251 |
|
| 252 |
grpc_objc_ios_unit_test( |
| 253 |
name = "InteropTestsRemote", |
| 254 |
deps = [ |
| 255 |
":InteropTestsRemote-lib", |
| 256 |
], |
| 257 |
) |
| 258 |
|
| 259 |
grpc_objc_ios_unit_test( |
| 260 |
name = "CronetTests", |
| 261 |
deps = [ |
| 262 |
"CronetTests-lib", |
| 263 |
], |
| 264 |
) |
| 265 |
|
| 266 |
grpc_objc_ios_unit_test( |
| 267 |
name = "PerfTestsPosix", |
| 268 |
deps = [ |
| 269 |
"PerfTests-lib-Posix", |
| 270 |
], |
| 271 |
) |
| 272 |
|
| 273 |
grpc_objc_ios_unit_test( |
| 274 |
name = "PerfTests", |
| 275 |
env = { |
| 276 |
"GRPC_CFSTREAM_RUN_LOOP": "1", |
| 277 |
}, |
| 278 |
deps = [ |
| 279 |
"PerfTests-lib", |
| 280 |
], |
| 281 |
) |
| 282 |
|
| 283 |
macos_unit_test( |
| 284 |
name = "MacTests", |
| 285 |
minimum_os_version = "10.10", |
| 286 |
deps = [ |
| 287 |
":APIv2Tests-lib", |
| 288 |
":InteropTestsLocalCleartext-lib", |
| 289 |
":InteropTestsLocalSSL-lib", |
| 290 |
":InteropTestsRemote-lib", |
| 291 |
":MacStressTests-lib", |
| 292 |
":NSErrorUnitTests-lib", |
| 293 |
":RxLibraryUnitTests-lib", |
| 294 |
], |
| 295 |
) |
| 296 |
|
| 297 |
# Note that bazel currently doesn't support running tvos_unit_test |
| 298 |
# See https://github.com/bazelbuild/rules_apple/blob/8d841342c238457896cd7596cc29b2d06c9a75f0/apple/testing/default_runner/tvos_test_runner.template.sh |
| 299 |
tvos_unit_test( |
| 300 |
name = "TvTests", |
| 301 |
minimum_os_version = "10.0", |
| 302 |
test_host = ":tvos-host", |
| 303 |
deps = [ |
| 304 |
":APIv2Tests-lib", |
| 305 |
":InteropTestsLocalCleartext-lib", |
| 306 |
":InteropTestsLocalSSL-lib", |
| 307 |
":InteropTestsRemote-lib", |
| 308 |
":NSErrorUnitTests-lib", |
| 309 |
":RxLibraryUnitTests-lib", |
| 310 |
], |
| 311 |
) |
| 312 |
|
| 313 |
# TvTests is not runnable with bazel, so the best we can do is to test |
| 314 |
# that the testsuite builds correctly. This is achieved by having |
| 315 |
# a dummy sh_test depend on :TvTests. |
| 316 |
grpc_sh_test( |
| 317 |
name = "tvtests_build_test", |
| 318 |
srcs = [ |
| 319 |
"tvtests_build_test.sh", |
| 320 |
], |
| 321 |
data = [ |
| 322 |
":TvTests", |
| 323 |
], |
| 324 |
uses_polling = False, |
| 325 |
) |
| 326 |
|
| 327 |
grpc_sh_test( |
| 328 |
name = "objc_codegen_plugin_test", |
| 329 |
srcs = ["PluginTest/plugin_test.sh"], |
| 330 |
data = [ |
| 331 |
"@com_google_protobuf//:protoc", |
| 332 |
"//src/compiler:grpc_objective_c_plugin", |
| 333 |
] + glob(["PluginTest/*.proto"]), |
| 334 |
uses_polling = False, |
| 335 |
) |
| 336 |
|
| 337 |
grpc_sh_test( |
| 338 |
name = "objc_codegen_plugin_option_test", |
| 339 |
srcs = ["PluginTest/plugin_option_test.sh"], |
| 340 |
data = [ |
| 341 |
"@com_google_protobuf//:protoc", |
| 342 |
"//src/compiler:grpc_objective_c_plugin", |
| 343 |
"@com_google_protobuf//:well_known_type_protos", |
| 344 |
] + glob(["RemoteTestClient/*.proto"]), |
| 345 |
uses_polling = False, |
| 346 |
) |