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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 cd $(dirname "$0") | 142 cd $(dirname "$0") |
143 | 143 |
144 FLAGS "$@" || exit 1 | 144 FLAGS "$@" || exit 1 |
145 | 145 |
146 if [[ -z "${FLAGS_ARGV}" ]]; then | 146 if [[ -z "${FLAGS_ARGV}" ]]; then |
147 echo "Please specify tests to run. For example:" | 147 echo "Please specify tests to run. For example:" |
148 echo " $0 --remote=MyMachine BootPerfServer" | 148 echo " $0 --remote=MyMachine BootPerfServer" |
149 exit 1 | 149 exit 1 |
150 fi | 150 fi |
151 | 151 |
| 152 # Check the validity of the user-specified result directory |
| 153 # It must be within the /tmp directory |
| 154 if [[ -n "${FLAGS_results_dir_root}" ]]; then |
| 155 SUBSTRING=${FLAGS_results_dir_root:0:5} |
| 156 if [[ ${SUBSTRING} != "/tmp/" ]]; then |
| 157 echo "User-specified result directory must be within the /tmp directory" |
| 158 echo "ex: --results_dir_root=/tmp/<result_directory>" |
| 159 exit 1 |
| 160 fi |
| 161 fi |
| 162 |
152 set -e | 163 set -e |
153 | 164 |
154 # Set global TMP for remote_access.sh's sake | 165 # Set global TMP for remote_access.sh's sake |
155 if [[ ${INSIDE_CHROOT} -eq 0 ]] | 166 # and if --results_dir_root is specified, |
156 then | 167 # set TMP and create dir appropriately |
157 TMP=$(mktemp -d ${FLAGS_chroot}/tmp/run_remote_tests.XXXX) | 168 if [[ ${INSIDE_CHROOT} -eq 0 ]]; then |
| 169 if [[ -n "${FLAGS_results_dir_root}" ]]; then |
| 170 TMP=${FLAGS_chroot}${FLAGS_results_dir_root} |
| 171 mkdir -m 777 ${TMP} |
| 172 else |
| 173 TMP=$(mktemp -d ${FLAGS_chroot}/tmp/run_remote_tests.XXXX) |
| 174 fi |
158 TMP_INSIDE_CHROOT=$(echo ${TMP#${FLAGS_chroot}}) | 175 TMP_INSIDE_CHROOT=$(echo ${TMP#${FLAGS_chroot}}) |
159 else | 176 else |
160 TMP=$(mktemp -d /tmp/run_remote_tests.XXXX) | 177 if [[ -n "${FLAGS_results_dir_root}" ]]; then |
| 178 TMP=${FLAGS_results_dir_root} |
| 179 mkdir -m 777 ${TMP} |
| 180 else |
| 181 TMP=$(mktemp -d /tmp/run_remote_tests.XXXX) |
| 182 fi |
161 TMP_INSIDE_CHROOT=${TMP} | 183 TMP_INSIDE_CHROOT=${TMP} |
162 fi | 184 fi |
163 | 185 |
164 trap cleanup EXIT | 186 trap cleanup EXIT |
165 | 187 |
166 remote_access_init | 188 remote_access_init |
167 | 189 |
168 local autotest_dir="" | 190 local autotest_dir="" |
169 if [[ -z "${FLAGS_prepackaged_autotest}" ]]; then | 191 if [[ -z "${FLAGS_prepackaged_autotest}" ]]; then |
170 learn_board | 192 learn_board |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 if [[ -z "${control_files_to_run}" ]]; then | 232 if [[ -z "${control_files_to_run}" ]]; then |
211 echo_color "red" ">>> Found no control files" | 233 echo_color "red" ">>> Found no control files" |
212 exit 1 | 234 exit 1 |
213 fi | 235 fi |
214 | 236 |
215 echo_color "yellow" ">>> Running the following control files:" | 237 echo_color "yellow" ">>> Running the following control files:" |
216 for CONTROL_FILE in ${control_files_to_run}; do | 238 for CONTROL_FILE in ${control_files_to_run}; do |
217 echo_color "yellow" " * " "${CONTROL_FILE}" | 239 echo_color "yellow" " * " "${CONTROL_FILE}" |
218 done | 240 done |
219 | 241 |
220 if [[ -z "${FLAGS_results_dir_root}" ]]; then | |
221 FLAGS_results_dir_root="${TMP_INSIDE_CHROOT}" | |
222 fi | |
223 | |
224 mkdir -p "${FLAGS_results_dir_root}" | |
225 | |
226 for control_file in ${control_files_to_run}; do | 242 for control_file in ${control_files_to_run}; do |
227 # Assume a line starts with TEST_TYPE = | 243 # Assume a line starts with TEST_TYPE = |
228 control_file=$(remove_quotes "${control_file}") | 244 control_file=$(remove_quotes "${control_file}") |
229 local type=$(read_test_type "${autotest_dir}/${control_file}") | 245 local type=$(read_test_type "${autotest_dir}/${control_file}") |
230 local option | 246 local option |
231 if [[ "${type}" == "client" ]]; then | 247 if [[ "${type}" == "client" ]]; then |
232 option="-c" | 248 option="-c" |
233 else | 249 else |
234 option="-s" | 250 option="-s" |
235 fi | 251 fi |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 fi | 292 fi |
277 else | 293 else |
278 echo_color "red" ">>> FAILED: ${control_file}" | 294 echo_color "red" ">>> FAILED: ${control_file}" |
279 cat "${test_status}" | 295 cat "${test_status}" |
280 fi | 296 fi |
281 local end_time=$(date '+%s') | 297 local end_time=$(date '+%s') |
282 done | 298 done |
283 } | 299 } |
284 | 300 |
285 main $@ | 301 main $@ |
OLD | NEW |