tests: Make the test_virtio_pmem test use a temporary file

Rather than using a raw OS disk image. This will be useful when the test
is extended to doing I/O on the image.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-03-19 10:48:17 +00:00 committed by Sebastien Boeuf
parent f7197e8415
commit 70986022d8
3 changed files with 8 additions and 2 deletions

1
Cargo.lock generated
View File

@ -168,6 +168,7 @@ dependencies = [
"serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
"ssh2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vhost 0.1.0 (git+https://github.com/cloud-hypervisor/vhost?branch=dragonball)",
"vhost_user_backend 0.1.0",
"vhost_user_block 0.1.0",

View File

@ -33,6 +33,7 @@ dirs = "2.0.2"
credibility = "0.1.3"
tempdir= "0.3.7"
lazy_static= "1.4.0"
tempfile = "3.1.0"
[features]
default = ["acpi", "pci", "cmos"]

View File

@ -30,6 +30,7 @@ mod tests {
use std::sync::Mutex;
use std::thread;
use tempdir::TempDir;
use tempfile::NamedTempFile;
lazy_static! {
static ref NEXT_VM_ID: Mutex<u8> = Mutex::new(1);
@ -1937,6 +1938,9 @@ mod tests {
let mut kernel_path = workload_path;
kernel_path.push("vmlinux");
let mut pmem_temp_file = NamedTempFile::new().unwrap();
pmem_temp_file.as_file_mut().set_len(128 << 20).unwrap();
let mut child = GuestCommand::new(&guest)
.args(&["--cpus","boot=1"])
.args(&["--memory", "size=512M"])
@ -1947,8 +1951,8 @@ mod tests {
"--pmem",
format!(
"file={},size={}",
guest.disk_config.disk(DiskType::RawOperatingSystem).unwrap(),
fs::metadata(&guest.disk_config.disk(DiskType::RawOperatingSystem).unwrap()).unwrap().len()
pmem_temp_file.path().to_str().unwrap(),
"128M",
)
.as_str(),
])