aboutsummaryrefslogtreecommitdiff
path: root/UnitTesting/RunMacOSUnitTests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'UnitTesting/RunMacOSUnitTests.sh')
-rwxr-xr-xUnitTesting/RunMacOSUnitTests.sh101
1 files changed, 56 insertions, 45 deletions
diff --git a/UnitTesting/RunMacOSUnitTests.sh b/UnitTesting/RunMacOSUnitTests.sh
index 285dfb2..c5cafe4 100755
--- a/UnitTesting/RunMacOSUnitTests.sh
+++ b/UnitTesting/RunMacOSUnitTests.sh
@@ -2,13 +2,13 @@
#
# RunMacOSUnitTests.sh
# Copyright 2008 Google Inc.
-#
+#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -21,11 +21,13 @@
#
set -o errexit
-set -o nounset
+set -o nounset
+# Uncomment the next line to trace execution.
+#set -o verbose
# Controlling environment variables:
#
-# GTM_DISABLE_ZOMBIES -
+# 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}
@@ -36,19 +38,19 @@ GTM_DISABLE_ZOMBIES=${GTM_DISABLE_ZOMBIES:=0}
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
+# 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
-# file has changed and the gcov data can't be merged.
-# We remove all the gcda files for the current configuration for the entire
-# project so that if you are building a test bundle to test another separate
+# 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
+# file has changed and the gcov data can't be merged.
+# We remove all the gcda files for the current configuration for the entire
+# project so that if you are building a test bundle to test another separate
# bundle we make sure to clean up the files for the test bundle and the bundle
# that you are testing.
# If you DO NOT want this to occur, set GTM_DO_NOT_REMOVE_GCOV_DATA to a
@@ -92,7 +94,7 @@ sys.exit(subprocess.call(sys.argv[1:]))" "${@}"
# The workaround below is due to
# Radar 6248062 otest won't run with MallocHistory enabled under rosetta
# Basically we go through and check what architecture we are running on
-# and which architectures we can support
+# and which architectures we can support
AppendToSymbolsLeaksShouldIgnore() {
if [ "${GTM_LEAKS_SYMBOLS_TO_IGNORE}" = "" ]; then
GTM_LEAKS_SYMBOLS_TO_IGNORE="${1}"
@@ -124,13 +126,13 @@ UpdateArchitecturesToTest() {
AppendToLeakTestArchs "${1}"
fi
;;
-
+
ppc64)
if [ "${1}" = "ppc" -o "${1}" = "ppc64" ]; then
AppendToLeakTestArchs "${1}"
fi
;;
-
+
i386)
if [ "${1}" = "i386" ]; then
AppendToLeakTestArchs "${1}"
@@ -138,7 +140,7 @@ UpdateArchitecturesToTest() {
AppendToNoLeakTestArchs "${1}"
fi
;;
-
+
x86_64)
if [ "${1}" = "i386" -o "${1}" = "x86_64" ]; then
AppendToLeakTestArchs "${1}"
@@ -146,7 +148,7 @@ UpdateArchitecturesToTest() {
AppendToNoLeakTestArchs "${1}"
fi
;;
-
+
*)
echo "RunMacOSUnitTests.sh Unknown native architecture: ${NATIVE_ARCH_ACTUAL}"
exit 1
@@ -154,11 +156,39 @@ UpdateArchitecturesToTest() {
esac
}
+SetMemoryVariables() {
+ # Jack up some memory stress so we can catch more bugs.
+
+ # This is done via a helper so it can be invoked in two places at the
+ # last possible moment to avoid the variables causing tracing from other
+ # processes that are invoked along the way.
+
+ if [ $GTM_DISABLE_ZOMBIES -eq 0 ]; then
+ GTMXcodeNote ${LINENO} "Enabling zombies"
+ # CFZombieLevel disabled because it doesn't play well with the
+ # security framework
+ # export CFZombieLevel=3
+ export NSZombieEnabled=YES
+ fi
+
+ export MallocScribble=YES
+ export MallocPreScribble=YES
+ export MallocGuardEdges=YES
+ export NSAutoreleaseFreedObjectCheckEnabled=YES
+
+ # Turn on the mostly undocumented OBJC_DEBUG stuff.
+ export OBJC_DEBUG_FRAGILE_SUPERCLASSES=YES
+ export OBJC_DEBUG_UNLOAD=YES
+ # Turned off due to the amount of false positives from NS classes.
+ # export OBJC_DEBUG_FINALIZERS=YES
+ export OBJC_DEBUG_NIL_SYNC=YES
+}
+
RunTests() {
if [ "${CURRENT_ARCH}" = "" ]; then
CURRENT_ARCH=`arch`
fi
-
+
if [ "${ONLY_ACTIVE_ARCH}" = "YES" ]; then
ARCHS="${CURRENT_ARCH}"
fi
@@ -177,7 +207,7 @@ RunTests() {
LEAK_TEST_ARCHS=""
NO_LEAK_TEST_ARCHS=""
-
+
for TEST_ARCH in ${ARCHS}; do
for TEST_VALID_ARCH in ${VALID_ARCHS}; do
if [ "${TEST_VALID_ARCH}" = "${TEST_ARCH}" ]; then
@@ -185,7 +215,7 @@ RunTests() {
fi
done
done
-
+
# These are symbols that leak on OS 10.5.5
# radar 6247293 NSCollatorElement leaks in +initialize.
AppendToSymbolsLeaksShouldIgnore "+[NSCollatorElement initialize]"
@@ -204,8 +234,9 @@ RunTests() {
ARCHS="${LEAK_TEST_ARCHS}"
VALID_ARCHS="${LEAK_TEST_ARCHS}"
GTMXcodeNote ${LINENO} "Leak checking enabled for $ARCHS. Ignoring leaks from $GTM_LEAKS_SYMBOLS_TO_IGNORE."
+ SetMemoryVariables
MaybeFlock "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
-
+
# Running leaks on architectures that don't support leaks.
unset MallocStackLogging
unset GTM_ENABLE_LEAKS
@@ -215,27 +246,6 @@ RunTests() {
MaybeFlock "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
}
-# Jack up some memory stress so we can catch more bugs.
-export MallocScribble=YES
-export MallocPreScribble=YES
-export MallocGuardEdges=YES
-export NSAutoreleaseFreedObjectCheckEnabled=YES
-
-# Turn on the mostly undocumented OBJC_DEBUG stuff.
-export OBJC_DEBUG_FRAGILE_SUPERCLASSES=YES
-export OBJC_DEBUG_UNLOAD=YES
-# Turned off due to the amount of false positives from NS classes.
-# export OBJC_DEBUG_FINALIZERS=YES
-export OBJC_DEBUG_NIL_SYNC=YES
-
-if [ $GTM_DISABLE_ZOMBIES -eq 0 ]; then
- GTMXcodeNote ${LINENO} "Enabling zombies"
- # CFZombieLevel disabled because it doesn't play well with the
- # security framework
- # export CFZombieLevel=3
- export NSZombieEnabled=YES
-fi
-
if [ ! $GTM_DO_NOT_REMOVE_GCOV_DATA ]; then
GTM_GCOV_CLEANUP_DIR="${CONFIGURATION_TEMP_DIR}"
if [ $GTM_REMOVE_TARGET_GCOV_ONLY ]; then
@@ -253,8 +263,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 -ne 0 ]; then
- RunTests
+ RunTests
else
GTMXcodeNote ${LINENO} "Leak checking disabled."
+ SetMemoryVariables
MaybeFlock "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
fi