8c768cb85beff7d5d470126d0181f85f0e0cce7b
[platform/upstream/grpc.git] / src / objective-c / tests / run_tests.sh
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
19 set -ev
20
21 cd $(dirname $0)
22
23 # Run the tests server.
24
25 BINDIR=../../../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.
35 trap 'kill -9 `jobs -p` ; echo "EXIT TIME:  $(date)"' EXIT
36
37 set -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.
42 XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )'
43
44 echo "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
50 retries=0
51 while [ $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
76 done
77 if [ $retries == 3 ]; then
78   echo "Failed with code 65 for 3 times; abort."
79   exit 1
80 fi
81
82 echo "TIME:  $(date)"
83 xcodebuild \
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
92 echo "TIME:  $(date)"
93 xcodebuild \
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
102 echo "TIME:  $(date)"
103 xcodebuild \
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
112 echo "TIME:  $(date)"
113 xcodebuild \
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
122 echo "TIME:  $(date)"
123 xcodebuild \
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
133 echo "TIME:  $(date)"
134 xcodebuild \
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
144 echo "TIME:  $(date)"
145 xcodebuild \
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
155 echo "TIME:  $(date)"
156 xcodebuild \
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
166 echo "TIME:  $(date)"
167 xcodebuild \
168     -workspace Tests.xcworkspace \
169     -scheme UnitTests \
170     -destination name="iPhone 8" \
171     test \
172     | egrep -v "$XCODEBUILD_FILTER" \
173     | egrep -v '^$' \
174     | egrep -v "(GPBDictionary|GPBArray)" -
175
176 echo "TIME:  $(date)"
177 xcodebuild \
178     -workspace Tests.xcworkspace \
179     -scheme ChannelTests \
180     -destination name="iPhone 8" \
181     test \
182     | egrep -v "$XCODEBUILD_FILTER" \
183     | egrep -v '^$' \
184     | egrep -v "(GPBDictionary|GPBArray)" -
185
186 echo "TIME:  $(date)"
187 xcodebuild \
188     -workspace Tests.xcworkspace \
189     -scheme APIv2Tests \
190     -destination name="iPhone 8" \
191     HOST_PORT_LOCAL=localhost:5050 \
192     HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \
193     test \
194     | egrep -v "$XCODEBUILD_FILTER" \
195     | egrep -v '^$' \
196     | egrep -v "(GPBDictionary|GPBArray)" -
197
198 echo "TIME:  $(date)"
199 xcodebuild \
200     -workspace Tests.xcworkspace \
201     -scheme MacTests \
202     -destination platform=macOS \
203     HOST_PORT_LOCALSSL=localhost:5051 \
204     HOST_PORT_LOCAL=localhost:5050 \
205     HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \
206     test \
207     | egrep -v "$XCODEBUILD_FILTER" \
208     | egrep -v '^$' \
209     | egrep -v "(GPBDictionary|GPBArray)" -
210
211 exit 0