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." b |
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 DEFINE_boolean use_emerged ${FLAGS_FALSE} \ |
| 23 "Force use of emerged autotest packages" |
22 | 24 |
23 set -e | 25 set -e |
24 | 26 |
25 # Parse command line. | 27 # Parse command line. |
26 FLAGS "$@" || exit 1 | 28 FLAGS "$@" || exit 1 |
27 | 29 |
28 # Use latest if not specified. | 30 # Use latest if not specified. |
29 if [ -z "${FLAGS_image_path}" ]; then | 31 if [ -z "${FLAGS_image_path}" ]; then |
30 LATEST_IMAGE="$(${SCRIPTS_DIR}/get_latest_image.sh \ | 32 LATEST_IMAGE="$(${SCRIPTS_DIR}/get_latest_image.sh \ |
31 --board=${FLAGS_board})/${DEFAULT_QEMU_IMAGE}" | 33 --board=${FLAGS_board})/${DEFAULT_QEMU_IMAGE}" |
32 info "Using latest vm image ${LATEST_IMAGE}" | 34 info "Using latest vm image ${LATEST_IMAGE}" |
33 FLAGS_image_path=${LATEST_IMAGE} | 35 FLAGS_image_path=${LATEST_IMAGE} |
34 fi | 36 fi |
35 | 37 |
36 [ -e "${FLAGS_image_path}" ] || die "Image ${FLAGS_image_path} does not exist." | 38 [ -e "${FLAGS_image_path}" ] || die "Image ${FLAGS_image_path} does not exist." |
37 | 39 |
38 if [ -n "${FLAGS_test_case}" ]; then | 40 if [ -n "${FLAGS_test_case}" ]; then |
39 warn "Use of --test_case=<test> is being deprecated. Just pass test names \ | 41 warn "Use of --test_case=<test> is being deprecated. Just pass test names \ |
40 as separate command line arguments." | 42 as separate command line arguments." |
41 fi | 43 fi |
42 | 44 |
43 if [ -z "${FLAGS_test_case}" ] && [ -z "${FLAGS_ARGV}" ]; then | 45 if [ -z "${FLAGS_test_case}" ] && [ -z "${FLAGS_ARGV}" ]; then |
44 die "You must specify a test case." | 46 die "You must specify a test case." |
45 fi | 47 fi |
46 | 48 |
| 49 USE_EMERGED= |
| 50 if [[ ${FLAGS_use_emerged} -eq ${FLAGS_TRUE} ]]; then |
| 51 USE_EMERGED="--use_emerged" |
| 52 fi |
| 53 |
47 tests=( ) | 54 tests=( ) |
48 [ -n "${FLAGS_test_case}" ] && tests=( "${FLAGS_test_case}" ) | 55 [ -n "${FLAGS_test_case}" ] && tests=( "${FLAGS_test_case}" ) |
49 for test in ${FLAGS_ARGV}; do | 56 for test in ${FLAGS_ARGV}; do |
50 tests=( "${tests[@]}" "$(remove_quotes "${test}")" ) | 57 tests=( "${tests[@]}" "$(remove_quotes "${test}")" ) |
51 done | 58 done |
52 | 59 |
53 trap stop_kvm EXIT | 60 trap stop_kvm EXIT |
54 start_kvm "${FLAGS_image_path}" | 61 start_kvm "${FLAGS_image_path}" |
55 info "Checking for ssh access to virtual machine." | 62 info "Checking for ssh access to virtual machine." |
56 retry_until_ssh ${MAX_RETRIES} | 63 retry_until_ssh ${MAX_RETRIES} |
57 "$(dirname $0)"/../run_remote_tests.sh \ | 64 "$(dirname $0)"/../run_remote_tests.sh \ |
58 --board=${FLAGS_board} \ | 65 --board=${FLAGS_board} \ |
59 --ssh_port=${FLAGS_ssh_port} \ | 66 --ssh_port=${FLAGS_ssh_port} \ |
60 --remote=127.0.0.1 \ | 67 --remote=127.0.0.1 \ |
61 --results_dir_root="${FLAGS_results_dir_root}" \ | 68 --results_dir_root="${FLAGS_results_dir_root}" \ |
| 69 ${USE_EMERGED} \ |
62 "${tests[@]}" | 70 "${tests[@]}" |
OLD | NEW |