OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 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 # Runs a given test case under a VM. | 7 # Runs a given test case under a VM. |
8 | 8 |
9 . "$(dirname $0)/../common.sh" | 9 . "$(dirname $0)/../common.sh" |
10 . "$(dirname $0)/../lib/cros_vm_lib.sh" | 10 . "$(dirname $0)/../lib/cros_vm_lib.sh" |
11 . "$(dirname "$0")/../lib/cros_vm_constants.sh" | 11 . "$(dirname "$0")/../lib/cros_vm_constants.sh" |
12 | 12 |
13 MAX_RETRIES=3 | 13 MAX_RETRIES=3 |
14 | 14 |
15 get_default_board | 15 get_default_board |
16 | 16 |
17 DEFINE_string board "$DEFAULT_BOARD" \ | 17 DEFINE_string board "$DEFAULT_BOARD" \ |
18 "The board for which you built autotest." | 18 "The board for which you built autotest." |
19 DEFINE_string image_path "" "Full path of the VM image" | 19 DEFINE_string image_path "" "Full path of the VM image" |
20 DEFINE_string results_dir_root "" "alternate root results directory" | 20 DEFINE_string results_dir_root "" "alternate root results directory" |
21 DEFINE_string test_case "" "Name of the test case to run" | 21 DEFINE_string test_case "" "Name of the test case to run" |
22 | 22 |
23 set -e | 23 set -e |
24 | 24 |
25 # Parse command line. | 25 # Parse command line. |
26 FLAGS "$@" || exit 1 | 26 FLAGS "$@" || exit 1 |
27 eval set -- "${FLAGS_ARGV}" | |
28 | 27 |
29 # Use latest if not specified. | 28 # Use latest if not specified. |
30 if [ -z "${FLAGS_image_path}" ]; then | 29 if [ -z "${FLAGS_image_path}" ]; then |
31 LATEST_IMAGE="$(${SCRIPTS_DIR}/get_latest_image.sh \ | 30 LATEST_IMAGE="$(${SCRIPTS_DIR}/get_latest_image.sh \ |
32 --board=${FLAGS_board})/${DEFAULT_QEMU_IMAGE}" | 31 --board=${FLAGS_board})/${DEFAULT_QEMU_IMAGE}" |
33 info "Using latest vm image ${LATEST_IMAGE}" | 32 info "Using latest vm image ${LATEST_IMAGE}" |
34 FLAGS_image_path=${LATEST_IMAGE} | 33 FLAGS_image_path=${LATEST_IMAGE} |
35 fi | 34 fi |
36 | 35 |
37 [ -e "${FLAGS_image_path}" ] || die "Image ${FLAGS_image_path} does not exist." | 36 [ -e "${FLAGS_image_path}" ] || die "Image ${FLAGS_image_path} does not exist." |
38 | 37 |
39 [ -n "${FLAGS_test_case}" ] || die "You must specify a test case." | 38 if [ -n "${FLAGS_test_case}" ]; then |
| 39 warn "Use of --test_case=<test> is being deprecated. Just pass test names \ |
| 40 as separate command line arguments." |
| 41 fi |
| 42 |
| 43 if [ -z "${FLAGS_test_case}" ] && [ -z "${FLAGS_ARGV}" ]; then |
| 44 die "You must specify a test case." |
| 45 fi |
| 46 |
| 47 tests=( ) |
| 48 [ -n "${FLAGS_test_case}" ] && tests=( "${FLAGS_test_case}" ) |
| 49 for test in ${FLAGS_ARGV}; do |
| 50 tests=( "${tests[@]}" "$(remove_quotes "${test}")" ) |
| 51 done |
40 | 52 |
41 trap stop_kvm EXIT | 53 trap stop_kvm EXIT |
42 start_kvm "${FLAGS_image_path}" | 54 start_kvm "${FLAGS_image_path}" |
43 info "Checking for ssh access to virtual machine." | 55 info "Checking for ssh access to virtual machine." |
44 retry_until_ssh ${MAX_RETRIES} | 56 retry_until_ssh ${MAX_RETRIES} |
45 "$(dirname $0)"/../run_remote_tests.sh \ | 57 "$(dirname $0)"/../run_remote_tests.sh \ |
46 --board=${FLAGS_board} \ | 58 --board=${FLAGS_board} \ |
47 --ssh_port=${FLAGS_ssh_port} \ | 59 --ssh_port=${FLAGS_ssh_port} \ |
48 --remote=127.0.0.1 \ | 60 --remote=127.0.0.1 \ |
49 --results_dir_root="${FLAGS_results_dir_root}" \ | 61 --results_dir_root="${FLAGS_results_dir_root}" \ |
50 "${FLAGS_test_case}" | 62 "${tests[@]}" |
OLD | NEW |