From 37264cf21bb7cd44aaada19fd46e61c666c4699d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 2 Apr 2020 18:21:04 +0100 Subject: [PATCH] vmm: config: Add unit testing for vsock Signed-off-by: Rob Bradford --- vmm/src/config.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/vmm/src/config.rs b/vmm/src/config.rs index b09020b5c..b97e577e2 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -1682,4 +1682,27 @@ mod tests { Ok(()) } + + #[test] + fn test_vsock_parsing() -> Result<()> { + // sock and cid is required + assert!(VsockConfig::parse("").is_err()); + assert_eq!( + VsockConfig::parse("sock=/tmp/sock,cid=1")?, + VsockConfig { + cid: 1, + sock: PathBuf::from("/tmp/sock"), + iommu: false + } + ); + assert_eq!( + VsockConfig::parse("sock=/tmp/sock,cid=1,iommu=on")?, + VsockConfig { + cid: 1, + sock: PathBuf::from("/tmp/sock"), + iommu: true + } + ); + Ok(()) + } }