Skip to content

Commit

Permalink
mshv: Fix test compilation on aarch64
Browse files Browse the repository at this point in the history
After this all the test compiles and runs on ARM64.

Signed-off-by: Jinank Jain <[email protected]>
  • Loading branch information
jinankjain authored and Jinank Jain committed Jan 30, 2025
1 parent d1b6519 commit f673728
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mshv-ioctls/src/ioctls/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ impl FromRawFd for DeviceFd {

#[cfg(test)]
mod tests {
#[cfg(target_arch = "x86_64")]
use super::*;
#[cfg(target_arch = "x86_64")]
use crate::ioctls::system::Mshv;
#[cfg(target_arch = "x86_64")]
use mshv_bindings::{MSHV_DEV_TYPE_VFIO, MSHV_DEV_VFIO_FILE, MSHV_DEV_VFIO_FILE_ADD};
Expand Down
1 change: 1 addition & 0 deletions mshv-ioctls/src/ioctls/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ mod tests {
assert!(vm.is_ok());
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_get_msr_index_list() {
let hv = Mshv::new().unwrap();
Expand Down
13 changes: 12 additions & 1 deletion mshv-ioctls/src/ioctls/vcpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use mshv_bindings::*;
use std::convert::TryFrom;
use std::fs::File;
use std::os::unix::io::{AsRawFd, RawFd};
#[cfg(test)]
#[cfg(all(test, target_arch = "x86_64"))]
use std::slice;
use vmm_sys_util::errno;
use vmm_sys_util::ioctl::{ioctl_with_mut_ref, ioctl_with_ref};
Expand Down Expand Up @@ -1922,6 +1922,8 @@ mod tests {
unsafe { libc::munmap(registers_addr as *mut c_void, 0x1000) };
unsafe { libc::munmap(hv_msg_addr as *mut c_void, 0x1000) };
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_set_get_msrs() {
let hv = Mshv::new().unwrap();
Expand Down Expand Up @@ -1959,6 +1961,7 @@ mod tests {
assert!(g_regs.as_slice()[1].data == s_regs.as_slice()[1].data);
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_set_get_vcpu_events() {
let hv = Mshv::new().unwrap();
Expand All @@ -1977,6 +1980,7 @@ mod tests {
}
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_set_get_xcrs() {
let hv = Mshv::new().unwrap();
Expand All @@ -1989,6 +1993,7 @@ mod tests {
assert!(g_regs.xcr0 == s_regs.xcr0);
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_set_get_lapic() {
let hv = Mshv::new().unwrap();
Expand All @@ -2003,6 +2008,7 @@ mod tests {
}
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_set_registers_64() {
let hv = Mshv::new().unwrap();
Expand Down Expand Up @@ -2033,6 +2039,7 @@ mod tests {
}
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_get_set_xsave() {
let hv = Mshv::new().unwrap();
Expand All @@ -2044,6 +2051,7 @@ mod tests {
vcpu.set_xsave(&state).unwrap();
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_get_suspend_regs() {
let hv = Mshv::new().unwrap();
Expand All @@ -2056,6 +2064,7 @@ mod tests {
assert!(regs.intercept_register == 0x0);
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_set_get_misc_regs() {
let hv = Mshv::new().unwrap();
Expand All @@ -2068,6 +2077,7 @@ mod tests {
assert!(g_regs.hypercall == s_regs.hypercall);
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_get_cpuid_values() {
let hv = Mshv::new().unwrap();
Expand All @@ -2080,6 +2090,7 @@ mod tests {
assert!(res_1[0] >= 1);
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_get_set_vp_state_components() {
let hv = Mshv::new().unwrap();
Expand Down
5 changes: 5 additions & 0 deletions mshv-ioctls/src/ioctls/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ mod tests {
assert!(vcpu.is_ok());
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_assert_virtual_interrupt() {
/* TODO better test with some code */
Expand All @@ -822,6 +823,7 @@ mod tests {
vm.request_virtual_interrupt(&cfg).unwrap();
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_install_intercept() {
let hv = Mshv::new().unwrap();
Expand All @@ -834,6 +836,7 @@ mod tests {
assert!(vm.install_intercept(intercept_args).is_ok());
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_get_property() {
let hv = Mshv::new().unwrap();
Expand Down Expand Up @@ -873,6 +876,7 @@ mod tests {
);
}

#[cfg(target_arch = "x86_64")]
#[test]
fn test_set_property() {
let hv = Mshv::new().unwrap();
Expand Down Expand Up @@ -1053,6 +1057,7 @@ mod tests {
}

#[test]
#[cfg(target_arch = "x86_64")]
fn test_register_deliverabilty_notifications() {
let hv = Mshv::new().unwrap();
let vm = hv.create_vm().unwrap();
Expand Down

0 comments on commit f673728

Please sign in to comment.