From 4e75efa9307fa95034df9b492fb35dc94ff3d6f3 Mon Sep 17 00:00:00 2001 From: Chris Sosa Date: Mon, 15 Nov 2010 15:12:06 -0800 Subject: [PATCH] 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 --- bin/cros_get_chrome_version | 25 +++++++++++++++++++++++++ bin/cros_run_vm_test | 34 ++++++++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 6 deletions(-) create mode 100755 bin/cros_get_chrome_version diff --git a/bin/cros_get_chrome_version b/bin/cros_get_chrome_version new file mode 100755 index 0000000000..a29cb3275f --- /dev/null +++ b/bin/cros_get_chrome_version @@ -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}" diff --git a/bin/cros_run_vm_test b/bin/cros_run_vm_test index fbbee23c7c..d62a2b9852 100755 --- a/bin/cros_run_vm_test +++ b/bin/cros_run_vm_test @@ -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_boolean use_emerged ${FLAGS_FALSE} \ "Force use of emerged autotest packages" +DEFINE_string verify_chrome_version "" \ + "Verify that this chrome version matches that on vm." 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. FLAGS "$@" || exit 1 @@ -61,10 +69,24 @@ trap stop_kvm EXIT start_kvm "${FLAGS_image_path}" info "Checking for ssh access to virtual machine." 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 \ - --board=${FLAGS_board} \ - --ssh_port=${FLAGS_ssh_port} \ - --remote=127.0.0.1 \ - --results_dir_root="${FLAGS_results_dir_root}" \ - ${USE_EMERGED} \ - "${tests[@]}" + --board=${FLAGS_board} \ + --ssh_port=${FLAGS_ssh_port} \ + --remote=127.0.0.1 \ + --results_dir_root="${FLAGS_results_dir_root}" \ + ${USE_EMERGED} \ + "${tests[@]}"