From 9e6a2825bae5300f2024b0510c496c75b4912b04 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 27 Mar 2020 12:30:13 +0000 Subject: [PATCH] vmm: config: Add unit test for CPU parsing Signed-off-by: Rob Bradford --- vmm/src/config.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/vmm/src/config.rs b/vmm/src/config.rs index bb17f0f8f..933c6ad41 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -1296,4 +1296,26 @@ mod tests { assert!(parser.is_set("size")); Ok(()) } + + #[test] + fn test_cpu_parsing() -> Result<()> { + assert_eq!(CpusConfig::parse("")?, CpusConfig::default()); + + assert_eq!( + CpusConfig::parse("boot=1")?, + CpusConfig { + boot_vcpus: 1, + max_vcpus: 1 + } + ); + assert_eq!( + CpusConfig::parse("boot=1,max=2")?, + CpusConfig { + boot_vcpus: 1, + max_vcpus: 2, + } + ); + assert!(CpusConfig::parse("boot=2,max=1").is_err()); + Ok(()) + } }