...
Run Format

Text file src/iostest.bash

Documentation: Index

     1	#!/usr/bin/env bash
     2	# Copyright 2015 The Go Authors. All rights reserved.
     3	# Use of this source code is governed by a BSD-style
     4	# license that can be found in the LICENSE file.
     5	
     6	# For testing darwin/arm{,64} on iOS.
     7	
     8	set -e
     9	ulimit -c 0 # no core files
    10	
    11	if [ ! -f make.bash ]; then
    12		echo 'iostest.bash must be run from $GOROOT/src' 1>&2
    13		exit 1
    14	fi
    15	
    16	if [ -z $GOOS ]; then
    17		export GOOS=darwin
    18	fi
    19	if [ "$GOOS" != "darwin" ]; then
    20		echo "iostest.bash requires GOOS=darwin, got GOOS=$GOOS" 1>&2
    21		exit 1
    22	fi
    23	if [ "$GOARCH" != "arm" ] && [ "$GOARCH" != "arm64" ]; then
    24		echo "iostest.bash requires GOARCH=arm or GOARCH=arm64, got GOARCH=$GOARCH" 1>&2
    25		exit 1
    26	fi
    27	if [ "$GOARCH" = "arm" ]; then
    28		export GOARM=7
    29	fi
    30	
    31	if [ "$1" = "-restart" ]; then
    32		# Reboot to make sure previous runs do not interfere with the current run.
    33		# It is reasonably easy for a bad program leave an iOS device in an
    34		# almost unusable state.
    35		idevicediagnostics restart
    36		# Initial sleep to make sure we are restarting before we start polling.
    37		sleep 30
    38		# Poll until the device has restarted.
    39		until idevicediagnostics diagnostics; do
    40			# TODO(crawshaw): replace with a test app using go_darwin_arm_exec.
    41			echo "waiting for idevice to come online"
    42			sleep 10
    43		done
    44		# Diagnostics are reported during boot before the device can start an
    45		# app. Wait a little longer before trying to use the device.
    46		sleep 30
    47	fi
    48	
    49	unset GOBIN
    50	export GOROOT=$(dirname $(pwd))
    51	export PATH=$GOROOT/bin:$PATH
    52	export CGO_ENABLED=1
    53	export CC_FOR_TARGET=$GOROOT/misc/ios/clangwrap.sh
    54	
    55	# Run the build for the host bootstrap, so we can build go_darwin_arm_exec.
    56	# Also lets us fail early before the (slow) ios-deploy if the build is broken.
    57	./make.bash
    58	
    59	GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build \
    60		-o ../bin/go_darwin_${GOARCH}_exec \
    61		../misc/ios/go_darwin_arm_exec.go
    62	
    63	if [ "$GOIOS_DEV_ID" = "" ]; then
    64		echo "detecting iOS development identity"
    65		eval $(GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go run ../misc/ios/detect.go)
    66	fi
    67	
    68	# Run standard build and tests.
    69	./all.bash --no-clean

View as plain text