From 76069a73d6c64722abbbe40b98959ffa3141f6fd Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 23 Apr 2026 15:33:20 +0200 Subject: [PATCH] block: raw: Add physical size test Verify that physical size of a sparse file is less than logical size. Assisted-by: Claude:Opus-4.6 Signed-off-by: Anatol Belski --- block/src/raw_disk.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/src/raw_disk.rs b/block/src/raw_disk.rs index 616c6d983..a6d3eab5c 100644 --- a/block/src/raw_disk.rs +++ b/block/src/raw_disk.rs @@ -151,7 +151,7 @@ mod unit_tests { use super::*; use crate::async_io::AsyncIo; - use crate::disk_file::{AsyncDiskFile, DiskSize, Resizable}; + use crate::disk_file::{AsyncDiskFile, DiskSize, PhysicalSize, Resizable}; const TEST_SIZE: u64 = 0x1122_3344; @@ -249,4 +249,12 @@ mod unit_tests { disk.resize(new_size).unwrap(); assert_eq!(disk.logical_size().unwrap(), new_size); } + + #[test] + fn physical_size_reports_allocated_blocks() { + let file = make_raw_file(); + let disk = RawDisk::new(file, RawBackend::Aio); + // Sparse file: physical size is less than logical size. + assert!(disk.physical_size().unwrap() < disk.logical_size().unwrap()); + } }