From 63cc26e1ce90f5d07466f541e087cb94550821ec Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 23 Apr 2026 00:17:06 +0200 Subject: [PATCH] block: vhd: Test that physical size includes footer The physical size of a fixed VHD is the data region plus the 512 byte footer. Verify it differs from the logical size. Assisted-by: Claude:Opus-4.6 Signed-off-by: Anatol Belski --- block/src/fixed_vhd_disk.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/src/fixed_vhd_disk.rs b/block/src/fixed_vhd_disk.rs index f5c6e9547..8a27cdf96 100644 --- a/block/src/fixed_vhd_disk.rs +++ b/block/src/fixed_vhd_disk.rs @@ -125,7 +125,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}; /// Minimal fixed VHD footer (disk type = 2, current_size = 0x11223344). fn fixed_vhd_footer() -> &'static [u8] { @@ -211,4 +211,12 @@ mod unit_tests { let mut disk = FixedVhdDisk::new(file, false).unwrap(); assert!(disk.resize(0x2000_0000).is_err()); } + + #[test] + fn physical_size_includes_footer() { + let file = make_vhd_file(); + let disk = FixedVhdDisk::new(file, false).unwrap(); + // Data region (0x1122_3344) + VHD footer (0x200). + assert_eq!(disk.physical_size().unwrap(), 0x1122_3344 + 0x200); + } }