block: fix cargo test -p block

`RawBackend::IoUring` is only available when `io_uring` feature is
defined.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu
2026-05-09 00:21:23 +00:00
committed by Rob Bradford
parent f7ebb0bedd
commit f67d0569b4
3 changed files with 13 additions and 4 deletions

View File

@@ -33,5 +33,8 @@ vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = { workspace = true }
zstd = "0.13"
[dev-dependencies]
cfg-if = { workspace = true }
[lints]
workspace = true

View File

@@ -170,10 +170,15 @@ mod unit_tests {
fn assert_async_io_from_dyn(disk: &dyn AsyncDiskFile, expect_backend: RawBackend) {
let io: Box<dyn AsyncIo> = disk.create_async_io(128).unwrap();
assert_eq!(
io.batch_requests_enabled(),
expect_backend == RawBackend::IoUring
);
cfg_if::cfg_if! {
if #[cfg(feature = "io_uring")] {
let expected_batch_requests = expect_backend == RawBackend::IoUring;
} else {
let _ = expect_backend;
let expected_batch_requests = false;
}
}
assert_eq!(io.batch_requests_enabled(), expected_batch_requests);
}
fn assert_sync_backend(disk: &RawDisk) {