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 exhausted chain
After the iterator yields the only descriptor in a chain, the subsequent None must reflect exhaustion rather than a validation failure, so failed and failed_addr stay unset. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
f700b10cfd
commit
43ced114aa
@@ -458,4 +458,16 @@ mod unit_tests {
|
|||||||
// translated one.
|
// translated one.
|
||||||
assert_eq!(result.unwrap_err(), GuestAddress(gva));
|
assert_eq!(result.unwrap_err(), GuestAddress(gva));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn exhausted_chain_returns_none() {
|
||||||
|
// After the iterator yields the only descriptor in the chain, the
|
||||||
|
// subsequent None must reflect exhaustion, not a validation failure.
|
||||||
|
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 mut it = chain.checked_iter(None);
|
||||||
|
it.next().unwrap().unwrap();
|
||||||
|
assert!(it.next().is_none());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user