mirror of https://github.com/grpc/grpc.git
[gRPC/iOS] Introduce common test util for reading interop server addr (#29774)
parent
887a605940
commit
62032f6838
13 changed files with 156 additions and 51 deletions
@ -0,0 +1,20 @@ |
||||
Pod::Spec.new do |s| |
||||
s.name = 'Common' |
||||
s.version = "0.0.1" |
||||
s.license = "Apache License, Version 2.0" |
||||
s.authors = { 'gRPC contributors' => 'grpc-io@googlegroups.com' } |
||||
s.homepage = "https://grpc.io/" |
||||
s.summary = "Shared common test utils" |
||||
s.source = { :git => 'https://github.com/grpc/grpc.git' } |
||||
|
||||
s.ios.deployment_target = '9.0' |
||||
s.osx.deployment_target = '10.10' |
||||
s.tvos.deployment_target = '10.0' |
||||
s.watchos.deployment_target = '4.0' |
||||
s.framework = 'XCTest' |
||||
|
||||
s.dependency "gRPC-ProtoRPC" |
||||
|
||||
s.source_files = '**/*.{m}' |
||||
s.public_header_files = '**/*.{h}' |
||||
end |
@ -0,0 +1,44 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2019 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 <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
* Common utility to fetch plain text local interop server address. |
||||
* |
||||
* @return Interop test server address including host and port. |
||||
*/ |
||||
FOUNDATION_EXPORT NSString *GRPCGetLocalInteropTestServerAddressPlainText(void); |
||||
|
||||
/**
|
||||
* Common utility to fetch ssl local interop server address. |
||||
* |
||||
* @return Interop test server address including host and port. |
||||
*/ |
||||
FOUNDATION_EXPORT NSString *GRPCGetLocalInteropTestServerAddressSSL(void); |
||||
|
||||
/**
|
||||
* Common utility to fetch remote interop test server address. |
||||
* |
||||
* @return Interop test server address including host and port. |
||||
*/ |
||||
FOUNDATION_EXPORT NSString *GRPCGetRemoteInteropTestServerAddress(void); |
||||
|
||||
NS_ASSUME_NONNULL_END |
@ -0,0 +1,51 @@ |
||||
/** |
||||
* Copyright 2022 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 "TestUtils.h" |
||||
|
||||
// Utility macro to stringize preprocessor defines |
||||
#define NSStringize_helper(x) #x |
||||
#define NSStringize(x) @NSStringize_helper(x) |
||||
|
||||
NSString *GRPCGetLocalInteropTestServerAddressPlainText() { |
||||
static NSString *address; |
||||
static dispatch_once_t onceToken; |
||||
dispatch_once(&onceToken, ^{ |
||||
address = |
||||
[NSProcessInfo processInfo].environment[@"HOST_PORT_LOCAL"] ?: NSStringize(HOST_PORT_LOCAL); |
||||
}); |
||||
return address; |
||||
} |
||||
|
||||
NSString *GRPCGetLocalInteropTestServerAddressSSL() { |
||||
static NSString *address; |
||||
static dispatch_once_t onceToken; |
||||
dispatch_once(&onceToken, ^{ |
||||
address = [NSProcessInfo processInfo].environment[@"HOST_PORT_LOCALSSL"] |
||||
?: NSStringize(HOST_PORT_LOCALSSL); |
||||
}); |
||||
return address; |
||||
} |
||||
|
||||
NSString *GRPCGetRemoteInteropTestServerAddress() { |
||||
static NSString *address; |
||||
static dispatch_once_t onceToken; |
||||
dispatch_once(&onceToken, ^{ |
||||
address = [NSProcessInfo processInfo].environment[@"HOST_PORT_REMOTE"] |
||||
?: NSStringize(HOST_PORT_REMOTE); |
||||
}); |
||||
return address; |
||||
} |
Loading…
Reference in new issue