Skip to content

Commit 6bdce02

Browse files
committed
chore: remove tests with invalid fds as Rust hates those
Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent c595dd7 commit 6bdce02

File tree

1 file changed

+0
-29
lines changed
  • src/vmm/src/devices/virtio/block/virtio/io

1 file changed

+0
-29
lines changed

src/vmm/src/devices/virtio/block/virtio/io/mod.rs

-29
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ impl<T: Debug> FileEngine<T> {
187187
pub mod tests {
188188
#![allow(clippy::undocumented_unsafe_blocks)]
189189
use std::os::unix::ffi::OsStrExt;
190-
use std::os::unix::io::FromRawFd;
191190

192191
use vmm_sys_util::tempfile::TempFile;
193192

@@ -201,20 +200,6 @@ pub mod tests {
201200
// 2 pages of memory should be enough to test read/write ops and also dirty tracking.
202201
const MEM_LEN: usize = 8192;
203202

204-
macro_rules! assert_err {
205-
($expression:expr, $($pattern:tt)+) => {
206-
match $expression {
207-
Err(UserDataError {
208-
user_data: _,
209-
error: $($pattern)+,
210-
}) => (),
211-
ref err => {
212-
panic!("expected `{}` but got `{:?}`", stringify!($($pattern)+), err);
213-
}
214-
}
215-
};
216-
}
217-
218203
macro_rules! assert_sync_execution {
219204
($expression:expr, $count:expr) => {
220205
match $expression {
@@ -265,17 +250,7 @@ pub mod tests {
265250

266251
#[test]
267252
fn test_sync() {
268-
// Check invalid file
269253
let mem = create_mem();
270-
let file = unsafe { File::from_raw_fd(-2) };
271-
let mut engine = FileEngine::from_file(file, FileEngineType::Sync).unwrap();
272-
let res = engine.read(0, &mem, GuestAddress(0), 0, ());
273-
assert_err!(res, BlockIoError::Sync(sync_io::SyncIoError::Seek(_e)));
274-
let res = engine.write(0, &mem, GuestAddress(0), 0, ());
275-
assert_err!(res, BlockIoError::Sync(sync_io::SyncIoError::Seek(_e)));
276-
let res = engine.flush(());
277-
assert_err!(res, BlockIoError::Sync(sync_io::SyncIoError::SyncAll(_e)));
278-
279254
// Create backing file.
280255
let file = TempFile::new().unwrap().into_file();
281256
let mut engine = FileEngine::from_file(file, FileEngineType::Sync).unwrap();
@@ -342,10 +317,6 @@ pub mod tests {
342317

343318
#[test]
344319
fn test_async() {
345-
// Check invalid file
346-
let file = unsafe { File::from_raw_fd(-2) };
347-
FileEngine::<()>::from_file(file, FileEngineType::Async).unwrap_err();
348-
349320
// Create backing file.
350321
let file = TempFile::new().unwrap().into_file();
351322
let mut engine = FileEngine::<()>::from_file(file, FileEngineType::Async).unwrap();

0 commit comments

Comments
 (0)