Skip to content

Commit

Permalink
chore: remove tests with invalid fds as Rust hates those
Browse files Browse the repository at this point in the history
Signed-off-by: Egor Lazarchuk <[email protected]>
  • Loading branch information
ShadowCurse committed Nov 28, 2024
1 parent c595dd7 commit 6bdce02
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions src/vmm/src/devices/virtio/block/virtio/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ impl<T: Debug> FileEngine<T> {
pub mod tests {
#![allow(clippy::undocumented_unsafe_blocks)]
use std::os::unix::ffi::OsStrExt;
use std::os::unix::io::FromRawFd;

use vmm_sys_util::tempfile::TempFile;

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

macro_rules! assert_err {
($expression:expr, $($pattern:tt)+) => {
match $expression {
Err(UserDataError {
user_data: _,
error: $($pattern)+,
}) => (),
ref err => {
panic!("expected `{}` but got `{:?}`", stringify!($($pattern)+), err);
}
}
};
}

macro_rules! assert_sync_execution {
($expression:expr, $count:expr) => {
match $expression {
Expand Down Expand Up @@ -265,17 +250,7 @@ pub mod tests {

#[test]
fn test_sync() {
// Check invalid file
let mem = create_mem();
let file = unsafe { File::from_raw_fd(-2) };
let mut engine = FileEngine::from_file(file, FileEngineType::Sync).unwrap();
let res = engine.read(0, &mem, GuestAddress(0), 0, ());
assert_err!(res, BlockIoError::Sync(sync_io::SyncIoError::Seek(_e)));
let res = engine.write(0, &mem, GuestAddress(0), 0, ());
assert_err!(res, BlockIoError::Sync(sync_io::SyncIoError::Seek(_e)));
let res = engine.flush(());
assert_err!(res, BlockIoError::Sync(sync_io::SyncIoError::SyncAll(_e)));

// Create backing file.
let file = TempFile::new().unwrap().into_file();
let mut engine = FileEngine::from_file(file, FileEngineType::Sync).unwrap();
Expand Down Expand Up @@ -342,10 +317,6 @@ pub mod tests {

#[test]
fn test_async() {
// Check invalid file
let file = unsafe { File::from_raw_fd(-2) };
FileEngine::<()>::from_file(file, FileEngineType::Async).unwrap_err();

// Create backing file.
let file = TempFile::new().unwrap().into_file();
let mut engine = FileEngine::<()>::from_file(file, FileEngineType::Async).unwrap();
Expand Down

0 comments on commit 6bdce02

Please sign in to comment.