From d359c8cdce68501ccb2c23a2231c3acb3774ed6c Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 29 May 2024 00:03:13 +0000 Subject: [PATCH] virtio-devices: vsock: allow fuzzer to use TestBackend Instead of reinventing this mock infrastructure in the upcoming fuzzer, reuse the one that is already available. However this change makes Clippy complain that TestBackend and TestContext don't implement Default. This is just test code, we can suppress Clippy in this case. Signed-off-by: Wei Liu --- virtio-devices/src/vsock/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/virtio-devices/src/vsock/mod.rs b/virtio-devices/src/vsock/mod.rs index fda49bc07..0ada35f73 100644 --- a/virtio-devices/src/vsock/mod.rs +++ b/virtio-devices/src/vsock/mod.rs @@ -160,8 +160,8 @@ pub trait VsockChannel { /// translates guest-side vsock connections to host-side Unix domain socket connections. pub trait VsockBackend: VsockChannel + VsockEpollListener + Send {} -#[cfg(test)] -mod tests { +#[cfg(any(test, fuzzing))] +pub mod tests { use std::os::unix::io::AsRawFd; use std::path::PathBuf; use std::sync::{Arc, RwLock}; @@ -200,6 +200,7 @@ mod tests { pub evset: Option, } impl TestBackend { + #[allow(clippy::new_without_default)] pub fn new() -> Self { Self { evfd: EventFd::new(EFD_NONBLOCK).unwrap(), @@ -264,6 +265,7 @@ mod tests { } impl TestContext { + #[allow(clippy::new_without_default)] pub fn new() -> Self { const CID: u32 = 52; const MEM_SIZE: usize = 1024 * 1024 * 128;