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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 function cleanup() { | 56 function cleanup() { |
57 if [[ $FLAGS_cleanup -eq ${FLAGS_TRUE} ]] || \ | 57 if [[ $FLAGS_cleanup -eq ${FLAGS_TRUE} ]] || \ |
58 [[ ${RAN_ANY_TESTS} -eq ${FLAGS_FALSE} ]]; then | 58 [[ ${RAN_ANY_TESTS} -eq ${FLAGS_FALSE} ]]; then |
59 rm -rf "${TMP}" | 59 rm -rf "${TMP}" |
60 else | 60 else |
61 echo ">>> Details stored under ${TMP}" | 61 echo ">>> Details stored under ${TMP}" |
62 fi | 62 fi |
63 cleanup_remote_access | 63 cleanup_remote_access |
64 } | 64 } |
65 | 65 |
66 # Returns an error if the test_result_file has text which indicates | |
67 # the test was not run successfully. | |
68 # Arguments: | |
69 # $1 - file name of autotest status for to check for success | |
70 # Returns: | |
71 # None | |
72 function is_successful_test() { | |
73 local file="$1" | |
74 # To be successful, must not have BAD, ERROR or FAIL in the file. | |
75 if egrep -q "(BAD|ERROR|FAIL)" "${file}"; then | |
76 return 1 | |
77 fi | |
78 # To be successful, must have GOOD in the file. | |
79 if ! grep -q GOOD "${file}"; then | |
80 return 1 | |
81 fi | |
82 return 0 | |
83 } | |
84 | |
85 # Adds attributes to all tests run | 66 # Adds attributes to all tests run |
86 # Arguments: | 67 # Arguments: |
87 # $1 - results directory | 68 # $1 - results directory |
88 # $2 - attribute name (key) | 69 # $2 - attribute name (key) |
89 # $3 - attribute value (value) | 70 # $3 - attribute value (value) |
90 function add_test_attribute() { | 71 function add_test_attribute() { |
91 local results_dir="$1" | 72 local results_dir="$1" |
92 local attribute_name="$2" | 73 local attribute_name="$2" |
93 local attribute_value="$3" | 74 local attribute_value="$3" |
94 if [[ -z "$attribute_value" ]]; then | 75 if [[ -z "$attribute_value" ]]; then |
95 return; | 76 return; |
96 fi | 77 fi |
97 | 78 |
98 for status_file in $(echo "${results_dir}"/*/status); do | 79 for status_file in $(echo "${results_dir}"/*/status); do |
99 local keyval_file=$(dirname $status_file)/keyval | 80 local keyval_file=$(dirname $status_file)/keyval |
100 echo "Updating ${keyval_file}" | 81 echo "Updating ${keyval_file}" |
101 echo "${attribute_name}=${attribute_value}" >> "${keyval_file}" | 82 echo "${attribute_name}=${attribute_value}" >> "${keyval_file}" |
102 done | 83 done |
103 } | 84 } |
104 | 85 |
105 | 86 |
106 # Ask the target what board it is | |
107 function learn_board() { | |
108 if [[ -n "${FLAGS_board}" ]]; then | |
109 return | |
110 fi | |
111 remote_sh grep CHROMEOS_RELEASE_BOARD /etc/lsb-release | |
112 FLAGS_board=$(echo "${REMOTE_OUT}" | cut -d= -f2) | |
113 if [[ -z "${FLAGS_board}" ]]; then | |
114 check_board | |
115 fi | |
116 echo "Target reports board is ${FLAGS_board}" | |
117 } | |
118 | |
119 | |
120 # Determine if a control is for a client or server test. Echos | 87 # Determine if a control is for a client or server test. Echos |
121 # either "server" or "client". | 88 # either "server" or "client". |
122 # Arguments: | 89 # Arguments: |
123 # $1 - control file path | 90 # $1 - control file path |
124 function read_test_type() { | 91 function read_test_type() { |
125 local control_file=$1 | 92 local control_file=$1 |
126 # Assume a line starts with TEST_TYPE = | 93 # Assume a line starts with TEST_TYPE = |
127 local type=$(egrep -m1 \ | 94 local type=$(egrep -m1 \ |
128 '^[[:space:]]*TEST_TYPE[[:space:]]*=' "${control_file}") | 95 '^[[:space:]]*TEST_TYPE[[:space:]]*=' "${control_file}") |
129 if [[ -z "${type}" ]]; then | 96 if [[ -z "${type}" ]]; then |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 "${option}" "${control_file}" -r "${results_dir}" ${verbose} \ | 250 "${option}" "${control_file}" -r "${results_dir}" ${verbose} \ |
284 "${args[@]}" | 251 "${args[@]}" |
285 done | 252 done |
286 | 253 |
287 echo "" | 254 echo "" |
288 echo_color "yellow" ">>> Test results:" | 255 echo_color "yellow" ">>> Test results:" |
289 $(dirname "$0")/generate_test_report "${TMP}" --strip="${TMP}/" | 256 $(dirname "$0")/generate_test_report "${TMP}" --strip="${TMP}/" |
290 } | 257 } |
291 | 258 |
292 main $@ | 259 main $@ |
OLD | NEW |