From 4f60880414f8d9a8fb682d680bd8a7ba30910bbe Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 6 Apr 2021 20:49:48 +1000 Subject: [PATCH] agent/device: Update test_get_device_name() The current test_get_device_name(), ported from Kata 1.x doesn't really reflect how the function is used in practice. The example path appears to be for a virtio-blk device, but it's an s390 specific variant, not a PCI device. The s390 form isn't actually supported by any of the existing users of get_device_name(). Change it to a plausible virtio-blk-pci style path to better test how get_device_name() will actually be used in practice. Signed-off-by: David Gibson --- src/agent/src/device.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/agent/src/device.rs b/src/agent/src/device.rs index e08f91cc4..8ce34a64d 100644 --- a/src/agent/src/device.rs +++ b/src/agent/src/device.rs @@ -780,8 +780,9 @@ mod tests { #[tokio::test] async fn test_get_device_name() { let devname = "vda"; - let busid = "0.0.0005"; - let devpath = format!("/dev/ces/css0/0.0.0004/{}/virtio4/block/{}", busid, devname); + let root_bus = create_pci_root_bus_path(); + let relpath = "/0000:00:0a.0/0000:03:0b.0"; + let devpath = format!("{}{}/virtio4/block/{}", root_bus, relpath, devname); let logger = slog::Logger::root(slog::Discard, o!()); let sandbox = Arc::new(Mutex::new(Sandbox::new(&logger).unwrap())); @@ -791,7 +792,7 @@ mod tests { .insert(devpath.clone(), devname.to_string()); drop(sb); // unlock - let name = get_device_name(&sandbox, busid).await; + let name = get_device_name(&sandbox, relpath).await; assert!(name.is_ok(), "{}", name.unwrap_err()); assert_eq!(name.unwrap(), format!("{}/{}", SYSTEM_DEV_PATH, devname)); @@ -817,7 +818,7 @@ mod tests { } }); - let name = get_device_name(&sandbox, busid).await; + let name = get_device_name(&sandbox, relpath).await; assert!(name.is_ok(), "{}", name.unwrap_err()); assert_eq!(name.unwrap(), format!("{}/{}", SYSTEM_DEV_PATH, devname)); }