diff options
author | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2012-04-05 17:32:34 +0000 |
---|---|---|
committer | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2012-04-05 17:32:34 +0000 |
commit | 960fe87b0b25a22655732f3bdd32fd14c5a27c07 (patch) | |
tree | 0f639e503f9744da95ac535a1e824ab611b2c72f /UnitTesting/RunIPhoneUnitTest.sh | |
parent | 66a61fbc1c930c8e5c2655ba03d31197e04fe400 (diff) |
[Author: jonwall]
Change RunIPhoneUnitTest.sh to launch securityd directly.
This fixes a bug where keychain library functions called from unit tests
would fail after a period of inactivity. We will now launch the security
daemon via launchctl load with a custom plist configuration, rather than
via RunIPhoneLaunchDaemons.sh.
R=dmaclach,thomasvl
APPROVED=thomasvl
DELTA=159 (112 added, 44 deleted, 3 changed)
Diffstat (limited to 'UnitTesting/RunIPhoneUnitTest.sh')
-rwxr-xr-x | UnitTesting/RunIPhoneUnitTest.sh | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/UnitTesting/RunIPhoneUnitTest.sh b/UnitTesting/RunIPhoneUnitTest.sh index 7721fcd..ce3f2dc 100755 --- a/UnitTesting/RunIPhoneUnitTest.sh +++ b/UnitTesting/RunIPhoneUnitTest.sh @@ -74,6 +74,26 @@ GTMXcodeNote() { echo ${ThisScript}:${1}: note: GTM ${2} } +# Creates a file containing the plist for the securityd daemon and prints the +# filename to stdout. +GTMCreateLaunchDaemonPlist() { + local plist_file + plist_file="$TMPDIR/securityd.$$.plist" + echo $plist_file + + # Create the plist file with PlistBuddy. + /usr/libexec/PlistBuddy \ + -c "Add :Label string RunIPhoneLaunchDaemons" \ + -c "Add :ProgramArguments array" \ + -c "Add :ProgramArguments: string \"$IPHONE_SIMULATOR_ROOT/usr/libexec/securityd\"" \ + -c "Add :EnvironmentVariables dict" \ + -c "Add :EnvironmentVariables:DYLD_ROOT_PATH string \"$IPHONE_SIMULATOR_ROOT\"" \ + -c "Add :EnvironmentVariables:IPHONE_SIMULATOR_ROOT string \"$IPHONE_SIMULATOR_ROOT\"" \ + -c "Add :EnvironmentVariables:CFFIXED_USER_HOME string \"$CFFIXED_USER_HOME\"" \ + -c "Add :MachServices dict" \ + -c "Add :MachServices:com.apple.securityd bool YES" "$plist_file" > /dev/null +} + if [ "$PLATFORM_NAME" == "iphonesimulator" ]; then # We kill the iPhone simulator because otherwise we run into issues where # the unittests fail becuase the simulator is currently running, and @@ -121,9 +141,13 @@ if [ "$PLATFORM_NAME" == "iphonesimulator" ]; then # presence as 'launchctl remove' will kill this script if run from within an # Xcode build. launchctl list | grep RunIPhoneLaunchDaemons && launchctl remove RunIPhoneLaunchDaemons + # If we want to test anything that interacts with the keychain, we need - # securityd up and running. See RunIPhoneLaunchDaemons.sh for details. - launchctl submit -l RunIPhoneLaunchDaemons -- "${ScriptDir}/RunIPhoneLaunchDaemons.sh" $IPHONE_SIMULATOR_ROOT $CFFIXED_USER_HOME + # securityd up and running. + LAUNCH_DAEMON_PLIST="$(GTMCreateLaunchDaemonPlist)" + launchctl load $LAUNCH_DAEMON_PLIST + rm $LAUNCH_DAEMON_PLIST + # No matter how we exit, we want to shut down our launchctl job. trap "launchctl remove RunIPhoneLaunchDaemons" INT TERM EXIT fi |