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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Script to run client or server tests on a live remote image. 7 # Script to run client or server tests on a live remote image.
8 8
9 # Load common constants. This should be the first executable line. 9 # Load common constants. This should be the first executable line.
10 # The path to common.sh should be relative to your script's location. 10 # The path to common.sh should be relative to your script's location.
(...skipping 11 matching lines...) Expand all
22 DEFINE_string chroot "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c 22 DEFINE_string chroot "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c
23 DEFINE_boolean cleanup ${FLAGS_FALSE} "Clean up temp directory" 23 DEFINE_boolean cleanup ${FLAGS_FALSE} "Clean up temp directory"
24 DEFINE_integer iterations 1 "Iterations to run every top level test" i 24 DEFINE_integer iterations 1 "Iterations to run every top level test" i
25 DEFINE_string results_dir_root "" "alternate root results directory" 25 DEFINE_string results_dir_root "" "alternate root results directory"
26 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v 26 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v
27 DEFINE_boolean use_emerged ${FLAGS_FALSE} \ 27 DEFINE_boolean use_emerged ${FLAGS_FALSE} \
28 "Force use of emerged autotest packages" 28 "Force use of emerged autotest packages"
29 29
30 RAN_ANY_TESTS=${FLAGS_FALSE} 30 RAN_ANY_TESTS=${FLAGS_FALSE}
31 31
32 function stop_ssh_agent() {
33 # Call this function from the exit trap of the main script.
34 # Iff we started ssh-agent, be nice and clean it up.
35 # Note, only works if called from the main script - no subshells.
36 if [[ 1 -eq ${OWN_SSH_AGENT} ]]
37 then
38 kill ${SSH_AGENT_PID} 2>/dev/null
39 unset OWN_SSH_AGENT SSH_AGENT_PID SSH_AUTH_SOCK
40 fi
41 }
42
43 function start_ssh_agent() {
44 local tmp_private_key=$TMP/autotest_key
45 if [ -z "$SSH_AGENT_PID" ]; then
46 eval $(ssh-agent)
47 OWN_SSH_AGENT=1
48 else
49 OWN_SSH_AGENT=0
50 fi
51 cp $FLAGS_private_key $tmp_private_key
52 chmod 0400 $tmp_private_key
53 ssh-add $tmp_private_key
54 }
55
32 function cleanup() { 56 function cleanup() {
33 # Always remove the build path in case it was used. 57 # Always remove the build path in case it was used.
34 [[ -n "${BUILD_DIR}" ]] && sudo rm -rf "${BUILD_DIR}" 58 [[ -n "${BUILD_DIR}" ]] && sudo rm -rf "${BUILD_DIR}"
35 if [[ $FLAGS_cleanup -eq ${FLAGS_TRUE} ]] || \ 59 if [[ $FLAGS_cleanup -eq ${FLAGS_TRUE} ]] || \
36 [[ ${RAN_ANY_TESTS} -eq ${FLAGS_FALSE} ]]; then 60 [[ ${RAN_ANY_TESTS} -eq ${FLAGS_FALSE} ]]; then
37 rm -rf "${TMP}" 61 rm -rf "${TMP}"
38 else 62 else
39 echo ">>> Details stored under ${TMP}" 63 echo ">>> Details stored under ${TMP}"
40 fi 64 fi
65 stop_ssh_agent
41 cleanup_remote_access 66 cleanup_remote_access
42 } 67 }
43 68
44 # Determine if a control is for a client or server test. Echos 69 # Determine if a control is for a client or server test. Echos
45 # either "server" or "client". 70 # either "server" or "client".
46 # Arguments: 71 # Arguments:
47 # $1 - control file path 72 # $1 - control file path
48 function read_test_type() { 73 function read_test_type() {
49 local control_file=$1 74 local control_file=$1
50 # Assume a line starts with TEST_TYPE = 75 # Assume a line starts with TEST_TYPE =
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 fi 187 fi
163 fi 188 fi
164 189
165 set -e 190 set -e
166 191
167 create_tmp 192 create_tmp
168 193
169 trap cleanup EXIT 194 trap cleanup EXIT
170 195
171 remote_access_init 196 remote_access_init
197 # autotest requires that an ssh-agent already be running
198 start_ssh_agent
172 199
173 learn_board 200 learn_board
174 autodetect_build 201 autodetect_build
175 202
176 local control_files_to_run="" 203 local control_files_to_run=""
177 local chrome_autotests="${CHROME_ROOT}/src/chrome/test/chromeos/autotest/files " 204 local chrome_autotests="${CHROME_ROOT}/src/chrome/test/chromeos/autotest/files "
178 # Now search for tests which unambiguously include the given identifier 205 # Now search for tests which unambiguously include the given identifier
179 local search_path=$(echo {client,server}/{tests,site_tests}) 206 local search_path=$(echo {client,server}/{tests,site_tests})
180 # Include chrome autotest in the search path 207 # Include chrome autotest in the search path
181 if [ -n "${CHROME_ROOT}" ]; then 208 if [ -n "${CHROME_ROOT}" ]; then
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 313
287 echo "" 314 echo ""
288 info "Test results:" 315 info "Test results:"
289 ./generate_test_report "${TMP}" --strip="${TMP}/" 316 ./generate_test_report "${TMP}" --strip="${TMP}/"
290 317
291 print_time_elapsed 318 print_time_elapsed
292 } 319 }
293 320
294 restart_in_chroot_if_needed "$@" 321 restart_in_chroot_if_needed "$@"
295 main "$@" 322 main "$@"
OLDNEW
« 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