From 1703423a77fd8585db513f11cc5396143e1a1c36 Mon Sep 17 00:00:00 2001 From: Ryan Cairns Date: Mon, 30 Aug 2010 17:03:50 -0700 Subject: [PATCH] Runs our BVT suite in a VM Change-Id: I758c93596d5cbdd6b52b9acc82f4d6e19a326c9f BUG=5518 TEST=Tested using all the options. All tests listed in the file pass. Review URL: http://codereview.chromium.org/3107039 --- bin/cros_run_vm_test | 58 ++++++++++++++++++++++++++++++++++++++++++++ run_remote_tests.sh | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100755 bin/cros_run_vm_test diff --git a/bin/cros_run_vm_test b/bin/cros_run_vm_test new file mode 100755 index 0000000000..82b3b8fcd4 --- /dev/null +++ b/bin/cros_run_vm_test @@ -0,0 +1,58 @@ +#!/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. +# +# Runs a given test case under a VM. + +. "$(dirname $0)/../common.sh" + +DEFINE_string image_path "" "Full path of the VM image" +DEFINE_boolean no_graphics ${FLAGS_FALSE} "Runs the KVM instance silently" +DEFINE_integer ssh_port 9222 "Port to tunnel ssh traffic over" +DEFINE_string test_case "" "Name of the test case to run" + +set -e + +KVM_PID_FILE=/tmp/kvm.$$.pid + +# TODO(rtc): These flags assume that we'll be using KVM on Lucid and won't work +# on Hardy. +function start_kvm { + echo "Starting the KVM instance" + local nographics="" + if [ ${FLAGS_no_graphics} -eq ${FLAGS_TRUE} ]; then + nographics="-nographic" + fi + sudo kvm -m 1024 \ + -vga std \ + -pidfile "${KVM_PID_FILE}" \ + -daemonize \ + -net nic \ + ${nographics} \ + -net user,hostfwd=tcp::${FLAGS_ssh_port}-:22 \ + -hda "${FLAGS_image_path}" +} + +function stop_kvm { + echo "Stopping the KVM instance" + local pid=$(sudo cat "${KVM_PID_FILE}") + echo "Killing ${pid}" + sudo kill ${pid} + sudo rm "${KVM_PID_FILE}" +} + +# Parse command line +FLAGS "$@" || exit 1 +eval set -- "${FLAGS_ARGV}" + +[ -n "${FLAGS_image_path}" ] || die "You must specify a path to an image" +[ -n "${FLAGS_test_case}" ] || die "You must specify a test case" + +trap stop_kvm EXIT +start_kvm +"$(dirname $0)"/../run_remote_tests.sh \ + --ssh_port=${FLAGS_ssh_port} \ + --remote="${HOSTNAME}" \ + "${FLAGS_test_case}" diff --git a/run_remote_tests.sh b/run_remote_tests.sh index 9d3fa36d0e..abcdc742ef 100755 --- a/run_remote_tests.sh +++ b/run_remote_tests.sh @@ -286,7 +286,7 @@ function main() { echo "" echo_color "yellow" ">>> Test results:" - $(dirname "$0")/generate_test_report "${TMP}" --strip="${TMP}/" + ./generate_test_report "${TMP}" --strip="${TMP}/" } main $@