diff --git a/vhost/src/vhost_user/frontend_req_handler.rs b/vhost/src/vhost_user/frontend_req_handler.rs index f6d0a816..e80692f0 100644 --- a/vhost/src/vhost_user/frontend_req_handler.rs +++ b/vhost/src/vhost_user/frontend_req_handler.rs @@ -396,6 +396,7 @@ mod tests { use super::*; use std::collections::HashSet; + use std::io::ErrorKind; use uuid::Uuid; @@ -449,6 +450,72 @@ mod tests { } } + #[test] + fn test_default_frontend_impl() { + struct Frontend; + impl VhostUserFrontendReqHandler for Frontend {} + + let f = Frontend; + assert_eq!( + f.shared_object_add(&Default::default()).unwrap_err().kind(), + ErrorKind::Unsupported + ); + assert_eq!( + f.shared_object_remove(&Default::default()) + .unwrap_err() + .kind(), + ErrorKind::Unsupported + ); + assert_eq!( + f.shared_object_lookup(&Default::default(), &0) + .unwrap_err() + .kind(), + ErrorKind::Unsupported + ); + + assert_eq!( + f.shmem_map(&Default::default(), &0).unwrap_err().kind(), + ErrorKind::Unsupported + ); + assert_eq!( + f.shmem_unmap(&Default::default()).unwrap_err().kind(), + ErrorKind::Unsupported + ); + } + + #[test] + fn test_default_frontend_impl_mut() { + struct FrontendMut; + impl VhostUserFrontendReqHandlerMut for FrontendMut {} + + let mut f = FrontendMut; + assert_eq!( + f.shared_object_add(&Default::default()).unwrap_err().kind(), + ErrorKind::Unsupported + ); + assert_eq!( + f.shared_object_remove(&Default::default()) + .unwrap_err() + .kind(), + ErrorKind::Unsupported + ); + assert_eq!( + f.shared_object_lookup(&Default::default(), &0) + .unwrap_err() + .kind(), + ErrorKind::Unsupported + ); + + assert_eq!( + f.shmem_map(&Default::default(), &0).unwrap_err().kind(), + ErrorKind::Unsupported + ); + assert_eq!( + f.shmem_unmap(&Default::default()).unwrap_err().kind(), + ErrorKind::Unsupported + ); + } + #[test] fn test_new_frontend_req_handler() { let backend = Arc::new(Mutex::new(MockFrontendReqHandler::new()));