OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 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 |
| 5 # found in the LICENSE file. |
| 6 # |
| 7 # Runs a given test case under a VM. |
| 8 |
| 9 . "$(dirname $0)/../common.sh" |
| 10 |
| 11 DEFINE_string image_path "" "Full path of the VM image" |
| 12 DEFINE_boolean no_graphics ${FLAGS_FALSE} "Runs the KVM instance silently" |
| 13 DEFINE_integer ssh_port 9222 "Port to tunnel ssh traffic over" |
| 14 DEFINE_string test_case "" "Name of the test case to run" |
| 15 |
| 16 set -e |
| 17 |
| 18 KVM_PID_FILE=/tmp/kvm.$$.pid |
| 19 |
| 20 # TODO(rtc): These flags assume that we'll be using KVM on Lucid and won't work |
| 21 # on Hardy. |
| 22 function start_kvm { |
| 23 echo "Starting the KVM instance" |
| 24 local nographics="" |
| 25 if [ ${FLAGS_no_graphics} -eq ${FLAGS_TRUE} ]; then |
| 26 nographics="-nographic" |
| 27 fi |
| 28 sudo kvm -m 1024 \ |
| 29 -vga std \ |
| 30 -pidfile "${KVM_PID_FILE}" \ |
| 31 -daemonize \ |
| 32 -net nic \ |
| 33 ${nographics} \ |
| 34 -net user,hostfwd=tcp::${FLAGS_ssh_port}-:22 \ |
| 35 -hda "${FLAGS_image_path}" |
| 36 } |
| 37 |
| 38 function stop_kvm { |
| 39 echo "Stopping the KVM instance" |
| 40 local pid=$(sudo cat "${KVM_PID_FILE}") |
| 41 echo "Killing ${pid}" |
| 42 sudo kill ${pid} |
| 43 sudo rm "${KVM_PID_FILE}" |
| 44 } |
| 45 |
| 46 # Parse command line |
| 47 FLAGS "$@" || exit 1 |
| 48 eval set -- "${FLAGS_ARGV}" |
| 49 |
| 50 [ -n "${FLAGS_image_path}" ] || die "You must specify a path to an image" |
| 51 [ -n "${FLAGS_test_case}" ] || die "You must specify a test case" |
| 52 |
| 53 trap stop_kvm EXIT |
| 54 start_kvm |
| 55 "$(dirname $0)"/../run_remote_tests.sh \ |
| 56 --ssh_port=${FLAGS_ssh_port} \ |
| 57 --remote="${HOSTNAME}" \ |
| 58 "${FLAGS_test_case}" |
OLD | NEW |