Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 146 lines (113 sloc) 4.09 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
#!/bin/sh
##
# Copyright 2008 Apple Inc.
# All rights reserved.
#
# iPhoneSimulator platform
# This script runs all of the unit tests for the target test bundle specified by the passed-in environment.
# 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.
##
#
# Input:
# See ${DEVELOPER_TOOLS_DIR}/RunUnitTests for input variables

Message() {
# usage: Message line type message
# Echo the message to stdout as the given type of message and continue
    echo "${PLATFORM_DEVELOPER_TOOLS_DIR}/Tools/RunPlatformUnitTests:${1}: ${2}: ${3}"
}

Note() {
# usage: Notify line message
# Echo the message to stdout as a note and continue
    Message "${1}" note "${2}"
}

Warning() {
# usage: Warning line message
# Echo the message to stdout as a note and continue
    Message "${1}" warning "${2}"
}

Error() {
# usage: Notify line message
# Echo the message to stdout as an error and continue
    Message "${1}" error "${2}"
}

Fail() {
# usage: Fail line message
# Echo the message to stdout and return 1, the universal error code
    Error "${1}" "${2}"
    exit 1
}

### Do not run tests on anything but a "build".

if [ "${ACTION}" != "build" ]; then
    exit 0
fi

### Silently skip tests if TEST_AFTER_BUILD is NO

if [ "${TEST_AFTER_BUILD}" = "NO" ]; then
    exit 0
fi

### Source RunUnitTests.include functionality

if [ "${DEVELOPER_TOOLS_DIR}" = "" ]; then
    Fail ${LINENO} "DEVELOPER_TOOLS_DIR is not set."
fi

if [ "${PLATFORM_DEVELOPER_TOOLS_DIR}" = "" ]; then
    Fail ${LINENO} "PLATFORM_DEVELOPER_TOOLS_DIR is not set."
fi

includeFile="${DEVELOPER_TOOLS_DIR}/RunPlatformUnitTests.include"
if [ ! -r "${includeFile}" ]; then
    Fail ${LINENO} "Cannot read include file ${includeFile}"
fi

source "${includeFile}"

if [ 0 != $? ]; then
    Fail ${LINENO} "Could not source include file ${includeFile}"
fi

### Define a sensible default for the path to the otest

if [ "${OTEST}" = "" ]; then
    OTEST="${SDKROOT}/Developer/usr/bin/otest"
fi

Main() {
# usage: Main
# Determine how tests need to be run and run them.
 
    # GC not supported by the simulator
    TEST_GC_STATES="OFF"
    
    Configure_TEST_ARCHS
    
    if [ "${TEST_HOST}" != "" ]; then

        export CFFIXED_USER_HOME="${BUILT_PRODUCTS_DIR}/UserHome/"
        mkdir -p "${CFFIXED_USER_HOME}"
        mkdir -p "${CFFIXED_USER_HOME}/Library/Caches"
        mkdir "${CFFIXED_USER_HOME}/Library/Preferences"
        mkdir "${CFFIXED_USER_HOME}/Documents"
        export OTHER_TEST_FLAGS="${OTHER_TEST_FLAGS} -RegisterForSystemEvents"
        RunTestsForApplication "${TEST_HOST}" "${TEST_BUNDLE_PATH}"
        
    else
        # If no TEST_HOST is specified, assume we're running the test bundle.
        
        RunTestsForBundle "${TEST_BUNDLE_PATH}"
    fi
}

### Update the dyld environment to support running tests out of the build directory.

# Sets and exports the following environment variables:
# DYLD_ROOT_PATH
# DYLD_FRAMEWORK_PATH
# DYLD_LIBRARY_PATH
# DYLD_NEW_LOCAL_SHARED_REGIONS
# DYLD_NO_FIX_PREBINDING

if [ "${DYLD_FRAMEWORK_PATH}" != "" ]; then
    DYLD_FRAMEWORK_PATH="${BUILT_PRODUCTS_DIR}:${SDKROOT}${DEVELOPER_LIBRARY_DIR}/Frameworks:${DYLD_FRAMEWORK_PATH}"
else
    DYLD_FRAMEWORK_PATH="${BUILT_PRODUCTS_DIR}:${SDKROOT}${DEVELOPER_LIBRARY_DIR}/Frameworks"
fi

if [ "${DYLD_LIBRARY_PATH}" != "" ]; then
    DYLD_LIBRARY_PATH="${BUILT_PRODUCTS_DIR}:${DYLD_LIBRARY_PATH}"
else
    DYLD_LIBRARY_PATH="${BUILT_PRODUCTS_DIR}"
fi

if [ "${DYLD_ROOT_PATH}" != "" ]; then
    DYLD_ROOT_PATH="${SDKROOT}:${DYLD_ROOT_PATH}"
else
    DYLD_ROOT_PATH="${SDKROOT}"
fi

DYLD_NEW_LOCAL_SHARED_REGIONS=YES
DYLD_NO_FIX_PREBINDING=YES
IPHONE_SIMULATOR_ROOT=$SDKROOT ## rdar://6528939
CFFIXED_USER_HOME="${HOME}/Library/Application Support/iPhone Simulator/$IPHONESIMULATOR_PLATFORM_VERSION"

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 )

### Run the tests

Main
Something went wrong with that request. Please try again.