Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1477)

Unified Diff: run_remote_tests.sh

Issue 6333001: run_remote_test.sh: explicitly start/stop ssh-agent (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Address codereview feedback. Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: run_remote_tests.sh
diff --git a/run_remote_tests.sh b/run_remote_tests.sh
index 9cb131817297301766619d05a3f71f74b5306d37..ab4923d75683cb3adbf193580f769f1a8c810dc4 100755
--- a/run_remote_tests.sh
+++ b/run_remote_tests.sh
@@ -29,6 +29,30 @@ DEFINE_boolean use_emerged ${FLAGS_FALSE} \
RAN_ANY_TESTS=${FLAGS_FALSE}
+function stop_ssh_agent() {
+ # 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 OWN_SSH_AGENT SSH_AGENT_PID SSH_AUTH_SOCK
+ fi
+}
+
+function start_ssh_agent() {
+ local tmp_private_key=$TMP/autotest_key
+ 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
+ ssh-add $tmp_private_key
+}
+
function cleanup() {
# Always remove the build path in case it was used.
[[ -n "${BUILD_DIR}" ]] && sudo rm -rf "${BUILD_DIR}"
@@ -38,6 +62,7 @@ function cleanup() {
else
echo ">>> Details stored under ${TMP}"
fi
+ stop_ssh_agent
cleanup_remote_access
}
@@ -169,6 +194,8 @@ function main() {
trap cleanup EXIT
remote_access_init
+ # autotest requires that an ssh-agent already be running
+ start_ssh_agent
learn_board
autodetect_build
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698