Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
JamesC1305 committed Aug 7, 2024
1 parent 2dfea4a commit 7cb349f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/vmm/src/acpi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ pub mod tests {
fn test_write_acpi_table_small_memory() {
let mut vmm = default_vmm();
vmm.guest_memory = arch_mem(
(SYSTEM_MEM_START + SYSTEM_MEM_SIZE - 4096)
(SYSTEM_MEM_START + SYSTEM_MEM_SIZE - 8192)
.try_into()
.unwrap(),
);
Expand All @@ -272,15 +272,15 @@ pub mod tests {
resource_allocator: &mut vmm.resource_allocator,
};

let mut sdt = MockSdt(vec![0; usize::try_from(SYSTEM_MEM_SIZE).unwrap()]);
let mut sdt = MockSdt(vec![0; usize::try_from(SYSTEM_MEM_SIZE - 4096).unwrap()]);
let err = writer.write_acpi_table(&mut sdt).unwrap_err();
assert!(
matches!(
err,
AcpiError::AcpiTables(acpi_tables::AcpiError::GuestMemory(
vm_memory::GuestMemoryError::PartialBuffer {
expected: 263168, // SYSTEM_MEM_SIZE
completed: 259072 // SYSTEM_MEM_SIZE - 4096
expected: 259072, // SYSTEM_MEM_SIZE - 4096
completed: 254976 // SYSTEM_MEM_SIZE - 8192
},
))
),
Expand Down
10 changes: 5 additions & 5 deletions src/vmm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1630,8 +1630,8 @@ pub mod tests {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
assert!(cmdline_contains(
&cmdline,
"virtio_mmio.device=4K@0xd0000000:5 virtio_mmio.device=4K@0xd0001000:6 \
virtio_mmio.device=4K@0xd0002000:7"
"virtio_mmio.device=4K@0xd0001000:7 virtio_mmio.device=4K@0xd0002000:8 \
virtio_mmio.device=4K@0xd0003000:9"
));
}

Expand Down Expand Up @@ -1726,7 +1726,7 @@ pub mod tests {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
assert!(cmdline_contains(
&cmdline,
"virtio_mmio.device=4K@0xd0000000:5"
"virtio_mmio.device=4K@0xd0001000:7"
));
}

Expand All @@ -1743,7 +1743,7 @@ pub mod tests {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
assert!(cmdline_contains(
&cmdline,
"virtio_mmio.device=4K@0xd0000000:5"
"virtio_mmio.device=4K@0xd0001000:7"
));
}

Expand All @@ -1762,7 +1762,7 @@ pub mod tests {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
assert!(cmdline_contains(
&cmdline,
"virtio_mmio.device=4K@0xd0000000:5"
"virtio_mmio.device=4K@0xd0001000:7"
));
}
}

0 comments on commit 7cb349f

Please sign in to comment.