1#!/bin/bash 2# Copyright 2015 gRPC authors. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16# Don't run this script standalone. Instead, run from the repository root: 17# ./tools/run_tests/run_tests.py -l objc 18 19set -ev 20 21cd $(dirname $0) 22 23# Run the tests server. 24 25BINDIR=../../../bins/$CONFIG 26 27[ -f $BINDIR/interop_server ] || { 28 echo >&2 "Can't find the test server. Make sure run_tests.py is making" \ 29 "interop_server before calling this script." 30 exit 1 31} 32$BINDIR/interop_server --port=5050 --max_send_message_size=8388608 & 33$BINDIR/interop_server --port=5051 --max_send_message_size=8388608 --use_tls & 34# Kill them when this script exits. 35trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT 36 37set -o pipefail 38 39# xcodebuild is very verbose. We filter its output and tell Bash to fail if any 40# element of the pipe fails. 41# TODO(jcanizales): Use xctool instead? Issue #2540. 42XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )' 43 44echo "TIME: $(date)" 45 46# Retry the test for up to 3 times when return code is 65, due to Xcode issue: 47# http://www.openradar.me/29785686 48# The issue seems to be a connectivity issue to Xcode simulator so only retry 49# the first xcodebuild command 50retries=0 51while [ $retries -lt 3 ]; do 52 return_code=0 53 out=$(xcodebuild \ 54 -workspace Tests.xcworkspace \ 55 -scheme AllTests \ 56 -destination name="iPhone 8" \ 57 HOST_PORT_LOCALSSL=localhost:5051 \ 58 HOST_PORT_LOCAL=localhost:5050 \ 59 HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ 60 test 2>&1 \ 61 | egrep -v "$XCODEBUILD_FILTER" \ 62 | egrep -v '^$' \ 63 | egrep -v "(GPBDictionary|GPBArray)" - ) || return_code=$? 64 if [ $return_code == 65 ] && [[ $out == *"DTXProxyChannel error 1"* ]]; then 65 echo "$out" 66 echo "Failed with code 65 (DTXProxyChannel error 1); retry." 67 retries=$(($retries+1)) 68 elif [ $return_code == 0 ]; then 69 echo "$out" 70 break 71 else 72 echo "$out" 73 echo "Failed with code $return_code." 74 exit 1 75 fi 76done 77if [ $retries == 3 ]; then 78 echo "Failed with code 65 for 3 times; abort." 79 exit 1 80fi 81 82echo "TIME: $(date)" 83xcodebuild \ 84 -workspace Tests.xcworkspace \ 85 -scheme CoreCronetEnd2EndTests \ 86 -destination name="iPhone 8" \ 87 test \ 88 | egrep -v "$XCODEBUILD_FILTER" \ 89 | egrep -v '^$' \ 90 | egrep -v "(GPBDictionary|GPBArray)" - 91 92echo "TIME: $(date)" 93xcodebuild \ 94 -workspace Tests.xcworkspace \ 95 -scheme CoreCronetEnd2EndTests_Asan \ 96 -destination name="iPhone 6" \ 97 test \ 98 | egrep -v "$XCODEBUILD_FILTER" \ 99 | egrep -v '^$' \ 100 | egrep -v "(GPBDictionary|GPBArray)" - 101 102echo "TIME: $(date)" 103xcodebuild \ 104 -workspace Tests.xcworkspace \ 105 -scheme CoreCronetEnd2EndTests_Tsan \ 106 -destination name="iPhone 6" \ 107 test \ 108 | egrep -v "$XCODEBUILD_FILTER" \ 109 | egrep -v '^$' \ 110 | egrep -v "(GPBDictionary|GPBArray)" - 111 112echo "TIME: $(date)" 113xcodebuild \ 114 -workspace Tests.xcworkspace \ 115 -scheme CronetUnitTests \ 116 -destination name="iPhone 8" \ 117 test \ 118 | egrep -v "$XCODEBUILD_FILTER" \ 119 | egrep -v '^$' \ 120 | egrep -v "(GPBDictionary|GPBArray)" - 121 122echo "TIME: $(date)" 123xcodebuild \ 124 -workspace Tests.xcworkspace \ 125 -scheme InteropTestsRemoteWithCronet \ 126 -destination name="iPhone 8" \ 127 HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ 128 test \ 129 | egrep -v "$XCODEBUILD_FILTER" \ 130 | egrep -v '^$' \ 131 | egrep -v "(GPBDictionary|GPBArray)" - 132 133echo "TIME: $(date)" 134xcodebuild \ 135 -workspace Tests.xcworkspace \ 136 -scheme InteropTestsRemoteCFStream \ 137 -destination name="iPhone 8" \ 138 HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ 139 test \ 140 | egrep -v "$XCODEBUILD_FILTER" \ 141 | egrep -v '^$' \ 142 | egrep -v "(GPBDictionary|GPBArray)" - 143 144echo "TIME: $(date)" 145xcodebuild \ 146 -workspace Tests.xcworkspace \ 147 -scheme InteropTestsLocalCleartextCFStream \ 148 -destination name="iPhone 8" \ 149 HOST_PORT_LOCAL=localhost:5050 \ 150 test \ 151 | egrep -v "$XCODEBUILD_FILTER" \ 152 | egrep -v '^$' \ 153 | egrep -v "(GPBDictionary|GPBArray)" - 154 155echo "TIME: $(date)" 156xcodebuild \ 157 -workspace Tests.xcworkspace \ 158 -scheme InteropTestsLocalSSLCFStream \ 159 -destination name="iPhone 8" \ 160 HOST_PORT_LOCALSSL=localhost:5051 \ 161 test \ 162 | egrep -v "$XCODEBUILD_FILTER" \ 163 | egrep -v '^$' \ 164 | egrep -v "(GPBDictionary|GPBArray)" - 165 166exit 0 167