/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. set -o errexit
  20. set -o nounset
  21. set -o verbose
  22. # Controlling environment variables:
  23. # GTM_DISABLE_ZOMBIES -
  24. # Set to a non-zero value to turn on zombie checks. You will probably
  25. # want to turn this off if you enable leaks.
  26. GTM_DISABLE_ZOMBIES=${GTM_DISABLE_ZOMBIES:=1}
  27. # GTM_ENABLE_LEAKS -
  28. # Set to a non-zero value to turn on the leaks check. You will probably want
  29. # to disable zombies, otherwise you will get a lot of false positives.
  30. # GTM_DISABLE_TERMINATION
  31. # Set to a non-zero value so that the app doesn't terminate when it's finished
  32. # running tests. This is useful when using it with external tools such
  33. # as Instruments.
  34. # GTM_LEAKS_SYMBOLS_TO_IGNORE
  35. # List of comma separated symbols that leaks should ignore. Mainly to control
  36. # leaks in frameworks you don't have control over.
  37. # Search this file for GTM_LEAKS_SYMBOLS_TO_IGNORE to see examples.
  38. # Please feel free to add other symbols as you find them but make sure to
  39. # reference Radars or other bug systems so we can track them.
  40. # GTM_REMOVE_GCOV_DATA
  41. # Before starting the test, remove any *.gcda files for the current run so
  42. # you won't get errors when the source file has changed and the data can't
  43. # be merged.
  44. #
  45. GTM_REMOVE_GCOV_DATA=${GTM_REMOVE_GCOV_DATA:=0}
  46. ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
  47. ScriptName=$(basename "$0")
  48. ThisScript="${ScriptDir}/${ScriptName}"
  49. GTMXcodeNote() {
  50. echo ${ThisScript}:${1}: note: GTM ${2}
  51. }
  52. if [ "$PLATFORM_NAME" == "iphonesimulator" ]; then
  53. # We kill the iPhone simulator because otherwise we run into issues where
  54. # the unittests fail becuase the simulator is currently running, and
  55. # at this time the iPhone SDK won't allow two simulators running at the same
  56. # time.
  57. set +e
  58. /usr/bin/killall "iPhone Simulator"
  59. set -e
  60. if [ $GTM_REMOVE_GCOV_DATA -ne 0 ]; then
  61. if [ "${OBJECT_FILE_DIR}-${CURRENT_VARIANT}" != "-" ]; then
  62. if [ -d "${OBJECT_FILE_DIR}-${CURRENT_VARIANT}" ]; then
  63. GTMXcodeNote ${LINENO} "Removing any .gcda files"
  64. (cd "${OBJECT_FILE_DIR}-${CURRENT_VARIANT}" && \
  65. find . -type f -name "*.gcda" -print0 | xargs -0 rm -f )
  66. fi
  67. fi
  68. fi
  69. export DYLD_ROOT_PATH="$SDKROOT"
  70. export DYLD_FRAMEWORK_PATH="$CONFIGURATION_BUILD_DIR"
  71. export IPHONE_SIMULATOR_ROOT="$SDKROOT"
  72. export CFFIXED_USER_HOME="$TEMP_FILES_DIR/iPhone Simulator User Dir"
  73. # See http://developer.apple.com/technotes/tn2004/tn2124.html for an
  74. # explanation of these environment variables.
  75. export MallocScribble=YES
  76. export MallocPreScribble=YES
  77. export MallocGuardEdges=YES
  78. export MallocStackLogging=YES
  79. export NSAutoreleaseFreedObjectCheckEnabled=YES
  80. # Turn on the mostly undocumented OBJC_DEBUG stuff.
  81. export OBJC_DEBUG_FRAGILE_SUPERCLASSES=YES
  82. export OBJC_DEBUG_UNLOAD=YES
  83. # Turned off due to the amount of false positives from NS classes.
  84. # export OBJC_DEBUG_FINALIZERS=YES
  85. export OBJC_DEBUG_NIL_SYNC=YES
  86. export OBJC_PRINT_REPLACED_METHODS=YES
  87. if [ $GTM_DISABLE_ZOMBIES -eq 0 ]; then
  88. GTMXcodeNote ${LINENO} "Enabling zombies"
  89. export CFZombieLevel=3
  90. export NSZombieEnabled=YES
  91. fi
  92. # Cleanup user home directory
  93. if [ -d "$CFFIXED_USER_HOME" ]; then
  94. rm -rf "$CFFIXED_USER_HOME"
  95. fi
  96. mkdir "$CFFIXED_USER_HOME"
  97. mkdir "$CFFIXED_USER_HOME/Documents"
  98. mkdir -p "$CFFIXED_USER_HOME/Library/Caches"
  99. # 6251475 iPhone simulator leaks @ CFHTTPCookieStore shutdown if
  100. # CFFIXED_USER_HOME empty
  101. GTM_LEAKS_SYMBOLS_TO_IGNORE="CFHTTPCookieStore"
  102. "$TARGET_BUILD_DIR/$EXECUTABLE_PATH" -RegisterForSystemEvents
  103. else
  104. GTMXcodeNote ${LINENO} "Skipping running of unittests for device build."
  105. fi
  106. exit 0