mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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 <anbelski@linux.microsoft.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user