OLD | NEW |
---|---|
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 Loading... | |
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() { | |
kmixter1
2011/01/13 23:16:39
Agree it would be good to say that this is implici
| |
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 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 exit 1 | 186 exit 1 |
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 |
petkov
2011/01/13 23:22:27
btw, are you setting up 2 ssh-agent's now? any con
| |
197 start_ssh_agent | |
172 | 198 |
173 learn_board | 199 learn_board |
174 autodetect_build | 200 autodetect_build |
175 | 201 |
176 local control_files_to_run="" | 202 local control_files_to_run="" |
177 local chrome_autotests="${CHROME_ROOT}/src/chrome/test/chromeos/autotest/files " | 203 local chrome_autotests="${CHROME_ROOT}/src/chrome/test/chromeos/autotest/files " |
178 # Now search for tests which unambiguously include the given identifier | 204 # Now search for tests which unambiguously include the given identifier |
179 local search_path=$(echo {client,server}/{tests,site_tests}) | 205 local search_path=$(echo {client,server}/{tests,site_tests}) |
180 # Include chrome autotest in the search path | 206 # Include chrome autotest in the search path |
181 if [ -n "${CHROME_ROOT}" ]; then | 207 if [ -n "${CHROME_ROOT}" ]; then |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 | 312 |
287 echo "" | 313 echo "" |
288 info "Test results:" | 314 info "Test results:" |
289 ./generate_test_report "${TMP}" --strip="${TMP}/" | 315 ./generate_test_report "${TMP}" --strip="${TMP}/" |
290 | 316 |
291 print_time_elapsed | 317 print_time_elapsed |
292 } | 318 } |
293 | 319 |
294 restart_in_chroot_if_needed "$@" | 320 restart_in_chroot_if_needed "$@" |
295 main "$@" | 321 main "$@" |
OLD | NEW |