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. |
11 | 11 |
12 . "$(dirname $0)/common.sh" | 12 . "$(dirname $0)/common.sh" |
13 . "$(dirname $0)/remote_access.sh" | 13 . "$(dirname $0)/remote_access.sh" |
14 | 14 |
15 DEFAULT_OUTPUT_FILE=test-output-$(date '+%Y%m%d.%H%M%S') | 15 DEFAULT_OUTPUT_FILE=test-output-$(date '+%Y%m%d.%H%M%S') |
16 | 16 |
17 DEFINE_boolean cleanup ${FLAGS_TRUE} "Clean up temp directory" | 17 DEFINE_boolean cleanup ${FLAGS_TRUE} "Clean up temp directory" |
18 DEFINE_integer iterations 1 "Iterations to run every top level test" i | 18 DEFINE_integer iterations 1 "Iterations to run every top level test" i |
19 DEFINE_string output_file "${DEFAULT_OUTPUT_FILE}" "Test run output" o | 19 DEFINE_string output_file "${DEFAULT_OUTPUT_FILE}" "Test run output" o |
20 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v | 20 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v |
21 DEFINE_boolean update_db ${FLAGS_FALSE} "Put results in autotest database" u | 21 DEFINE_boolean update_db ${FLAGS_FALSE} "Put results in autotest database" u |
22 DEFINE_string machine_desc "" "Machine description used in database" | 22 DEFINE_string machine_desc "" "Machine description used in database" |
23 DEFINE_string build_desc "" "Build description used in database" | 23 DEFINE_string build_desc "" "Build description used in database" |
24 DEFINE_string chroot_dir "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c | 24 DEFINE_string chroot_dir "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c |
25 DEFINE_string results_dir_root "" "alternate root results directory" | |
25 | 26 |
26 function cleanup() { | 27 function cleanup() { |
27 if [[ $FLAGS_cleanup -eq ${FLAGS_TRUE} ]]; then | 28 if [[ $FLAGS_cleanup -eq ${FLAGS_TRUE} ]]; then |
28 rm -rf "${TMP}" | 29 rm -rf "${TMP}" |
29 else | 30 else |
30 echo "Left temporary files at ${TMP}" | 31 echo "Left temporary files at ${TMP}" |
31 fi | 32 fi |
32 if [[ -n "${SSH_AGENT_PID}" ]] | 33 if [[ -n "${SSH_AGENT_PID}" ]] |
33 then | 34 then |
34 kill ${SSH_AGENT_PID} 2>/dev/null | 35 kill ${SSH_AGENT_PID} 2>/dev/null |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 | 148 |
148 echo "Running the following control files: ${control_files_to_run}" | 149 echo "Running the following control files: ${control_files_to_run}" |
149 | 150 |
150 remote_access_init | 151 remote_access_init |
151 | 152 |
152 # Set the default machine description to the machine's IP | 153 # Set the default machine description to the machine's IP |
153 if [[ -z "${FLAGS_machine_desc}" ]]; then | 154 if [[ -z "${FLAGS_machine_desc}" ]]; then |
154 FLAGS_machine_desc="${FLAGS_remote}" | 155 FLAGS_machine_desc="${FLAGS_remote}" |
155 fi | 156 fi |
156 | 157 |
158 if [[ -z "${FLAGS_results_dir_root}" ]]; then | |
159 FLAGS_results_dir_root="${TMP}" | |
160 fi | |
161 | |
162 mkdir -p "${FLAGS_results_dir_root}" | |
163 | |
157 for control_file in ${control_files_to_run}; do | 164 for control_file in ${control_files_to_run}; do |
158 # Assume a line starts with TEST_TYPE = | 165 # Assume a line starts with TEST_TYPE = |
159 control_file=$(remove_quotes "${control_file}") | 166 control_file=$(remove_quotes "${control_file}") |
160 local type=$(egrep '^\s*TEST_TYPE\s*=' "${control_file}" | head -1) | 167 local type=$(egrep '^\s*TEST_TYPE\s*=' "${control_file}" | head -1) |
161 type=$(python -c "${type}; print TEST_TYPE.lower()") | 168 type=$(python -c "${type}; print TEST_TYPE.lower()") |
162 local option | 169 local option |
163 if [ "${type}" == "client" ]; then | 170 if [ "${type}" == "client" ]; then |
164 option="-c" | 171 option="-c" |
165 elif [ "${type}" == "server" ]; then | 172 elif [ "${type}" == "server" ]; then |
166 option="-s" | 173 option="-s" |
167 else | 174 else |
168 echo "Unknown type of test (${type}) in ${control_file}" | 175 echo "Unknown type of test (${type}) in ${control_file}" |
169 exit 1 | 176 exit 1 |
170 fi | 177 fi |
171 echo "Running ${type} test ${control_file}" | 178 echo "Running ${type} test ${control_file}" |
172 local short_name=$(basename $(dirname "${control_file}")) | 179 local short_name=$(basename $(dirname "${control_file}")) |
173 local start_time=$(date '+%s') | 180 local start_time=$(date '+%s') |
174 local results_dir="${TMP}/${short_name},${FLAGS_machine_desc},${start_time}" | 181 local results_dir_name="${short_name},${FLAGS_machine_desc},${start_time}" |
sosa
2010/01/29 02:43:12
Unless you're planning to reuse this, I think this
| |
182 local results_dir="${FLAGS_results_dir_root}/${results_dir_name}" | |
175 rm -rf "${results_dir}" | 183 rm -rf "${results_dir}" |
176 local verbose="" | 184 local verbose="" |
177 if [[ ${FLAGS_verbose} -eq $FLAGS_TRUE ]]; then | 185 if [[ ${FLAGS_verbose} -eq $FLAGS_TRUE ]]; then |
178 verbose="--verbose" | 186 verbose="--verbose" |
179 fi | 187 fi |
180 | 188 |
181 ${autoserv} -m "${FLAGS_remote}" "${option}" "${control_file}" \ | 189 ${autoserv} -m "${FLAGS_remote}" "${option}" "${control_file}" \ |
182 -r "${results_dir}" ${verbose} | 190 -r "${results_dir}" ${verbose} |
183 local test_status="${results_dir}/status" | 191 local test_status="${results_dir}/status" |
184 local test_result_dir="${results_dir}/${short_name}" | 192 local test_result_dir="${results_dir}/${short_name}" |
(...skipping 22 matching lines...) Expand all Loading... | |
207 echo "Parse failed." | tee -a "${FLAGS_output_file}" | 215 echo "Parse failed." | tee -a "${FLAGS_output_file}" |
208 FLAGS_cleanup=${FLAGS_FALSE} | 216 FLAGS_cleanup=${FLAGS_FALSE} |
209 fi | 217 fi |
210 fi | 218 fi |
211 done | 219 done |
212 | 220 |
213 echo "Output stored to ${FLAGS_output_file}" | 221 echo "Output stored to ${FLAGS_output_file}" |
214 } | 222 } |
215 | 223 |
216 main $@ | 224 main $@ |
OLD | NEW |