block: factory: Add test for sync fallback

Verify that open_disk() falls back to synchronous backend when both
io_uring and AIO are disabled, and that the returned disk reports
the correct logical size.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-04-21 21:39:29 +02:00
committed by Rob Bradford
parent 37693aa141
commit 03a5c29c48

View File

@@ -262,4 +262,24 @@ mod unit_tests {
let opened = open_disk(&options).unwrap();
assert_eq!(opened.image_type, ImageType::Raw);
}
#[test]
fn sync_fallback_when_async_disabled() {
let tmp = TempFile::new().unwrap();
let size = 1u64 << 20;
tmp.as_file().set_len(size).unwrap();
let path = tmp.as_path().to_owned();
let options = DiskOpenOptions {
path: &path,
readonly: false,
direct: false,
sparse: false,
backing_files: false,
disable_io_uring: true,
disable_aio: true,
};
let opened = open_disk(&options).unwrap();
assert_eq!(opened.image_type, ImageType::Raw);
assert_eq!(opened.disk.logical_size().unwrap(), size);
}
}