aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2016-07-13 15:32:13 -0700
committerGravatar Muxi Yan <mxyan@google.com>2016-07-13 15:32:13 -0700
commit4a7aca0e4bf357aa9755ac2a61ef23bf9035b3c1 (patch)
tree4c4a262f7dec12a081ab3350ed74f2fd2b2d09a7
parent7deb5fd79562388a928aaa3da37bbc8921ebc162 (diff)
Establish Objective C end-to-end core test with Cronet
-rw-r--r--gRPC-Cronet.podspec37
-rw-r--r--src/objective-c/tests/End2EndTest/End2EndTest.xcodeproj/project.pbxproj8
-rw-r--r--src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.h39
-rw-r--r--src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.m39
-rw-r--r--src/objective-c/tests/End2EndTest/End2EndTest/h2_ssl.m15
-rw-r--r--src/objective-c/tests/End2EndTest/End2EndTest/main.m16
-rw-r--r--src/objective-c/tests/End2EndTest/Podfile49
7 files changed, 130 insertions, 73 deletions
diff --git a/gRPC-Cronet.podspec b/gRPC-Cronet.podspec
index 8db5490e0e..b353bf9a43 100644
--- a/gRPC-Cronet.podspec
+++ b/gRPC-Cronet.podspec
@@ -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
diff --git a/src/objective-c/tests/End2EndTest/End2EndTest.xcodeproj/project.pbxproj b/src/objective-c/tests/End2EndTest/End2EndTest.xcodeproj/project.pbxproj
index bc5006e936..a878db9c2e 100644
--- a/src/objective-c/tests/End2EndTest/End2EndTest.xcodeproj/project.pbxproj
+++ b/src/objective-c/tests/End2EndTest/End2EndTest.xcodeproj/project.pbxproj
@@ -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>";
diff --git a/src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.h b/src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.h
index dbc592fcc8..867e62842a 100644
--- a/src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.h
+++ b/src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.h
@@ -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>
diff --git a/src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.m b/src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.m
index a4beef9954..66fceffd85 100644
--- a/src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.m
+++ b/src/objective-c/tests/End2EndTest/End2EndTest/AppDelegate.m
@@ -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"
diff --git a/src/objective-c/tests/End2EndTest/End2EndTest/h2_ssl.m b/src/objective-c/tests/End2EndTest/End2EndTest/h2_ssl.m
index 2649546fca..800dd56649 100644
--- a/src/objective-c/tests/End2EndTest/End2EndTest/h2_ssl.m
+++ b/src/objective-c/tests/End2EndTest/End2EndTest/h2_ssl.m
@@ -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},
};
diff --git a/src/objective-c/tests/End2EndTest/End2EndTest/main.m b/src/objective-c/tests/End2EndTest/End2EndTest/main.m
deleted file mode 100644
index a1894cdb41..0000000000
--- a/src/objective-c/tests/End2EndTest/End2EndTest/main.m
+++ /dev/null
@@ -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]));
- }
-}
diff --git a/src/objective-c/tests/End2EndTest/Podfile b/src/objective-c/tests/End2EndTest/Podfile
index 59b64badfb..a3fd4d5e95 100644
--- a/src/objective-c/tests/End2EndTest/Podfile
+++ b/src/objective-c/tests/End2EndTest/Podfile
@@ -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|