diff options
author | 2009-05-12 22:00:26 +0000 | |
---|---|---|
committer | 2009-05-12 22:00:26 +0000 | |
commit | 44f91fa12da8b48d4ee46d017e17fe3b4729e53e (patch) | |
tree | b4fb26d9e29baa0efd254c1ed700f5683e4c89c8 | |
parent | 4f86270e6b63c5f050adf90b04a54dd4fbe8897b (diff) |
[Author: dmaclach]
Tightened up shell script error checking.
R=thomasvl
DELTA=27 (9 added, 10 deleted, 8 changed)
-rwxr-xr-x | UnitTesting/RunIPhoneUnitTest.sh | 29 | ||||
-rwxr-xr-x | UnitTesting/RunMacOSUnitTests.sh | 37 |
2 files changed, 37 insertions, 29 deletions
diff --git a/UnitTesting/RunIPhoneUnitTest.sh b/UnitTesting/RunIPhoneUnitTest.sh index 82fa4c2..60610cb 100755 --- a/UnitTesting/RunIPhoneUnitTest.sh +++ b/UnitTesting/RunIPhoneUnitTest.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # RunIPhoneUnitTest.sh # Copyright 2008 Google Inc. # @@ -16,33 +16,39 @@ # # Runs all unittests through the iPhone simulator. We don't handle running them # on the device. To run on the device just choose "run". -# Controlling environment variables: -# + +set -o errexit +set -o nounset +set -o verbose + +# Controlling environment variables: # GTM_DISABLE_ZOMBIES - # Set to a non-zero value to turn on zombie checks. You will probably # want to turn this off if you enable leaks. -# +GTM_DISABLE_ZOMBIES=${GTM_DISABLE_ZOMBIES:=1} + # GTM_ENABLE_LEAKS - # Set to a non-zero value to turn on the leaks check. You will probably want # to disable zombies, otherwise you will get a lot of false positives. -# + # GTM_DISABLE_TERMINATION # Set to a non-zero value so that the app doesn't terminate when it's finished # running tests. This is useful when using it with external tools such # as Instruments. -# + # GTM_LEAKS_SYMBOLS_TO_IGNORE # List of comma separated symbols that leaks should ignore. Mainly to control # leaks in frameworks you don't have control over. # Search this file for GTM_LEAKS_SYMBOLS_TO_IGNORE to see examples. # Please feel free to add other symbols as you find them but make sure to # reference Radars or other bug systems so we can track them. -# + # GTM_REMOVE_GCOV_DATA # Before starting the test, remove any *.gcda files for the current run so # you won't get errors when the source file has changed and the data can't # be merged. # +GTM_REMOVE_GCOV_DATA=${GTM_REMOVE_GCOV_DATA:=0} ScriptDir=$(dirname $(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")) ScriptName=$(basename "$0") @@ -57,9 +63,11 @@ if [ "$PLATFORM_NAME" == "iphonesimulator" ]; then # the unittests fail becuase the simulator is currently running, and # at this time the iPhone SDK won't allow two simulators running at the same # time. + set +e /usr/bin/killall "iPhone Simulator" - - if [ $GTM_REMOVE_GCOV_DATA ]; then + set -e + + if [ $GTM_REMOVE_GCOV_DATA -ne 0 ]; then if [ "${OBJECT_FILE_DIR}-${CURRENT_VARIANT}" != "-" ]; then if [ -d "${OBJECT_FILE_DIR}-${CURRENT_VARIANT}" ]; then GTMXcodeNote ${LINENO} "Removing any .gcda files" @@ -89,8 +97,9 @@ if [ "$PLATFORM_NAME" == "iphonesimulator" ]; then # Turned off due to the amount of false positives from NS classes. # export OBJC_DEBUG_FINALIZERS=YES export OBJC_DEBUG_NIL_SYNC=YES + export OBJC_PRINT_REPLACED_METHODS=YES - if [ ! $GTM_DISABLE_ZOMBIES ]; then + if [ $GTM_DISABLE_ZOMBIES -eq 0 ]; then GTMXcodeNote ${LINENO} "Enabling zombies" export CFZombieLevel=3 export NSZombieEnabled=YES diff --git a/UnitTesting/RunMacOSUnitTests.sh b/UnitTesting/RunMacOSUnitTests.sh index 4ffa5d0..6a19131 100755 --- a/UnitTesting/RunMacOSUnitTests.sh +++ b/UnitTesting/RunMacOSUnitTests.sh @@ -1,3 +1,4 @@ +#!/bin/bash # # RunMacOSUnitTests.sh # Copyright 2008 Google Inc. @@ -19,30 +20,30 @@ # See http://developer.apple.com/technotes/tn2004/tn2124.html for details. # +set -o errexit +set -o nounset +set -o verbose + # Controlling environment variables: # # GTM_DISABLE_ZOMBIES - # Set to a non-zero value to turn on zombie checks. You will probably # want to turn this off if you enable leaks. -# +GTM_DISABLE_ZOMBIES=${GTM_DISABLE_ZOMBIES:=0} + # GTM_ENABLE_LEAKS - # Set to a non-zero value to turn on the leaks check. You will probably want # to disable zombies, otherwise you will get a lot of false positives. -# -# GTM_NO_DEBUG_FRAMEWORKS - -# Set to zero to prevent the use of the debug versions of system -# libraries/frameworks if you have them installed on your system. The -# frameworks can be found at -# http://connect.apple.com > Downloads > Developer Tools -# (https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=19915) -# +GTM_ENABLE_LEAKS=${GTM_ENABLE_LEAKS:=0} + # GTM_LEAKS_SYMBOLS_TO_IGNORE # List of comma separated symbols that leaks should ignore. Mainly to control # leaks in frameworks you don't have control over. # Search this file for GTM_LEAKS_SYMBOLS_TO_IGNORE to see examples. # Please feel free to add other symbols as you find them but make sure to # reference Radars or other bug systems so we can track them. -# +GTM_LEAKS_SYMBOLS_TO_IGNORE=${GTM_LEAKS_SYMBOLS_TO_IGNORE:=""} + # GTM_DO_NOT_REMOVE_GCOV_DATA # By default before starting the test, we remove any *.gcda files for the # current project build configuration so you won't get errors when a source @@ -53,11 +54,7 @@ # that you are testing. # If you DO NOT want this to occur, set GTM_DO_NOT_REMOVE_GCOV_DATA to a # non-zero value. -# - -set -o errexit -set -o nounset -set -o verbose +GTM_DO_NOT_REMOVE_GCOV_DATA=${GTM_DO_NOT_REMOVE_GCOV_DATA:=0} ScriptDir=$(dirname $(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")) ScriptName=$(basename "$0") @@ -173,17 +170,18 @@ RunTests() { AppendToSymbolsLeaksShouldIgnore "-[IMServiceAgentImpl allServices]" # radar 6264034 +[IKSFEffectDescription initialize] Leaks AppendToSymbolsLeaksShouldIgnore "+[IKSFEffectDescription initialize]" - + # Running leaks on architectures that support leaks. export MallocStackLogging=YES export GTM_LEAKS_SYMBOLS_TO_IGNORE="${GTM_LEAKS_SYMBOLS_TO_IGNORE}" ARCHS="${LEAK_TEST_ARCHS}" VALID_ARCHS="${LEAK_TEST_ARCHS}" + GTMXcodeNote ${LINENO} "Leak checking enabled for $ARCHS. Ignoring leaks from $GTM_LEAKS_SYMBOLS_TO_IGNORE." "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests" # Running leaks on architectures that don't support leaks. unset MallocStackLogging - unset GTM_ENABLE_LEAKS + GTM_ENABLE_LEAKS=0 ARCHS="${NO_LEAK_TEST_ARCHS}" VALID_ARCHS="${NO_LEAK_TEST_ARCHS}" "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests" @@ -202,7 +200,7 @@ export OBJC_DEBUG_UNLOAD=YES # export OBJC_DEBUG_FINALIZERS=YES export OBJC_DEBUG_NIL_SYNC=YES -if [ ! $GTM_DISABLE_ZOMBIES ]; then +if [ $GTM_DISABLE_ZOMBIES -eq 0 ]; then GTMXcodeNote ${LINENO} "Enabling zombies" # CFZombieLevel disabled because it doesn't play well with the # security framework @@ -222,8 +220,9 @@ fi # If leaks testing is enabled, we have to go through our convoluted path # to handle architectures that don't allow us to do leak testing. -if [ $GTM_ENABLE_LEAKS ]; then +if [ $GTM_ENABLE_LEAKS -ne 0 ]; then RunTests else + GTMXcodeNote ${LINENO} "Leak checking disabled." "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests" fi |