Establish Objective C end-to-end core test with Cronet

pull/7368/head
Muxi Yan 9 years ago
parent 7deb5fd795
commit 4a7aca0e4b
  1. 37
      gRPC-Cronet.podspec
  2. 8
      src/objective-c/tests/End2EndTest/End2EndTest.xcodeproj/project.pbxproj
  3. 39
      src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.h
  4. 39
      src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.m
  5. 15
      src/objective-c/tests/End2EndTest/End2EndTest/h2_ssl.m
  6. 16
      src/objective-c/tests/End2EndTest/End2EndTest/main.m
  7. 49
      src/objective-c/tests/End2EndTest/Podfile

@ -52,12 +52,34 @@ Pod::Spec.new do |s|
s.osx.deployment_target = '10.9'
s.requires_arc = false
name = 'grpc'
name = 'GRPCCronet'
s.module_name = name
s.header_mappings_dir = '.'
# When creating a dynamic framework, copy the headers under `include/grpc/` into the root of
# the `Headers/` directory of the framework (i.e., not under `Headers/include/grpc`).
s.header_mappings_dir = 'include/grpc'
# The above has an undesired effect when creating a static library: It forces users to write
# includes like `#include <gRPC-Cronet/grpc.h>`. `s.header_dir` adds a path prefix to that, and
# because Cocoapods lets omit the pod name when including headers of static libraries, the
# following lets users write `#include <grpc/grpc.h>`.
s.header_dir = 'grpc'
# To compile the library, we need the user headers search path (quoted includes) to point to the
# root of the repo, and the system headers search path (angled includes) to point to `include/`.
# Cocoapods effectively clones the repo under `<Podfile dir>/Pods/gRPC-Cronet/`, and sets a build
# variable called `$(PODS_ROOT)` to `<Podfile dir>/Pods/`, so we use that.
#
# Relying on the file structure under $(PODS_ROOT) isn't officially supported in Cocoapods, as it
# is taken as an implementation detail. We've asked for an alternative, and have been told that
# what we're doing should keep working: https://github.com/CocoaPods/CocoaPods/issues/4386
#
# The `src_root` value of `$(PODS_ROOT)/gRPC-Cronet` assumes Cocoapods is installing this pod from
# its remote repo. For local development of this library, enabled by using `:path` in the Podfile,
# that assumption is wrong. In such case, the following settings need to be reset with the
# appropriate value of `src_root`. This can be accomplished in the `pre_install` hook of the
# Podfile; see `src/objective-c/tests/Podfile` for an example.
src_root = '$(PODS_ROOT)/gRPC-Cronet'
s.pod_target_xcconfig = {
'GRPC_SRC_ROOT' => src_root,
@ -80,9 +102,16 @@ Pod::Spec.new do |s|
ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.c',
'src/core/ext/transport/cronet/transport/cronet_transport.c',
'test/core/end2end/**/*.{c,h}',
'test/core/util'
'test/core/end2end/cq_verifier.{c,h}',
'test/core/end2end/end2end_tests.{c,h}',
'test/core/end2end/tests/*.{c,h}',
'test/core/end2end/data/*.{c,h}',
'test/core/util/test_config.{c,h}',
'test/core/util/port.h',
'test/core/util/port_posix.c',
'test/core/util/port_server_client.{c,h}'
ss.dependency 'gRPC-Core', version
ss.dependency 'CronetFramework'
end
end

@ -13,11 +13,12 @@
5E201A7F1D3452D600A81F3A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5E201A7E1D3452D600A81F3A /* Assets.xcassets */; };
5E201A821D3452D600A81F3A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E201A801D3452D600A81F3A /* LaunchScreen.storyboard */; };
5EC76B971D36B2EE00A74FED /* h2_ssl.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EC76B961D36B2EE00A74FED /* h2_ssl.m */; };
C124E05DC4ED9F5CA3EFD20D /* libPods-End2EndTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 931C29940B821E295AA90634 /* libPods-End2EndTest.a */; };
809A4524D003F25B67A9E20C /* libPods-End2EndTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 45442114339F6871ABA5F464 /* libPods-End2EndTest.a */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
18957F402A222D334CEBE57B /* Pods-End2EndTest.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-End2EndTest.debug.xcconfig"; path = "Pods/Target Support Files/Pods-End2EndTest/Pods-End2EndTest.debug.xcconfig"; sourceTree = "<group>"; };
45442114339F6871ABA5F464 /* libPods-End2EndTest.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-End2EndTest.a"; sourceTree = BUILT_PRODUCTS_DIR; };
5E201A6F1D3452D500A81F3A /* End2EndTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = End2EndTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
5E201A751D3452D500A81F3A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
5E201A761D3452D500A81F3A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@ -28,7 +29,6 @@
5E201A811D3452D600A81F3A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
5E201A831D3452D600A81F3A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5EC76B961D36B2EE00A74FED /* h2_ssl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = h2_ssl.m; sourceTree = "<group>"; };
931C29940B821E295AA90634 /* libPods-End2EndTest.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-End2EndTest.a"; sourceTree = BUILT_PRODUCTS_DIR; };
E7725B916D22B5AC6ECF8964 /* Pods-End2EndTest.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-End2EndTest.release.xcconfig"; path = "Pods/Target Support Files/Pods-End2EndTest/Pods-End2EndTest.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -37,7 +37,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C124E05DC4ED9F5CA3EFD20D /* libPods-End2EndTest.a in Frameworks */,
809A4524D003F25B67A9E20C /* libPods-End2EndTest.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -98,7 +98,7 @@
D564C37197511893E4E62D12 /* Frameworks */ = {
isa = PBXGroup;
children = (
931C29940B821E295AA90634 /* libPods-End2EndTest.a */,
45442114339F6871ABA5F464 /* libPods-End2EndTest.a */,
);
name = Frameworks;
sourceTree = "<group>";

@ -1,10 +1,35 @@
//
// AppDelegate.h
// End2EndTest
//
// Created by mxyan on 7/11/16.
// Copyright © 2016 Google. All rights reserved.
//
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#import <UIKit/UIKit.h>

@ -1,10 +1,35 @@
//
// AppDelegate.m
// End2EndTest
//
// Created by mxyan on 7/11/16.
// Copyright © 2016 Google. All rights reserved.
//
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#import "AppDelegate.h"

@ -31,6 +31,13 @@
*
*/
/*
* This fixture creates a server full stack using chttp2 and a client
* full stack using Cronet. End-to-end tests are run against this fixture
* setting.
*
*/
#include "test/core/end2end/end2end_tests.h"
#include <stdio.h>
@ -83,7 +90,7 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx,
cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL);
}
static void chttp2_init_client_secure_fullstack(
static void cronet_init_client_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
cronet_engine *cronetEngine) {
fullstack_secure_fixture_data *ffd = f->fixture_data;
@ -113,7 +120,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
gpr_free(ffd);
}
static void chttp2_init_client_simple_ssl_secure_fullstack(
static void cronet_init_client_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
grpc_arg ssl_name_override = {GRPC_ARG_STRING,
GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
@ -125,7 +132,7 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
[Cronet start];
cronet_engine *cronetEngine = [Cronet getGlobalEngine];
chttp2_init_client_secure_fullstack(f, new_client_args, cronetEngine);
cronet_init_client_secure_fullstack(f, new_client_args, cronetEngine);
grpc_channel_args_destroy(new_client_args);
}
@ -161,7 +168,7 @@ static grpc_end2end_test_config configs[] = {
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS,
chttp2_create_fixture_secure_fullstack,
chttp2_init_client_simple_ssl_secure_fullstack,
cronet_init_client_simple_ssl_secure_fullstack,
chttp2_init_server_simple_ssl_secure_fullstack,
chttp2_tear_down_secure_fullstack},
};

