| 1 |
#!/bin/bash |
| 2 |
# Copyright 2019 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 -ex |
| 20 |
|
| 21 |
cd $(dirname $0) |
| 22 |
|
| 23 |
BAZEL=../../../tools/bazel |
| 24 |
|
| 25 |
INTEROP=../../../bazel-out/darwin-fastbuild/bin/test/cpp/interop/interop_server |
| 26 |
|
| 27 |
[ -d Tests.xcworkspace ] || { |
| 28 |
./build_tests.sh |
| 29 |
} |
| 30 |
|
| 31 |
[ -f $INTEROP ] || { |
| 32 |
$BAZEL build //test/cpp/interop:interop_server |
| 33 |
} |
| 34 |
|
| 35 |
[ -z "$(ps aux |egrep 'port_server\.py.*-p\s32766')" ] && { |
| 36 |
echo >&2 "Can't find the port server. Start port server with tools/run_tests/start_port_server.py." |
| 37 |
exit 1 |
| 38 |
} |
| 39 |
|
| 40 |
PLAIN_PORT=$(curl localhost:32766/get) |
| 41 |
TLS_PORT=$(curl localhost:32766/get) |
| 42 |
|
| 43 |
# start interop_server for plaintext and interop_server for TLS on random ports obtained |
| 44 |
# from the port server. |
| 45 |
$INTEROP --port=$PLAIN_PORT --max_send_message_size=8388608 & |
| 46 |
$INTEROP --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & |
| 47 |
|
| 48 |
function finish { |
| 49 |
kill -9 `jobs -p` |
| 50 |
echo "EXIT TIME: $(date)" |
| 51 |
} |
| 52 |
trap finish EXIT |
| 53 |
|
| 54 |
set -o pipefail # preserve xcodebuild exit code when piping output |
| 55 |
|
| 56 |
if [ -z $PLATFORM ]; then |
| 57 |
DESTINATION='platform=iOS Simulator,name=iPhone 11' |
| 58 |
elif [ $PLATFORM == ios ]; then |
| 59 |
DESTINATION='platform=iOS Simulator,name=iPhone 11' |
| 60 |
elif [ $PLATFORM == macos ]; then |
| 61 |
DESTINATION='platform=macOS' |
| 62 |
elif [ $PLATFORM == tvos ]; then |
| 63 |
DESTINATION='platform=tvOS Simulator,name=Apple TV' |
| 64 |
fi |
| 65 |
|
| 66 |
XCODEBUILD_FLAGS=" |
| 67 |
IPHONEOS_DEPLOYMENT_TARGET=10 |
| 68 |
" |
| 69 |
|
| 70 |
XCODEBUILD_FILTER_OUTPUT_SCRIPT="./xcodebuild_filter_output.sh" |
| 71 |
|
| 72 |
TEST_DEFS="HOST_PORT_LOCAL=localhost:$PLAIN_PORT \ |
| 73 |
HOST_PORT_LOCALSSL=localhost:$TLS_PORT \ |
| 74 |
HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ |
| 75 |
GCC_OPTIMIZATION_LEVEL=s" |
| 76 |
|
| 77 |
time xcodebuild \ |
| 78 |
-workspace Tests.xcworkspace \ |
| 79 |
-scheme $SCHEME \ |
| 80 |
-destination "${DESTINATION}" \ |
| 81 |
GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS'" $TEST_DEFS" \ |
| 82 |
test \ |
| 83 |
"${XCODEBUILD_FLAGS}" \ |
| 84 |
| "${XCODEBUILD_FILTER_OUTPUT_SCRIPT}" |