Chromium Code Reviews| Index: bin/cros_run_vm_test |
| diff --git a/bin/cros_run_vm_test b/bin/cros_run_vm_test |
| index d62a2b98524fadc489971677df2df893e1be18bc..968e74a92f02619dca16681a80f1a4a2c7cf7e90 100755 |
| --- a/bin/cros_run_vm_test |
| +++ b/bin/cros_run_vm_test |
| @@ -23,6 +23,10 @@ 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." |
| +DEFINE_boolean save_vm_state ${FLAGS_FALSE} \ |
|
sosa
2010/11/20 08:55:08
Sort in alphabetical order
thieule
2010/11/24 00:51:34
Done.
|
| + "Save the state of the VM when a test fails" |
| +DEFINE_string save_vm_state_file ${DEFAULT_QEMU_COW_IMAGE} \ |
| + "Name of file to save VM state into if test fails" |
| set -e |
| @@ -54,6 +58,16 @@ if [ -z "${FLAGS_test_case}" ] && [ -z "${FLAGS_ARGV}" ]; then |
| die "You must specify a test case." |
| fi |
| +if [ ${FLAGS_save_vm_state} -eq ${FLAGS_TRUE} ] && |
| + [ ${FLAGS_snapshot} -eq ${FLAGS_TRUE} ]; then |
| + die "You cannot set both --snapshot and --save_vm_state." |
| +fi |
| + |
| +if [ ${FLAGS_save_vm_state} -eq ${FLAGS_TRUE} ] && |
| + [ -z ${FLAGS_save_vm_state_file} ]; then |
| + die "You must specify a save_vm_state_file." |
| +fi |
| + |
| USE_EMERGED= |
| if [[ ${FLAGS_use_emerged} -eq ${FLAGS_TRUE} ]]; then |
| USE_EMERGED="--use_emerged" |
| @@ -65,6 +79,15 @@ for test in ${FLAGS_ARGV}; do |
| tests=( "${tests[@]}" "$(remove_quotes "${test}")" ) |
| done |
| +# Create a copy-on-write qcow2 file that is based off the default QEMU image |
| +# so that we can save state information into it. |
| +if [ ${FLAGS_save_vm_state} -eq ${FLAGS_TRUE} ]; then |
| + QEMU_COW_IMAGE="$(${SCRIPTS_DIR}/get_latest_image.sh \ |
| + --board=${FLAGS_board})/${FLAGS_save_vm_state_file}" |
| + qemu-img create -f qcow2 -b ${LATEST_IMAGE} ${QEMU_COW_IMAGE} |
| + FLAGS_image_path=${QEMU_COW_IMAGE} |
| +fi |
| + |
| trap stop_kvm EXIT |
| start_kvm "${FLAGS_image_path}" |
| info "Checking for ssh access to virtual machine." |