[ObjC] run cf event engine test suit on ios (#33534)

Run cf event engine test suit on ios

CC: @sampajano  @mikefan1991
pull/33546/head
Hannah Shi 2 years ago committed by GitHub
parent 059144abd6
commit c6e4a60f8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      src/objective-c/tests/BUILD
  2. 65
      src/objective-c/tests/EventEngineTests/CFEventEngineTests.mm
  3. 5
      test/core/event_engine/test_suite/posix/BUILD
  4. 1
      tools/internal_ci/macos/grpc_objc_bazel_test.sh

@ -333,6 +333,23 @@ grpc_objc_ios_unit_test(
deps = [":CFStreamTests-lib"],
)
grpc_objc_testing_library(
name = "EventEngineTests-lib",
srcs = glob(["EventEngineTests/*.mm"]),
# defines = ["GRPC_IOS_EVENT_ENGINE_CLIENT=1"],
deps = [
"//src/core:cf_event_engine",
"//test/core/event_engine/test_suite/posix:oracle_event_engine_posix",
"//test/core/event_engine/test_suite/tests:client",
"//test/core/event_engine/test_suite/tests:timer",
],
)
grpc_objc_ios_unit_test(
name = "EventEngineTests",
deps = [":EventEngineTests-lib"],
)
# Note that bazel currently doesn't support running tvos_unit_test
# See https://github.com/bazelbuild/rules_apple/blob/8d841342c238457896cd7596cc29b2d06c9a75f0/apple/testing/default_runner/tvos_test_runner.template.sh
tvos_unit_test(
@ -367,8 +384,8 @@ grpc_sh_test(
name = "objc_codegen_plugin_test",
srcs = ["PluginTest/plugin_test.sh"],
data = [
"@com_google_protobuf//:protoc",
"//src/compiler:grpc_objective_c_plugin",
"@com_google_protobuf//:protoc",
] + glob(["PluginTest/*.proto"]),
uses_polling = False,
)
@ -377,8 +394,8 @@ grpc_sh_test(
name = "objc_codegen_plugin_option_test",
srcs = ["PluginTest/plugin_option_test.sh"],
data = [
"@com_google_protobuf//:protoc",
"//src/compiler:grpc_objective_c_plugin",
"@com_google_protobuf//:protoc",
"@com_google_protobuf//:well_known_type_protos",
] + glob(["RemoteTestClient/*.proto"]),
uses_polling = False,

@ -0,0 +1,65 @@
/*
*
* Copyright 2023 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#import <XCTest/XCTest.h>
#include <grpc/grpc.h>
#include "src/core/lib/event_engine/cf_engine/cf_engine.h"
#include "test/core/event_engine/test_suite/event_engine_test_framework.h"
#include "test/core/event_engine/test_suite/posix/oracle_event_engine_posix.h"
#include "test/core/event_engine/test_suite/tests/client_test.h"
#include "test/core/event_engine/test_suite/tests/timer_test.h"
#include "test/core/util/test_config.h"
@interface EventEngineTimerTests : XCTestCase
@end
@implementation EventEngineTimerTests
- (void)testAll {
NSArray *arguments = [NSProcessInfo processInfo].arguments;
int argc = (int)arguments.count;
char **argv = static_cast<char **>(alloca((sizeof(char *) * (argc + 1))));
for (int index = 0; index < argc; index++) {
argv[index] = const_cast<char *>([arguments[index] UTF8String]);
}
argv[argc] = NULL;
testing::InitGoogleTest(&argc, (char **)argv);
grpc::testing::TestEnvironment env(&argc, (char **)argv);
auto factory = []() {
return std::make_unique<grpc_event_engine::experimental::CFEventEngine>();
};
auto oracle_factory = []() {
return std::make_unique<grpc_event_engine::experimental::PosixOracleEventEngine>();
};
SetEventEngineFactories(factory, oracle_factory);
grpc_event_engine::experimental::InitTimerTests();
grpc_event_engine::experimental::InitClientTests();
// TODO(ctiller): EventEngine temporarily needs grpc to be initialized first
// until we clear out the iomgr shutdown code.
grpc_init();
int r = RUN_ALL_TESTS();
grpc_shutdown();
XCTAssertEqual(r, 0);
}
@end

@ -27,7 +27,10 @@ grpc_cc_library(
"cpu:10",
"no_windows",
],
visibility = ["//test:__subpackages__"],
visibility = [
"//src/objective-c/tests:__subpackages__",
"//test:__subpackages__",
],
deps = [
"//:grpc",
"//test/core/event_engine:event_engine_test_utils",

@ -61,6 +61,7 @@ TEST_TARGETS=(
#//src/objective-c/tests:CronetTests
#//src/objective-c/tests:PerfTests
//src/objective-c/tests:CFStreamTests
//src/objective-c/tests:EventEngineTests
//src/objective-c/tests:tvtests_build_test
# codegen plugin tests
//src/objective-c/tests:objc_codegen_plugin_test

Loading…
Cancel
Save