mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: Test activator success path
Feed Ok into VirtioPciDeviceActivator and assert that activate returns Ok, device_activated becomes true, DEVICE_NEEDS_RESET is not set, status is otherwise unchanged, no Config interrupt is delivered, and the barrier waiter unblocks normally. Assisted-by: Claude:Opus-4.7 Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
64c552cc96
commit
a89600aeba
@@ -1621,4 +1621,25 @@ mod unit_tests {
|
||||
// did not deadlock the vCPU thread.
|
||||
waiter.join().expect("barrier waiter deadlocked");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn activate_success_sets_activated_and_does_not_signal_reset() {
|
||||
let (activator, status, device_activated, interrupt, barrier) = make_activator(Ok(()));
|
||||
let initial_status = status.load(Ordering::SeqCst);
|
||||
|
||||
let waiter = std::thread::spawn(move || barrier.wait());
|
||||
|
||||
let result = activator.activate();
|
||||
|
||||
result.unwrap();
|
||||
assert!(device_activated.load(Ordering::SeqCst));
|
||||
assert_eq!(
|
||||
status.load(Ordering::SeqCst) & (DEVICE_NEEDS_RESET as u8),
|
||||
0
|
||||
);
|
||||
assert_eq!(status.load(Ordering::SeqCst), initial_status);
|
||||
assert!(interrupt.triggers.lock().unwrap().is_empty());
|
||||
|
||||
waiter.join().expect("barrier waiter deadlocked");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user