From 811a024b2e71225bf90bbd19b983db9c8a4dbc54 Mon Sep 17 00:00:00 2001 From: Muminul Islam Date: Mon, 8 Apr 2024 15:25:11 -0700 Subject: [PATCH] mshv-ioctls: Add test_get_set_vp_state_components Signed-off-by: Muminul Islam --- mshv-ioctls/src/ioctls/vcpu.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mshv-ioctls/src/ioctls/vcpu.rs b/mshv-ioctls/src/ioctls/vcpu.rs index 9cbbbda0..6369528e 100644 --- a/mshv-ioctls/src/ioctls/vcpu.rs +++ b/mshv-ioctls/src/ioctls/vcpu.rs @@ -1531,4 +1531,18 @@ mod tests { let max_function = res[0]; assert!(max_function >= 1); } + + #[test] + fn test_get_set_vp_state_components() { + let hv = Mshv::new().unwrap(); + let vm = hv.create_vm().unwrap(); + let vcpu = vm.create_vcpu(0).unwrap(); + let mut states = vcpu.get_all_vp_state_components().unwrap(); + vcpu.set_all_vp_state_components(&mut states).unwrap(); + let ret_states = vcpu.get_all_vp_state_components().unwrap(); + assert!(states.buffer + .iter() + .zip(ret_states.buffer) + .all(|(a, b)| *a == b)); + } }