mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-04 19:11:11 +00:00
vmm: config: Add unit test for console parsing
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
5ab58e743a
commit
143d63c88e
@ -1585,4 +1585,59 @@ mod tests {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_console_parsing() -> Result<()> {
|
||||
assert!(ConsoleConfig::parse("").is_err());
|
||||
assert!(ConsoleConfig::parse("badmode").is_err());
|
||||
assert_eq!(
|
||||
ConsoleConfig::parse("off")?,
|
||||
ConsoleConfig {
|
||||
mode: ConsoleOutputMode::Off,
|
||||
iommu: false,
|
||||
file: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
ConsoleConfig::parse("tty")?,
|
||||
ConsoleConfig {
|
||||
mode: ConsoleOutputMode::Tty,
|
||||
iommu: false,
|
||||
file: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
ConsoleConfig::parse("null")?,
|
||||
ConsoleConfig {
|
||||
mode: ConsoleOutputMode::Null,
|
||||
iommu: false,
|
||||
file: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
ConsoleConfig::parse("file=/tmp/console")?,
|
||||
ConsoleConfig {
|
||||
mode: ConsoleOutputMode::File,
|
||||
iommu: false,
|
||||
file: Some(PathBuf::from("/tmp/console"))
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
ConsoleConfig::parse("null,iommu=on")?,
|
||||
ConsoleConfig {
|
||||
mode: ConsoleOutputMode::Null,
|
||||
iommu: true,
|
||||
file: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
ConsoleConfig::parse("file=/tmp/console,iommu=on")?,
|
||||
ConsoleConfig {
|
||||
mode: ConsoleOutputMode::File,
|
||||
iommu: true,
|
||||
file: Some(PathBuf::from("/tmp/console"))
|
||||
}
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user