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 <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-04-23 15:33:20 +02:00
committed by Bo Chen
parent 86e4ccecb6
commit 76069a73d6

View File

@@ -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());
}
}