Skip to content

Commit fec52fa

Browse files
andr3wyhimanshur-devGoldin Vo
committed
-Utilized Option instead of Vector to store IRQ lines for MMIO devices.
-Add test to test this. -Update existing tests Signed-off-by: Andrew Yao <[email protected]> Co-authored-by: Himanshu Reddy <[email protected]> Co-authored-by: Goldin Vo <[email protected]>
1 parent 46005b0 commit fec52fa

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

Diff for: src/vmm/src/device_manager/mmio.rs

+15-18
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ mod tests {
741741
assert_eq!(dummy.queues().len(), QUEUE_SIZES.len());
742742
}
743743

744-
// NOTE: we are also failing this test now
745744
#[test]
746745
fn test_device_info() {
747746
let start_addr1 = GuestAddress(0x0);
@@ -820,30 +819,31 @@ mod tests {
820819
}
821820

822821
#[test]
823-
fn test_slot_irq_allocation() {
822+
fn test_no_irq_allocation() {
824823
let mut device_manager = MMIODeviceManager::new();
825824
let mut resource_allocator = ResourceAllocator::new().unwrap();
825+
826826
let device_info = device_manager
827827
.allocate_mmio_resources(&mut resource_allocator, 0)
828828
.unwrap();
829829
assert!(device_info.irq.is_none());
830+
}
831+
832+
#[test]
833+
fn test_irq_allocation() {
834+
let mut device_manager = MMIODeviceManager::new();
835+
let mut resource_allocator = ResourceAllocator::new().unwrap();
836+
830837
let device_info = device_manager
831838
.allocate_mmio_resources(&mut resource_allocator, 1)
832839
.unwrap();
833840
assert_eq!(device_info.irq.unwrap().get(), crate::arch::IRQ_BASE);
834-
assert_eq!(
835-
format!(
836-
"{}",
837-
device_manager
838-
.allocate_mmio_resources(
839-
&mut resource_allocator,
840-
crate::arch::IRQ_MAX - crate::arch::IRQ_BASE + 1
841-
)
842-
.unwrap_err()
843-
),
844-
"Invalid MMIO IRQ configuration."
845-
.to_string()
846-
);
841+
}
842+
843+
#[test]
844+
fn test_allocation_failure() {
845+
let mut device_manager = MMIODeviceManager::new();
846+
let mut resource_allocator = ResourceAllocator::new().unwrap();
847847
assert_eq!(
848848
format!(
849849
"{}",
@@ -854,8 +854,5 @@ mod tests {
854854
"Invalid MMIO IRQ configuration."
855855
.to_string()
856856
);
857-
device_manager
858-
.allocate_mmio_resources(&mut resource_allocator, 0)
859-
.unwrap();
860857
}
861858
}

0 commit comments

Comments
 (0)