mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 11:22:26 +00:00
vmm: config: Add parsing test for pmem
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
13dc637350
commit
233ad78b3a
@ -832,7 +832,7 @@ impl FsConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, Default)]
|
||||||
pub struct PmemConfig {
|
pub struct PmemConfig {
|
||||||
pub file: PathBuf,
|
pub file: PathBuf,
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
@ -1548,4 +1548,33 @@ mod tests {
|
|||||||
assert!(FsConfig::parse("tag=mytag,sock=/tmp/sock,dax=off,cache_size=4G").is_err());
|
assert!(FsConfig::parse("tag=mytag,sock=/tmp/sock,dax=off,cache_size=4G").is_err());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_pmem_parsing() -> Result<()> {
|
||||||
|
// Must always give a file and size
|
||||||
|
assert!(PmemConfig::parse("").is_err());
|
||||||
|
assert!(PmemConfig::parse("file=/tmp/pmem").is_err());
|
||||||
|
assert!(PmemConfig::parse("size=128M").is_err());
|
||||||
|
assert_eq!(
|
||||||
|
PmemConfig::parse("file=/tmp/pmem,size=128M")?,
|
||||||
|
PmemConfig {
|
||||||
|
file: PathBuf::from("/tmp/pmem"),
|
||||||
|
size: 128 << 20,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
PmemConfig::parse("file=/tmp/pmem,size=128M,iommu=on,mergeable=on,discard_writes=on")?,
|
||||||
|
PmemConfig {
|
||||||
|
file: PathBuf::from("/tmp/pmem"),
|
||||||
|
size: 128 << 20,
|
||||||
|
mergeable: true,
|
||||||
|
discard_writes: true,
|
||||||
|
iommu: true,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user