Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
| 2 | |
| 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 | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 # Wrapper script around run_remote_tests.sh that knows how to find | |
| 8 # device test cells. | |
| 9 | |
| 10 | |
| 11 # TODO(pstew): Apparently the script files are in transition from | |
| 12 # src/scripts to src/scripts/bin. However this state has existed | |
| 13 # for months now, therefore we need to look for the common libs in | |
| 14 # both places | |
| 15 script_root=$(dirname $0) | |
| 16 if [ -f ${script_root}/../common.sh ] ; then | |
| 17 script_root=${script_root}/.. | |
| 18 fi | |
| 19 | |
| 20 . "${script_root}/common.sh" | |
| 21 | |
| 22 # Figure out the default chromelab server name. In order for this to | |
| 23 # work correctly, you have to: | |
| 24 # | |
| 25 # - Put the hostname into "scripts/.default_wifi_test_lab" | |
| 26 # - Create an /etc/hosts entry in your chroot for that hostname | |
| 27 # (if it isn't findable via DNS) | |
| 28 # - Make sure you have created a wifi_testbed_${lab} file in the | |
| 29 # ${autotest}/files/client/config/ directory | |
|
Sam Leffler
2010/07/15 17:46:13
Is it still necessary to have these config files i
| |
| 30 if [ -f "$GCLIENT_ROOT/src/scripts/.default_wifi_test_lab" ] ; then | |
| 31 DEFAULT_LAB=`cat "$GCLIENT_ROOT/src/scripts/.default_wifi_test_lab"` | |
| 32 fi | |
| 33 | |
| 34 # TODO(pstew) Since this is a wrapper script, we need to accept all | |
| 35 # arguments run_remote_tests does, plus a few more of our own. This | |
| 36 # can lead to version skew issues | |
| 37 | |
| 38 DEFINE_string args "" "Command line arguments for test, separated with comma" a | |
| 39 DEFINE_string board "" "The board for which you are building autotest" | |
| 40 DEFINE_string chroot "" "alternate chroot location" c | |
| 41 DEFINE_boolean cleanup ${FLAGS_FALSE} "Clean up temp directory" | |
| 42 DEFINE_string iterations "" "Iterations to run every top level test" i | |
| 43 DEFINE_string prepackaged_autotest "" "Use this prepackaged autotest dir" | |
| 44 DEFINE_string results_dir_root "" "alternate root results directory" | |
| 45 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v | |
| 46 | |
| 47 # These flags are specific to run_wifi_tests | |
| 48 DEFINE_string cell "" "Cell number to perform test on" | |
| 49 DEFINE_string client "" "Host name or IP of device to perform test" | |
| 50 DEFINE_string lab "${DEFAULT_LAB}" "Lab machine to perform test on" | |
| 51 DEFINE_string url "" "URL to lab server config server" | |
| 52 | |
| 53 FLAGS "$@" || exit 1 | |
| 54 | |
| 55 run_remote_flags="" | |
| 56 run_remote_args=${FLAGS_args} | |
| 57 | |
| 58 append_flag () { | |
| 59 local delim='' | |
| 60 [ -n "${run_remote_flags}" ] && delim=' ' | |
| 61 run_remote_flags="${run_remote_flags}${delim}$*" | |
| 62 } | |
| 63 | |
| 64 append_arg () { | |
| 65 local delim='' | |
| 66 [ -n "${run_remote_args}" ] && delim=',' | |
| 67 run_remote_args="${run_remote_args}${delim}$*" | |
| 68 } | |
| 69 | |
| 70 if [ -n "${FLAGS_board}" ]; then | |
| 71 append_flag --board "'${FLAGS_board}'" | |
| 72 fi | |
| 73 | |
| 74 if [ -n "${FLAGS_chroot}" ]; then | |
| 75 append_flag --chroot "'${FLAGS_chroot}'" | |
| 76 fi | |
| 77 | |
| 78 if [ "${FLAGS_cleanup}" -eq ${FLAGS_TRUE} ]; then | |
| 79 append_flag --cleanup | |
| 80 fi | |
| 81 | |
| 82 if [ -n "${FLAGS_iterations}" ]; then | |
| 83 append_flag --iterations ${FLAGS_iterations} | |
| 84 fi | |
| 85 | |
| 86 if [ -n "${FLAGS_prepackaged_autotest}" ]; then | |
| 87 append_flag --prepackaged_autotest "'${FLAGS_prepackaged_autotest}'" | |
| 88 fi | |
| 89 | |
| 90 if [ -n "${FLAGS_results_dir_root}" ]; then | |
| 91 append_flag --results_dir_root "'${FLAGS_results_dir_root}'" | |
| 92 fi | |
| 93 | |
| 94 if [ "${FLAGS_verbose}" -eq ${FLAGS_TRUE} ]; then | |
| 95 append_flag --verbose | |
| 96 fi | |
| 97 | |
| 98 # Parse our local args | |
| 99 if [ -n "${FLAGS_lab}" ] ; then | |
| 100 # Add a config file for the lab if one isn't already set | |
| 101 if ! expr "${run_remote_args}" : '.*config_file=' >/dev/null; then | |
| 102 append_arg "config_file=wifi_testbed_${FLAGS_lab}" | |
| 103 fi | |
| 104 fi | |
| 105 | |
| 106 if [ -n "${FLAGS_url}" ] ; then | |
| 107 lab_url=${FLAGS_url} | |
| 108 elif [ -n "${FLAGS_lab}" ] ; then | |
| 109 lab_url="http://${FLAGS_lab}:8080/cells" | |
| 110 else | |
| 111 echo ">>> No lab server specified. Please use --lab or --url options" | |
| 112 exit 1 | |
| 113 fi | |
| 114 | |
| 115 cell_no=0 | |
|
Sam Leffler
2010/07/15 17:46:13
Maybe default FLAG_cell to "0" and set this from i
| |
| 116 | |
| 117 # Retrieve the testbed config from the server and match either the client | |
| 118 # or the cell number to one of the entries | |
| 119 ret=$(curl -s $lab_url | \ | |
| 120 while read line; do | |
| 121 # Each line from the server is made up of: | |
| 122 # client_name router_name server_name client_addr router_addr server_addr | |
| 123 set $line | |
| 124 if [ "${FLAGS_cell}" = "$cell_no" -o "${FLAGS_client}" = "$1" -o \ | |
| 125 "${FLAGS_client}" = "$4" ] ; then | |
| 126 echo "$4" | |
| 127 echo "router_addr=$5" | |
| 128 if [ "$6" != "0.0.0.0" ] ; then | |
| 129 echo "server_addr=$6" | |
| 130 fi | |
| 131 break | |
| 132 fi | |
| 133 cell_no=$[cell_no + 1] | |
| 134 done) | |
| 135 | |
| 136 if [ -z "$ret" ] ; then | |
| 137 echo ">>> Cell or host not found at $lab_url" | |
| 138 exit 1 | |
| 139 fi | |
| 140 | |
| 141 set $ret | |
| 142 remote=$1 | |
| 143 shift | |
| 144 for arg in $*; do | |
| 145 append_arg $arg | |
| 146 done | |
| 147 | |
| 148 eval "exec "${script_root}/run_remote_tests.sh" \ | |
| 149 -a "${run_remote_args}" --remote=${remote} $run_remote_flags $FLAGS_ARGV" | |
| OLD | NEW |