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 |
| 14 |
13 DEFINE_string image_path "" "Full path of the VM image" | 15 DEFINE_string image_path "" "Full path of the VM image" |
14 DEFINE_string test_case "" "Name of the test case to run" | 16 DEFINE_string test_case "" "Name of the test case to run" |
15 | 17 |
16 set -e | 18 set -e |
17 | 19 |
18 # Parse command line. | 20 # Parse command line. |
19 FLAGS "$@" || exit 1 | 21 FLAGS "$@" || exit 1 |
20 eval set -- "${FLAGS_ARGV}" | 22 eval set -- "${FLAGS_ARGV}" |
21 | 23 |
22 # Use latest if not specified. | 24 # Use latest if not specified. |
23 if [ -z "${FLAGS_image_path}" ]; then | 25 if [ -z "${FLAGS_image_path}" ]; then |
24 LATEST_IMAGE="$(${SCRIPTS_DIR}/get_latest_image.sh)/${DEFAULT_QEMU_IMAGE}" | 26 LATEST_IMAGE="$(${SCRIPTS_DIR}/get_latest_image.sh)/${DEFAULT_QEMU_IMAGE}" |
25 info "Using latest vm image ${LATEST_IMAGE}" | 27 info "Using latest vm image ${LATEST_IMAGE}" |
26 FLAGS_image_path=${LATEST_IMAGE} | 28 FLAGS_image_path=${LATEST_IMAGE} |
27 fi | 29 fi |
28 | 30 |
29 [ -e "${FLAGS_image_path}" ] || die "Image ${FLAGS_image_path} does not exist." | 31 [ -e "${FLAGS_image_path}" ] || die "Image ${FLAGS_image_path} does not exist." |
30 | 32 |
31 [ -n "${FLAGS_test_case}" ] || die "You must specify a test case." | 33 [ -n "${FLAGS_test_case}" ] || die "You must specify a test case." |
32 | 34 |
33 trap stop_kvm EXIT | 35 trap stop_kvm EXIT |
34 start_kvm "${FLAGS_image_path}" | 36 start_kvm "${FLAGS_image_path}" |
| 37 info "Checking for ssh access to virtual machine." |
| 38 retry_until_ssh ${MAX_RETRIES} |
35 "$(dirname $0)"/../run_remote_tests.sh \ | 39 "$(dirname $0)"/../run_remote_tests.sh \ |
36 --ssh_port=${FLAGS_ssh_port} \ | 40 --ssh_port=${FLAGS_ssh_port} \ |
37 --remote=127.0.0.1 \ | 41 --remote=127.0.0.1 \ |
38 "${FLAGS_test_case}" | 42 "${FLAGS_test_case}" |
OLD | NEW |