crosvm/e2e_tests/tests/boot.rs
Alexandre Courbot 884ea737c3 e2e_tests: add test for booting a VM from a configuration file
Add `boot_test_vm_config_file`, which boots a VM similar to
`boot_test_vm`, but using a configuration file instead of command-line
options wherever possible.

BUG=b:218223240
TEST=cargo test -p e2e_tests boot_test_vm

Change-Id: I45f82bfa8201776081e18c50011d928d8c7be0f0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4022749
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-11-21 12:00:39 +00:00

35 lines
1 KiB
Rust

// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
pub mod fixture;
use fixture::Config;
use fixture::TestVm;
#[test]
fn boot_test_vm() {
let mut vm = TestVm::new(Config::new()).unwrap();
assert_eq!(vm.exec_in_guest("echo 42").unwrap().trim(), "42");
}
#[test]
fn boot_test_vm_odirect() {
let mut vm = TestVm::new(Config::new().o_direct()).unwrap();
assert_eq!(vm.exec_in_guest("echo 42").unwrap().trim(), "42");
}
#[test]
fn boot_test_vm_config_file() {
let mut vm = TestVm::new_with_config_file(Config::new()).unwrap();
assert_eq!(vm.exec_in_guest("echo 42").unwrap().trim(), "42");
}
#[test]
fn boot_test_suspend_resume() {
// There is no easy way for us to check if the VM is actually suspended. But at
// least exercise the code-path.
let mut vm = TestVm::new(Config::new()).unwrap();
vm.suspend().unwrap();
vm.resume().unwrap();
assert_eq!(vm.exec_in_guest("echo 42").unwrap().trim(), "42");
}