@ -1,16 +0,0 @@
//
// main.m
// End2EndTest
//
// Created by mxyan on 7/11/16.
// Copyright © 2016 Google. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}

@ -32,38 +32,25 @@ end
#
# TODO(jcanizales): Send a PR to Cocoapods to get rid of this need.
pre_install do |installer|
# This is the gRPC-Core podspec object, as initialized by its podspec file.
grpc_core_spec = installer.pod_targets.find{|t| t.name == 'gRPC-Core'}.root_spec
# Copied from gRPC-Core.podspec, except for the adjusted src_root:
src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}"
grpc_core_spec.pod_target_xcconfig = {
'GRPC_SRC_ROOT' => src_root,
'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
# If we don't set these two settings, `include/grpc/support/time.h` and
# `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
# build.
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
}
# This is the gRPC-Core podspec object, as initialized by its podspec file.
grpc_core_spec = installer.pod_targets.find{|t| t.name == 'gRPC-Cronet'}.root_spec
# Copied from gRPC-Core.podspec, except for the adjusted src_root:
src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}"
grpc_core_spec.pod_target_xcconfig = {
'GRPC_SRC_ROOT' => src_root,
'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
# If we don't set these two settings, `include/grpc/support/time.h` and
# `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
# build.
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
}
%w(
gRPC-Core
gRPC-Cronet
).each do |target_name|
grpc_core_spec = installer.pod_targets.find{|t| t.name == target_name}.root_spec
# Copied from gRPC-Core.podspec, except for the adjusted src_root:
src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}"
grpc_core_spec.pod_target_xcconfig = {
'GRPC_SRC_ROOT' => src_root,
'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
# If we don't set these two settings, `include/grpc/support/time.h` and
# `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking
# the build.
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
}
end
end
post_install do |installer|

Loading…
Cancel
Save