virtio-devices: vsock: fix two clippy warnings

The mem_size field is not needed in TestContext. Drop it.

Make sure guest_evvq is read once. Clippy cannot figured out that it was
used.

While at it, add an extra assert for the spurious rxvq event test, too.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2024-04-29 19:13:07 +00:00 committed by Rob Bradford
parent fe704bd44a
commit 862a056105
2 changed files with 2 additions and 2 deletions

View File

@ -782,6 +782,7 @@ mod tests {
let mut epoll_helper = let mut epoll_helper =
EpollHelper::new(&ctx.handler.kill_evt, &ctx.handler.pause_evt).unwrap(); EpollHelper::new(&ctx.handler.kill_evt, &ctx.handler.pause_evt).unwrap();
assert_eq!(ctx.guest_rxvq.used.idx.get(), 0);
assert!( assert!(
ctx.handler.handle_event(&mut epoll_helper, &event).is_err(), ctx.handler.handle_event(&mut epoll_helper, &event).is_err(),
"handle_event() should have failed" "handle_event() should have failed"
@ -802,6 +803,7 @@ mod tests {
let mut epoll_helper = let mut epoll_helper =
EpollHelper::new(&ctx.handler.kill_evt, &ctx.handler.pause_evt).unwrap(); EpollHelper::new(&ctx.handler.kill_evt, &ctx.handler.pause_evt).unwrap();
assert_eq!(ctx.guest_evvq.used.idx.get(), 0);
assert!( assert!(
ctx.handler.handle_event(&mut epoll_helper, &event).is_err(), ctx.handler.handle_event(&mut epoll_helper, &event).is_err(),
"handle_event() should have failed" "handle_event() should have failed"

View File

@ -256,7 +256,6 @@ mod tests {
pub struct TestContext { pub struct TestContext {
pub cid: u64, pub cid: u64,
pub mem: GuestMemoryMmap, pub mem: GuestMemoryMmap,
pub mem_size: usize,
pub device: Vsock<TestBackend>, pub device: Vsock<TestBackend>,
} }
@ -267,7 +266,6 @@ mod tests {
Self { Self {
cid: CID as u64, cid: CID as u64,
mem: GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap(), mem: GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap(),
mem_size: MEM_SIZE,
device: Vsock::new( device: Vsock::new(
String::from("vsock"), String::from("vsock"),
CID, CID,