mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-04 19:11:11 +00:00
vmm: config: Add RNG parsing unit test
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
057e71d266
commit
708dbb973a
@ -717,7 +717,7 @@ impl RngConfig {
|
||||
// Split the parameters based on the comma delimiter
|
||||
let params_list: Vec<&str> = rng.split(',').collect();
|
||||
|
||||
let mut src_str: &str = "";
|
||||
let mut src_str: &str = DEFAULT_RNG_SOURCE;
|
||||
let mut iommu_str: &str = "";
|
||||
|
||||
for param in params_list.iter() {
|
||||
@ -1485,4 +1485,31 @@ mod tests {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_rng() -> Result<()> {
|
||||
assert_eq!(RngConfig::parse("")?, RngConfig::default());
|
||||
assert_eq!(
|
||||
RngConfig::parse("src=/dev/random")?,
|
||||
RngConfig {
|
||||
src: PathBuf::from("/dev/random"),
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
RngConfig::parse("src=/dev/random,iommu=on")?,
|
||||
RngConfig {
|
||||
src: PathBuf::from("/dev/random"),
|
||||
iommu: true,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
RngConfig::parse("iommu=on")?,
|
||||
RngConfig {
|
||||
iommu: true,
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user