PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/MapView/GTM/RunIPhoneUnitTest.sh

http://github.com/route-me/route-me
Shell | 124 lines | 54 code | 18 blank | 52 comment | 10 complexity | 8f4ddaf63539a519d8e7ea2dade689f9 MD5 | raw file
  1#!/bin/bash
  2#  RunIPhoneUnitTest.sh
  3#  Copyright 2008 Google Inc.
  4#  
  5#  Licensed under the Apache License, Version 2.0 (the "License"); you may not
  6#  use this file except in compliance with the License.  You may obtain a copy
  7#  of the License at
  8# 
  9#  http://www.apache.org/licenses/LICENSE-2.0
 10# 
 11#  Unless required by applicable law or agreed to in writing, software
 12#  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 13#  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 14#  License for the specific language governing permissions and limitations under
 15#  the License.
 16#
 17#  Runs all unittests through the iPhone simulator. We don't handle running them
 18#  on the device. To run on the device just choose "run".
 19
 20set -o errexit
 21set -o nounset 
 22set -o verbose
 23
 24#  Controlling environment variables:
 25# GTM_DISABLE_ZOMBIES - 
 26#   Set to a non-zero value to turn on zombie checks. You will probably
 27#   want to turn this off if you enable leaks.
 28GTM_DISABLE_ZOMBIES=${GTM_DISABLE_ZOMBIES:=1}
 29
 30# GTM_ENABLE_LEAKS -
 31#   Set to a non-zero value to turn on the leaks check. You will probably want
 32#   to disable zombies, otherwise you will get a lot of false positives.
 33
 34# GTM_DISABLE_TERMINATION
 35#   Set to a non-zero value so that the app doesn't terminate when it's finished
 36#   running tests. This is useful when using it with external tools such
 37#   as Instruments.
 38
 39# GTM_LEAKS_SYMBOLS_TO_IGNORE
 40#   List of comma separated symbols that leaks should ignore. Mainly to control 
 41#   leaks in frameworks you don't have control over. 
 42#   Search this file for GTM_LEAKS_SYMBOLS_TO_IGNORE to see examples. 
 43#   Please feel free to add other symbols as you find them but make sure to 
 44#   reference Radars or other bug systems so we can track them.
 45
 46# GTM_REMOVE_GCOV_DATA
 47#   Before starting the test, remove any *.gcda files for the current run so
 48#   you won't get errors when the source file has changed and the data can't
 49#   be merged.
 50#
 51GTM_REMOVE_GCOV_DATA=${GTM_REMOVE_GCOV_DATA:=0}
 52
 53ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
 54ScriptName=$(basename "$0")
 55ThisScript="${ScriptDir}/${ScriptName}"
 56
 57GTMXcodeNote() {
 58    echo ${ThisScript}:${1}: note: GTM ${2}
 59}
 60
 61if [ "$PLATFORM_NAME" == "iphonesimulator" ]; then
 62  # We kill the iPhone simulator because otherwise we run into issues where
 63  # the unittests fail becuase the simulator is currently running, and 
 64  # at this time the iPhone SDK won't allow two simulators running at the same
 65  # time.
 66  set +e
 67  /usr/bin/killall "iPhone Simulator"
 68  set -e
 69  
 70  if [ $GTM_REMOVE_GCOV_DATA -ne 0 ]; then
 71    if [ "${OBJECT_FILE_DIR}-${CURRENT_VARIANT}" != "-" ]; then
 72      if [ -d "${OBJECT_FILE_DIR}-${CURRENT_VARIANT}" ]; then
 73        GTMXcodeNote ${LINENO} "Removing any .gcda files"
 74        (cd "${OBJECT_FILE_DIR}-${CURRENT_VARIANT}" && \
 75            find . -type f -name "*.gcda" -print0 | xargs -0 rm -f )
 76      fi
 77    fi
 78  fi
 79
 80  export DYLD_ROOT_PATH="$SDKROOT"
 81  export DYLD_FRAMEWORK_PATH="$CONFIGURATION_BUILD_DIR"
 82  export IPHONE_SIMULATOR_ROOT="$SDKROOT"
 83  export CFFIXED_USER_HOME="$TEMP_FILES_DIR/iPhone Simulator User Dir"
 84  
 85  # See http://developer.apple.com/technotes/tn2004/tn2124.html for an 
 86  # explanation of these environment variables.
 87  
 88  export MallocScribble=YES
 89  export MallocPreScribble=YES
 90  export MallocGuardEdges=YES
 91  export MallocStackLogging=YES
 92  export NSAutoreleaseFreedObjectCheckEnabled=YES
 93
 94  # Turn on the mostly undocumented OBJC_DEBUG stuff.
 95  export OBJC_DEBUG_FRAGILE_SUPERCLASSES=YES
 96  export OBJC_DEBUG_UNLOAD=YES
 97  # Turned off due to the amount of false positives from NS classes.
 98  # export OBJC_DEBUG_FINALIZERS=YES  
 99  export OBJC_DEBUG_NIL_SYNC=YES
100  export OBJC_PRINT_REPLACED_METHODS=YES
101
102  if [ $GTM_DISABLE_ZOMBIES -eq 0 ]; then
103    GTMXcodeNote ${LINENO} "Enabling zombies"
104    export CFZombieLevel=3
105    export NSZombieEnabled=YES
106  fi
107
108  # Cleanup user home directory
109  if [ -d "$CFFIXED_USER_HOME" ]; then
110    rm -rf "$CFFIXED_USER_HOME"
111  fi
112  mkdir "$CFFIXED_USER_HOME"
113  mkdir "$CFFIXED_USER_HOME/Documents"
114  mkdir -p "$CFFIXED_USER_HOME/Library/Caches"
115
116  # 6251475 iPhone simulator leaks @ CFHTTPCookieStore shutdown if 
117  #         CFFIXED_USER_HOME empty
118  GTM_LEAKS_SYMBOLS_TO_IGNORE="CFHTTPCookieStore"
119  
120  "$TARGET_BUILD_DIR/$EXECUTABLE_PATH" -RegisterForSystemEvents
121else
122  GTMXcodeNote ${LINENO} "Skipping running of unittests for device build."
123fi
124exit 0