From 03a5c29c4849815e897db12a0e2f29d78e585f33 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 21 Apr 2026 21:39:29 +0200 Subject: [PATCH] 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 --- block/src/factory.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/block/src/factory.rs b/block/src/factory.rs index 296b9c70c..7bfef6729 100644 --- a/block/src/factory.rs +++ b/block/src/factory.rs @@ -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); + } }