Skip to content

Commit 710c549

Browse files
committed
Update unit tests
MMIO tests: The addresses and IRQs of devices created in `test_attach_...` tests are now slightly different due to the implementation of the CpuContainer. The IRQs are have been increased by 2, and the address has been increased by 0x1000. This occurs because the CPUContainer has 2 IRQs and one MMIO device, which takes up 4K. ACPI Table tests: Test `test_write_acpi_tables_small_memory` was failing due to additional pages being allocated to CpuContainer. This led to the corner case not being reproduced. Values have been changed in order to properly reproduce this corner case. Signed-off-by: James Curtis <[email protected]>
1 parent 9cbec99 commit 710c549

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/vmm/src/acpi/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ pub mod tests {
263263
fn test_write_acpi_table_small_memory() {
264264
let mut vmm = default_vmm();
265265
vmm.guest_memory = arch_mem(
266-
(SYSTEM_MEM_START + SYSTEM_MEM_SIZE - 4096)
266+
(SYSTEM_MEM_START + SYSTEM_MEM_SIZE - 8192)
267267
.try_into()
268268
.unwrap(),
269269
);
@@ -272,15 +272,15 @@ pub mod tests {
272272
resource_allocator: &mut vmm.resource_allocator,
273273
};
274274

275-
let mut sdt = MockSdt(vec![0; usize::try_from(SYSTEM_MEM_SIZE).unwrap()]);
275+
let mut sdt = MockSdt(vec![0; usize::try_from(SYSTEM_MEM_SIZE - 4096).unwrap()]);
276276
let err = writer.write_acpi_table(&mut sdt).unwrap_err();
277277
assert!(
278278
matches!(
279279
err,
280280
AcpiError::AcpiTables(acpi_tables::AcpiError::GuestMemory(
281281
vm_memory::GuestMemoryError::PartialBuffer {
282-
expected: 263168, // SYSTEM_MEM_SIZE
283-
completed: 259072 // SYSTEM_MEM_SIZE - 4096
282+
expected: 259072, // SYSTEM_MEM_SIZE - 4096
283+
completed: 254976 // SYSTEM_MEM_SIZE - 8192
284284
},
285285
))
286286
),

src/vmm/src/builder.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1629,8 +1629,8 @@ pub mod tests {
16291629
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
16301630
assert!(cmdline_contains(
16311631
&cmdline,
1632-
"virtio_mmio.device=4K@0xd0000000:5 virtio_mmio.device=4K@0xd0001000:6 \
1633-
virtio_mmio.device=4K@0xd0002000:7"
1632+
"virtio_mmio.device=4K@0xd0001000:7 virtio_mmio.device=4K@0xd0002000:8 \
1633+
virtio_mmio.device=4K@0xd0003000:9"
16341634
));
16351635
}
16361636

@@ -1725,7 +1725,7 @@ pub mod tests {
17251725
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
17261726
assert!(cmdline_contains(
17271727
&cmdline,
1728-
"virtio_mmio.device=4K@0xd0000000:5"
1728+
"virtio_mmio.device=4K@0xd0001000:7"
17291729
));
17301730
}
17311731

@@ -1742,7 +1742,7 @@ pub mod tests {
17421742
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
17431743
assert!(cmdline_contains(
17441744
&cmdline,
1745-
"virtio_mmio.device=4K@0xd0000000:5"
1745+
"virtio_mmio.device=4K@0xd0001000:7"
17461746
));
17471747
}
17481748

@@ -1761,7 +1761,7 @@ pub mod tests {
17611761
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
17621762
assert!(cmdline_contains(
17631763
&cmdline,
1764-
"virtio_mmio.device=4K@0xd0000000:5"
1764+
"virtio_mmio.device=4K@0xd0001000:7"
17651765
));
17661766
}
17671767
}

0 commit comments

Comments
 (0)