|
| 1 | +#!/bin/sh |
| 2 | +## |
| 3 | +# Copyright 2008 Apple Inc. |
| 4 | +# All rights reserved. |
| 5 | +# |
| 6 | +# iPhoneSimulator platform |
| 7 | +# This script runs all of the unit tests for the target test bundle specified by the passed-in environment. |
| 8 | +# This script is generally intended to be invoked by ${DEVELOPER_TOOLS_DIR}/RunUnitTests. The interface or location of this script may change in future releases. |
| 9 | +## |
| 10 | +# |
| 11 | +# Input: |
| 12 | +# See ${DEVELOPER_TOOLS_DIR}/RunUnitTests for input variables |
| 13 | + |
| 14 | +Message() { |
| 15 | +# usage: Message line type message |
| 16 | +# Echo the message to stdout as the given type of message and continue |
| 17 | +echo"${PLATFORM_DEVELOPER_TOOLS_DIR}/Tools/RunPlatformUnitTests:${1}:${2}:${3}" |
| 18 | +} |
| 19 | + |
| 20 | +Note() { |
| 21 | +# usage: Notify line message |
| 22 | +# Echo the message to stdout as a note and continue |
| 23 | + Message"${1}" note"${2}" |
| 24 | +} |
| 25 | + |
| 26 | +Warning() { |
| 27 | +# usage: Warning line message |
| 28 | +# Echo the message to stdout as a note and continue |
| 29 | + Message"${1}" warning"${2}" |
| 30 | +} |
| 31 | + |
| 32 | +Error() { |
| 33 | +# usage: Notify line message |
| 34 | +# Echo the message to stdout as an error and continue |
| 35 | + Message"${1}" error"${2}" |
| 36 | +} |
| 37 | + |
| 38 | +Fail() { |
| 39 | +# usage: Fail line message |
| 40 | +# Echo the message to stdout and return 1, the universal error code |
| 41 | + Error"${1}""${2}" |
| 42 | +exit 1 |
| 43 | +} |
| 44 | + |
| 45 | +### Do not run tests on anything but a "build". |
| 46 | + |
| 47 | +if ["${ACTION}"!="build" ];then |
| 48 | +exit 0 |
| 49 | +fi |
| 50 | + |
| 51 | +### Silently skip tests if TEST_AFTER_BUILD is NO |
| 52 | + |
| 53 | +if ["${TEST_AFTER_BUILD}"="NO" ];then |
| 54 | +exit 0 |
| 55 | +fi |
| 56 | + |
| 57 | +### Source RunUnitTests.include functionality |
| 58 | + |
| 59 | +if ["${DEVELOPER_TOOLS_DIR}"="" ];then |
| 60 | + Fail${LINENO}"DEVELOPER_TOOLS_DIR is not set." |
| 61 | +fi |
| 62 | + |
| 63 | +if ["${PLATFORM_DEVELOPER_TOOLS_DIR}"="" ];then |
| 64 | + Fail${LINENO}"PLATFORM_DEVELOPER_TOOLS_DIR is not set." |
| 65 | +fi |
| 66 | + |
| 67 | +includeFile="${DEVELOPER_TOOLS_DIR}/RunPlatformUnitTests.include" |
| 68 | +if [!-r"${includeFile}" ];then |
| 69 | + Fail${LINENO}"Cannot read include file${includeFile}" |
| 70 | +fi |
| 71 | + |
| 72 | +source"${includeFile}" |
| 73 | + |
| 74 | +if [ 0!=$? ];then |
| 75 | + Fail${LINENO}"Could not source include file${includeFile}" |
| 76 | +fi |
| 77 | + |
| 78 | +### Define a sensible default for the path to the otest |
| 79 | + |
| 80 | +if ["${OTEST}"="" ];then |
| 81 | + OTEST="${SDKROOT}/Developer/usr/bin/otest" |
| 82 | +fi |
| 83 | + |
| 84 | +Main() { |
| 85 | +# usage: Main |
| 86 | +# Determine how tests need to be run and run them. |
| 87 | + |
| 88 | +# GC not supported by the simulator |
| 89 | + TEST_GC_STATES="OFF" |
| 90 | + |
| 91 | + Configure_TEST_ARCHS |
| 92 | + |
| 93 | +if ["${TEST_HOST}"!="" ];then |
| 94 | + |
| 95 | +# SG changed based on this post: |
| 96 | +# http://longweekendmobile.com/2011/04/17/xcode4-running-application-tests-from-the-command-line-in-ios/ |
| 97 | +#Warning ${LINENO} "Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set)." |
| 98 | +export OTHER_TEST_FLAGS="-RegisterForSystemEvents" |
| 99 | + RunTestsForApplication"${TEST_HOST}""${TEST_BUNDLE_PATH}" |
| 100 | +else |
| 101 | +# If no TEST_HOST is specified, assume we're running the test bundle. |
| 102 | + |
| 103 | + RunTestsForBundle"${TEST_BUNDLE_PATH}" |
| 104 | +fi |
| 105 | +} |
| 106 | + |
| 107 | +### Update the dyld environment to support running tests out of the build directory. |
| 108 | + |
| 109 | +# Sets and exports the following environment variables: |
| 110 | +# DYLD_ROOT_PATH |
| 111 | +# DYLD_FRAMEWORK_PATH |
| 112 | +# DYLD_LIBRARY_PATH |
| 113 | +# DYLD_NEW_LOCAL_SHARED_REGIONS |
| 114 | +# DYLD_NO_FIX_PREBINDING |
| 115 | + |
| 116 | +if ["${DYLD_FRAMEWORK_PATH}"!="" ];then |
| 117 | + DYLD_FRAMEWORK_PATH="${BUILT_PRODUCTS_DIR}:${SDKROOT}${DEVELOPER_LIBRARY_DIR}/Frameworks:${DYLD_FRAMEWORK_PATH}" |
| 118 | +else |
| 119 | + DYLD_FRAMEWORK_PATH="${BUILT_PRODUCTS_DIR}:${SDKROOT}${DEVELOPER_LIBRARY_DIR}/Frameworks" |
| 120 | +fi |
| 121 | + |
| 122 | +if ["${DYLD_LIBRARY_PATH}"!="" ];then |
| 123 | + DYLD_LIBRARY_PATH="${BUILT_PRODUCTS_DIR}:${DYLD_LIBRARY_PATH}" |
| 124 | +else |
| 125 | + DYLD_LIBRARY_PATH="${BUILT_PRODUCTS_DIR}" |
| 126 | +fi |
| 127 | + |
| 128 | +if ["${DYLD_ROOT_PATH}"!="" ];then |
| 129 | + DYLD_ROOT_PATH="${SDKROOT}:${DYLD_ROOT_PATH}" |
| 130 | +else |
| 131 | + DYLD_ROOT_PATH="${SDKROOT}" |
| 132 | +fi |
| 133 | + |
| 134 | +DYLD_NEW_LOCAL_SHARED_REGIONS=YES |
| 135 | +DYLD_NO_FIX_PREBINDING=YES |
| 136 | +IPHONE_SIMULATOR_ROOT=$SDKROOT## rdar://6528939 |
| 137 | +CFFIXED_USER_HOME="${HOME}/Library/Application Support/iPhone Simulator/$IPHONESIMULATOR_PLATFORM_VERSION" |
| 138 | + |
| 139 | +EXPORT_VARS=(DYLD_FRAMEWORK_PATH DYLD_LIBRARY_PATH DYLD_NEW_LOCAL_SHARED_REGIONS DYLD_NO_FIX_PREBINDING DYLD_ROOT_PATH IPHONE_SIMULATOR_ROOT CFFIXED_USER_HOME ) |
| 140 | + |
| 141 | +### Run the tests |
| 142 | + |
| 143 | +Main |