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

Side by Side Diff: run_remote_tests.sh

Issue 6240018: This starts to fix the scripts so that they load from /usr/lib/crosutils (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: fixing bad merge Created 9 years, 10 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 | « resize_stateful_partition.sh ('k') | set_shared_user_password.sh » ('j') | 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.
11 11
12 . "$(dirname $0)/common.sh" 12 # --- BEGIN COMMON.SH BOILERPLATE ---
13 . "$(dirname $0)/remote_access.sh" 13 # Load common CrOS utilities. Inside the chroot this file is installed in
14 # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
15 # location.
16 find_common_sh() {
17 local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
18 local path
19
20 SCRIPT_ROOT=
21 for path in "${common_paths[@]}"; do
22 if [ -r "${path}/common.sh" ]; then
23 SCRIPT_ROOT=${path}
24 break
25 fi
26 done
27 }
28
29 find_common_sh
30 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
31 # --- END COMMON.SH BOILERPLATE ---
32
33 . "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh"
14 34
15 get_default_board 35 get_default_board
16 36
17 DEFINE_string args "" \ 37 DEFINE_string args "" \
18 "Command line arguments for test. Quoted and space separated if multiple." a 38 "Command line arguments for test. Quoted and space separated if multiple." a
19 DEFINE_string board "$DEFAULT_BOARD" \ 39 DEFINE_string board "$DEFAULT_BOARD" \
20 "The board for which you are building autotest" 40 "The board for which you are building autotest"
21 DEFINE_boolean build ${FLAGS_FALSE} "Build tests while running" b 41 DEFINE_boolean build ${FLAGS_FALSE} "Build tests while running" b
22 DEFINE_string chroot "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c 42 DEFINE_string chroot "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c
23 DEFINE_boolean cleanup ${FLAGS_FALSE} "Clean up temp directory" 43 DEFINE_boolean cleanup ${FLAGS_FALSE} "Clean up temp directory"
24 DEFINE_integer iterations 1 "Iterations to run every top level test" i 44 DEFINE_integer iterations 1 "Iterations to run every top level test" i
25 DEFINE_string results_dir_root "" "alternate root results directory" 45 DEFINE_string results_dir_root "" "alternate root results directory"
26 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v 46 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v
27 DEFINE_boolean use_emerged ${FLAGS_FALSE} \ 47 DEFINE_boolean use_emerged ${FLAGS_FALSE} \
28 "Force use of emerged autotest packages" 48 "Force use of emerged autotest packages"
29 49
30 RAN_ANY_TESTS=${FLAGS_FALSE} 50 RAN_ANY_TESTS=${FLAGS_FALSE}
31 51
32 function stop_ssh_agent() { 52 function stop_ssh_agent() {
33 # Call this function from the exit trap of the main script. 53 # Call this function from the exit trap of the main script.
34 # Iff we started ssh-agent, be nice and clean it up. 54 # Iff we started ssh-agent, be nice and clean it up.
35 # Note, only works if called from the main script - no subshells. 55 # Note, only works if called from the main script - no subshells.
36 if [[ 1 -eq ${OWN_SSH_AGENT} ]] 56 if [[ 1 -eq ${OWN_SSH_AGENT} ]]; then
37 then
38 kill ${SSH_AGENT_PID} 2>/dev/null 57 kill ${SSH_AGENT_PID} 2>/dev/null
39 unset OWN_SSH_AGENT SSH_AGENT_PID SSH_AUTH_SOCK 58 unset OWN_SSH_AGENT SSH_AGENT_PID SSH_AUTH_SOCK
40 fi 59 fi
41 } 60 }
42 61
43 function start_ssh_agent() { 62 function start_ssh_agent() {
44 local tmp_private_key=$TMP/autotest_key 63 local tmp_private_key=$TMP/autotest_key
45 if [ -z "$SSH_AGENT_PID" ]; then 64 if [ -z "$SSH_AGENT_PID" ]; then
46 eval $(ssh-agent) 65 eval $(ssh-agent)
47 OWN_SSH_AGENT=1 66 OWN_SSH_AGENT=1
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 die \ 141 die \
123 "Could not find pre-installed autotest, you need to emerge-${FLAGS_board} \ 142 "Could not find pre-installed autotest, you need to emerge-${FLAGS_board} \
124 autotest autotest-tests (or use --build)." 143 autotest autotest-tests (or use --build)."
125 fi 144 fi
126 info \ 145 info \
127 "As requested, using emerged autotests already installed at ${AUTOTEST_DIR}." 146 "As requested, using emerged autotests already installed at ${AUTOTEST_DIR}."
128 return 147 return
129 fi 148 fi
130 149
131 if [ ${FLAGS_build} -eq ${FLAGS_FALSE} ] && 150 if [ ${FLAGS_build} -eq ${FLAGS_FALSE} ] &&
132 $(dirname $0)/cros_workon --board=${FLAGS_board} list | 151 "${SCRIPTS_DIR}/cros_workon" --board=${FLAGS_board} list |
133 grep -q autotest; then 152 grep -q autotest; then
134 AUTOTEST_DIR="${SRC_ROOT}/third_party/autotest/files" 153 AUTOTEST_DIR="${SRC_ROOT}/third_party/autotest/files"
135 FLAGS_build=${FLAGS_TRUE} 154 FLAGS_build=${FLAGS_TRUE}
136 if [ ! -d "${AUTOTEST_DIR}" ]; then 155 if [ ! -d "${AUTOTEST_DIR}" ]; then
137 die \ 156 die \
138 "Detected cros_workon autotest but ${AUTOTEST_DIR} does not exist. Run \ 157 "Detected cros_workon autotest but ${AUTOTEST_DIR} does not exist. Run \
139 repo sync autotest." 158 repo sync autotest."
140 fi 159 fi
141 info \ 160 info \
142 "Detected cros_workon autotests. Building and running your autotests from \ 161 "Detected cros_workon autotests. Building and running your autotests from \
(...skipping 15 matching lines...) Expand all
158 if [ ! -d "${AUTOTEST_DIR}" ]; then 177 if [ ! -d "${AUTOTEST_DIR}" ]; then
159 die \ 178 die \
160 "Autotest was not emerged. Run emerge-${FLAGS_board} autotest \ 179 "Autotest was not emerged. Run emerge-${FLAGS_board} autotest \
161 autotest-tests to continue." 180 autotest-tests to continue."
162 fi 181 fi
163 info "Using emerged autotests already installed at ${AUTOTEST_DIR}." 182 info "Using emerged autotests already installed at ${AUTOTEST_DIR}."
164 fi 183 fi
165 } 184 }
166 185
167 function main() { 186 function main() {
168 cd $(dirname "$0") 187 cd "${SCRIPTS_DIR}"
169 188
170 FLAGS "$@" || exit 1 189 FLAGS "$@" || exit 1
171 190
172 if [[ -z "${FLAGS_ARGV}" ]]; then 191 if [[ -z "${FLAGS_ARGV}" ]]; then
173 echo "Usage: $0 --remote=[hostname] [regexp...]:" 192 echo "Usage: $0 --remote=[hostname] [regexp...]:"
174 echo "Each regexp pattern must uniquely match a control file. For example:" 193 echo "Each regexp pattern must uniquely match a control file. For example:"
175 echo " $0 --remote=MyMachine BootPerfServer" 194 echo " $0 --remote=MyMachine BootPerfServer"
176 exit 1 195 exit 1
177 fi 196 fi
178 197
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 fi 273 fi
255 local option 274 local option
256 if [[ "${test_type}" == "client" ]]; then 275 if [[ "${test_type}" == "client" ]]; then
257 option="-c" 276 option="-c"
258 else 277 else
259 option="-s" 278 option="-s"
260 fi 279 fi
261 echo "" 280 echo ""
262 info "Running ${test_type} test ${control_file}" 281 info "Running ${test_type} test ${control_file}"
263 local control_file_name=$(basename "${control_file}") 282 local control_file_name=$(basename "${control_file}")
264 local short_name=$(basename $(dirname "${control_file}")) 283 local short_name=$(basename "$(dirname "${control_file}")")
265 284
266 # testName/control --> testName 285 # testName/control --> testName
267 # testName/control.bvt --> testName.bvt 286 # testName/control.bvt --> testName.bvt
268 # testName/control.regression --> testName.regression 287 # testName/control.regression --> testName.regression
269 # testName/some_control --> testName.some_control 288 # testName/some_control --> testName.some_control
270 if [[ "${control_file_name}" != control ]]; then 289 if [[ "${control_file_name}" != control ]]; then
271 if [[ "${control_file_name}" == control.* ]]; then 290 if [[ "${control_file_name}" == control.* ]]; then
272 short_name=${short_name}.${control_file_name/control./} 291 short_name=${short_name}.${control_file_name/control./}
273 else 292 else
274 short_name=${short_name}.${control_file_name} 293 short_name=${short_name}.${control_file_name}
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 332
314 echo "" 333 echo ""
315 info "Test results:" 334 info "Test results:"
316 ./generate_test_report "${TMP}" --strip="${TMP}/" 335 ./generate_test_report "${TMP}" --strip="${TMP}/"
317 336
318 print_time_elapsed 337 print_time_elapsed
319 } 338 }
320 339
321 restart_in_chroot_if_needed "$@" 340 restart_in_chroot_if_needed "$@"
322 main "$@" 341 main "$@"
OLDNEW
« no previous file with comments | « resize_stateful_partition.sh ('k') | set_shared_user_password.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698