mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: checked_descriptor: Add unit test for next_checked success
Cover the success path of the DescriptorChainExt::next_checked trait method, asserting that a valid single descriptor is returned as Ok(Some(_)) with the expected addr and len. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
d345118854
commit
be432bda07
@@ -300,4 +300,17 @@ mod unit_tests {
|
||||
second.unwrap_err();
|
||||
assert!(it.next().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn next_checked_returns_valid_descriptor() {
|
||||
let (_mem, mem_atomic, mut queue) = setup_vq(128 * 1024, 0x4000, 256, 0);
|
||||
let mem_guard = mem_atomic.memory();
|
||||
let mut chain = queue.pop_descriptor_chain(mem_guard).unwrap();
|
||||
let desc = chain
|
||||
.next_checked(None)
|
||||
.expect("validation must succeed")
|
||||
.expect("descriptor must be present");
|
||||
assert_eq!(desc.addr().0, 0x4000);
|
||||
assert_eq!(desc.len(), 256);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user