Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: bin/cros_run_vm_test

Issue 4942001: Add option to check version of Chrome on target. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Change name Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bin/cros_get_chrome_version ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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." b 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} \ 22 DEFINE_boolean use_emerged ${FLAGS_FALSE} \
23 "Force use of emerged autotest packages" 23 "Force use of emerged autotest packages"
24 DEFINE_string verify_chrome_version "" \
25 "Verify that this chrome version matches that on vm."
24 26
25 set -e 27 set -e
26 28
29 # Returns normally if the given $1 is a valid chrome version.
30 chrome_version_is_valid() {
31 local chrome_version="$1"
32 echo ${chrome_version} | egrep '^[0-9]+.[0-9]+.[0-9]+.[0-9]+$' &> /dev/null
33 }
34
27 # Parse command line. 35 # Parse command line.
28 FLAGS "$@" || exit 1 36 FLAGS "$@" || exit 1
29 37
30 # Use latest if not specified. 38 # Use latest if not specified.
31 if [ -z "${FLAGS_image_path}" ]; then 39 if [ -z "${FLAGS_image_path}" ]; then
32 LATEST_IMAGE="$(${SCRIPTS_DIR}/get_latest_image.sh \ 40 LATEST_IMAGE="$(${SCRIPTS_DIR}/get_latest_image.sh \
33 --board=${FLAGS_board})/${DEFAULT_QEMU_IMAGE}" 41 --board=${FLAGS_board})/${DEFAULT_QEMU_IMAGE}"
34 info "Using latest vm image ${LATEST_IMAGE}" 42 info "Using latest vm image ${LATEST_IMAGE}"
35 FLAGS_image_path=${LATEST_IMAGE} 43 FLAGS_image_path=${LATEST_IMAGE}
36 fi 44 fi
(...skipping 17 matching lines...) Expand all
54 tests=( ) 62 tests=( )
55 [ -n "${FLAGS_test_case}" ] && tests=( "${FLAGS_test_case}" ) 63 [ -n "${FLAGS_test_case}" ] && tests=( "${FLAGS_test_case}" )
56 for test in ${FLAGS_ARGV}; do 64 for test in ${FLAGS_ARGV}; do
57 tests=( "${tests[@]}" "$(remove_quotes "${test}")" ) 65 tests=( "${tests[@]}" "$(remove_quotes "${test}")" )
58 done 66 done
59 67
60 trap stop_kvm EXIT 68 trap stop_kvm EXIT
61 start_kvm "${FLAGS_image_path}" 69 start_kvm "${FLAGS_image_path}"
62 info "Checking for ssh access to virtual machine." 70 info "Checking for ssh access to virtual machine."
63 retry_until_ssh ${MAX_RETRIES} 71 retry_until_ssh ${MAX_RETRIES}
72
73 if [ -n "${FLAGS_verify_chrome_version}" ]; then
74 info "Verifying version of Chrome matches what we expect."
75 if chrome_version_is_valid "${FLAGS_verify_chrome_version}"; then
76 chrome_version_on_vm=$("$(dirname $0)/cros_get_chrome_version" \
77 --remote=127.0.0.1 \
78 --ssh_port=${FLAGS_ssh_port})
79 [[ ${chrome_version_on_vm} == ${FLAGS_verify_chrome_version} ]] || \
80 die "Chrome version mismatch. VM reported ${chrome_version_on_vm}"
81 else
82 warn "${FLAGS_verify_chrome_version} is not a valid Chrome version"
83 fi
84 fi
85
64 "$(dirname $0)"/../run_remote_tests.sh \ 86 "$(dirname $0)"/../run_remote_tests.sh \
65 --board=${FLAGS_board} \ 87 --board=${FLAGS_board} \
66 --ssh_port=${FLAGS_ssh_port} \ 88 --ssh_port=${FLAGS_ssh_port} \
67 --remote=127.0.0.1 \ 89 --remote=127.0.0.1 \
68 --results_dir_root="${FLAGS_results_dir_root}" \ 90 --results_dir_root="${FLAGS_results_dir_root}" \
69 ${USE_EMERGED} \ 91 ${USE_EMERGED} \
70 "${tests[@]}" 92 "${tests[@]}"
OLDNEW
« no previous file with comments | « bin/cros_get_chrome_version ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698