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)/autotest_lib.sh" |
13 . "$(dirname $0)/remote_access.sh" | 14 . "$(dirname $0)/remote_access.sh" |
14 | 15 |
15 DEFAULT_OUTPUT_FILE=test-output-$(date '+%Y%m%d.%H%M%S') | 16 DEFAULT_OUTPUT_FILE=test-output-$(date '+%Y%m%d.%H%M%S') |
16 | 17 |
17 DEFINE_boolean cleanup ${FLAGS_TRUE} "Clean up temp directory" | 18 DEFINE_boolean cleanup ${FLAGS_TRUE} "Clean up temp directory" |
18 DEFINE_integer iterations 1 "Iterations to run every top level test" i | 19 DEFINE_integer iterations 1 "Iterations to run every top level test" i |
19 DEFINE_string output_file "${DEFAULT_OUTPUT_FILE}" "Test run output" o | 20 DEFINE_string output_file "${DEFAULT_OUTPUT_FILE}" "Test run output" o |
20 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v | 21 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v |
21 DEFINE_boolean update_db ${FLAGS_FALSE} "Put results in autotest database" u | 22 DEFINE_boolean update_db ${FLAGS_FALSE} "Put results in autotest database" u |
22 DEFINE_string machine_desc "" "Machine description used in database" | 23 DEFINE_string machine_desc "" "Machine description used in database" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 97 |
97 local parse_cmd="$(dirname $0)/../third_party/autotest/files/tko/parse.py" | 98 local parse_cmd="$(dirname $0)/../third_party/autotest/files/tko/parse.py" |
98 | 99 |
99 if [[ ${FLAGS_update_db} -eq ${FLAGS_TRUE} && ! -x "${parse_cmd}" ]]; then | 100 if [[ ${FLAGS_update_db} -eq ${FLAGS_TRUE} && ! -x "${parse_cmd}" ]]; then |
100 echo "Cannot find parser ${parse_cmd}" | 101 echo "Cannot find parser ${parse_cmd}" |
101 exit 1 | 102 exit 1 |
102 fi | 103 fi |
103 | 104 |
104 set -e | 105 set -e |
105 | 106 |
106 AUTOTEST_DIR="${DEFAULT_CHROOT_DIR}/usr/local/autotest" | 107 local autotest_dir="${DEFAULT_CHROOT_DIR}/usr/local/autotest" |
107 | 108 |
108 # Set global TMP for remote_access.sh's sake | 109 # Set global TMP for remote_access.sh's sake |
109 TMP=$(mktemp -d /tmp/run_remote_tests.XXXX) | 110 TMP=$(mktemp -d /tmp/run_remote_tests.XXXX) |
110 | 111 |
111 rm -f "${FLAGS_output_file}" | 112 rm -f "${FLAGS_output_file}" |
112 | 113 |
113 trap cleanup EXIT | 114 trap cleanup EXIT |
114 | 115 |
115 # Check for installed autotest. | 116 # Always copy into installed autotest directory. This way if a user |
116 local autoserv="${AUTOTEST_DIR}/server/autoserv" | 117 # is just modifying scripts, they take effect without having to wait |
117 if [[ ! -f "${autoserv}" ]]; then | 118 # for the laborious build_autotest.sh command. |
118 echo "Cannot find autotest in build dir. Run build_autotest.sh" | 119 local original="${GCLIENT_ROOT}/src/third_party/autotest/files" |
119 exit 1 | 120 update_chroot_autotest "${original}" |
120 fi | 121 |
| 122 local autoserv="${autotest_dir}/server/autoserv" |
121 | 123 |
122 local control_files_to_run="" | 124 local control_files_to_run="" |
123 | 125 |
124 # Now search for tests which unambiguously include the given identifier | 126 # Now search for tests which unambiguously include the given identifier |
125 local search_path=$(echo ${AUTOTEST_DIR}/{client,server}/{tests,site_tests}) | 127 local search_path=$(echo ${autotest_dir}/{client,server}/{tests,site_tests}) |
126 for test_request in $FLAGS_ARGV; do | 128 for test_request in $FLAGS_ARGV; do |
127 test_request=$(remove_quotes "${test_request}") | 129 test_request=$(remove_quotes "${test_request}") |
128 ! finds=$(find ${search_path} -type f -name control | \ | 130 ! finds=$(find ${search_path} -type f -name control | \ |
129 egrep "${test_request}") | 131 egrep "${test_request}") |
130 if [[ -z "${finds}" ]]; then | 132 if [[ -z "${finds}" ]]; then |
131 echo "Can not find match for ${test_request}" | 133 echo "Can not find match for ${test_request}" |
132 exit 1 | 134 exit 1 |
133 fi | 135 fi |
134 local matches=$(echo "${finds}" | wc -l) | 136 local matches=$(echo "${finds}" | wc -l) |
135 if [[ ${matches} -gt 1 ]]; then | 137 if [[ ${matches} -gt 1 ]]; then |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 echo "Parse failed." | tee -a "${FLAGS_output_file}" | 213 echo "Parse failed." | tee -a "${FLAGS_output_file}" |
212 FLAGS_cleanup=${FLAGS_FALSE} | 214 FLAGS_cleanup=${FLAGS_FALSE} |
213 fi | 215 fi |
214 fi | 216 fi |
215 done | 217 done |
216 | 218 |
217 echo "Output stored to ${FLAGS_output_file}" | 219 echo "Output stored to ${FLAGS_output_file}" |
218 } | 220 } |
219 | 221 |
220 main $@ | 222 main $@ |
OLD | NEW |