Make run_remote_test's use of ssh-agent more predictable.

Review URL: http://codereview.chromium.org/560005
This commit is contained in:
Sean O'Connor 2010-02-01 17:10:03 -08:00
parent 797abfd825
commit 9969ce9238
2 changed files with 15 additions and 5 deletions

View File

@ -25,6 +25,9 @@ function remote_sh_allow_changed_host_key() {
function set_up_remote_access() {
if [ -z "$SSH_AGENT_PID" ]; then
eval $(ssh-agent)
OWN_SSH_AGENT=1
else
OWN_SSH_AGENT=0
fi
cp $FLAGS_private_key $TMP_PRIVATE_KEY
chmod 0400 $TMP_PRIVATE_KEY
@ -36,6 +39,17 @@ function set_up_remote_access() {
echo "Connection OK"
}
function cleanup_remote_access() {
# Call this function from the exit trap of the main script.
# Iff we started ssh-agent, be nice and clean it up.
# Note, only works if called from the main script - no subshells.
if [[ 1 -eq ${OWN_SSH_AGENT} ]]
then
kill ${SSH_AGENT_PID} 2>/dev/null
unset SSH_AGENT_PID SSH_AUTH_SOCK
fi
}
function remote_access_init() {
TMP_PRIVATE_KEY=$TMP/private_key
TMP_KNOWN_HOSTS=$TMP/known_hosts

View File

@ -29,11 +29,7 @@ function cleanup() {
else
echo "Left temporary files at ${TMP}"
fi
if [[ -n "${SSH_AGENT_PID}" ]]
then
kill ${SSH_AGENT_PID} 2>/dev/null
unset SSH_AGENT_PID SSH_AUTH_SOCK
fi
cleanup_remote_access
}
# Returns an error if the test_result_file has text which indicates