Add option to check version of Chrome on target.

Change-Id: I34e9d64656e04d4f5c477914512219d9b8563b78

BUG=chromium-os:9137
TEST=Ran with both wrong and right versions against a Google Chrome and
Chromium build

Review URL: http://codereview.chromium.org/4942001
This commit is contained in:
Chris Sosa 2010-11-15 15:12:06 -08:00
parent b94e40293d
commit 4e75efa930
2 changed files with 53 additions and 6 deletions

25
bin/cros_get_chrome_version Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Returns the version of Chrome running on a remote machine.
. "$(dirname $0)/../common.sh"
. "$(dirname $0)/../remote_access.sh"
FLAGS "$@" || exit 1
set -e
# TMP necessary for remote_access_init.
TMP=$(mktemp -d /tmp/cros_check_chrome_version.XXXX)
trap "rm -rf ${TMP}" EXIT
remote_access_init &> /dev/null
remote_sh "/opt/google/chrome/chrome --version"
CHROME_VERSION=$(echo ${REMOTE_OUT} | \
sed 's/.* \([0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+\).*/\1/')
echo "${CHROME_VERSION}"

View File

@ -21,9 +21,17 @@ DEFINE_string results_dir_root "" "alternate root results directory"
DEFINE_string test_case "" "Name of the test case to run" DEFINE_string test_case "" "Name of the test case to run"
DEFINE_boolean use_emerged ${FLAGS_FALSE} \ DEFINE_boolean use_emerged ${FLAGS_FALSE} \
"Force use of emerged autotest packages" "Force use of emerged autotest packages"
DEFINE_string verify_chrome_version "" \
"Verify that this chrome version matches that on vm."
set -e set -e
# Returns normally if the given $1 is a valid chrome version.
chrome_version_is_valid() {
local chrome_version="$1"
echo ${chrome_version} | egrep '^[0-9]+.[0-9]+.[0-9]+.[0-9]+$' &> /dev/null
}
# Parse command line. # Parse command line.
FLAGS "$@" || exit 1 FLAGS "$@" || exit 1
@ -61,10 +69,24 @@ trap stop_kvm EXIT
start_kvm "${FLAGS_image_path}" start_kvm "${FLAGS_image_path}"
info "Checking for ssh access to virtual machine." info "Checking for ssh access to virtual machine."
retry_until_ssh ${MAX_RETRIES} retry_until_ssh ${MAX_RETRIES}
if [ -n "${FLAGS_verify_chrome_version}" ]; then
info "Verifying version of Chrome matches what we expect."
if chrome_version_is_valid "${FLAGS_verify_chrome_version}"; then
chrome_version_on_vm=$("$(dirname $0)/cros_get_chrome_version" \
--remote=127.0.0.1 \
--ssh_port=${FLAGS_ssh_port})
[[ ${chrome_version_on_vm} == ${FLAGS_verify_chrome_version} ]] || \
die "Chrome version mismatch. VM reported ${chrome_version_on_vm}"
else
warn "${FLAGS_verify_chrome_version} is not a valid Chrome version"
fi
fi
"$(dirname $0)"/../run_remote_tests.sh \ "$(dirname $0)"/../run_remote_tests.sh \
--board=${FLAGS_board} \ --board=${FLAGS_board} \
--ssh_port=${FLAGS_ssh_port} \ --ssh_port=${FLAGS_ssh_port} \
--remote=127.0.0.1 \ --remote=127.0.0.1 \
--results_dir_root="${FLAGS_results_dir_root}" \ --results_dir_root="${FLAGS_results_dir_root}" \
${USE_EMERGED} \ ${USE_EMERGED} \
"${tests[@]}" "${tests[@]}"