Skip to content

Commit

Permalink
Simplify code related to testing of xtest
Browse files Browse the repository at this point in the history
  • Loading branch information
marxin authored and Amanieu committed Sep 23, 2024
1 parent 96a614b commit 1b3d2c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
14 changes: 1 addition & 13 deletions crates/core_arch/src/x86/xsave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ mod tests {
use stdarch_test::simd_test;

#[repr(align(64))]
#[derive(Debug)]
struct XsaveArea {
// max size for 256-bit registers is 800 bytes:
// see https://software.intel.com/en-us/node/682996
Expand Down Expand Up @@ -198,19 +199,6 @@ mod tests {
}
}

impl fmt::Debug for XsaveArea {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "[")?;
for i in 0..self.data.len() {
write!(f, "{}", self.data[i])?;
if i != self.data.len() - 1 {
write!(f, ", ")?;
}
}
write!(f, "]")
}
}

// We cannot test for `_xsave`, `xrstor`, `_xsetbv`, `_xsaveopt`, `_xsaves`, `_xrstors` as they
// are privileged instructions and will need access to kernel mode to execute and test them.
// see https://github.com/rust-lang/stdarch/issues/209
Expand Down
16 changes: 2 additions & 14 deletions crates/core_arch/src/x86_64/xsave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ mod tests {
use stdarch_test::simd_test;

#[repr(align(64))]
#[derive(Debug)]
struct XsaveArea {
// max size for 256-bit registers is 800 bytes:
// see https://software.intel.com/en-us/node/682996
Expand All @@ -144,7 +145,7 @@ mod tests {
XsaveArea { data: [0; 2560] }
}
fn ptr(&mut self) -> *mut u8 {
&mut self.data[0] as *mut _ as *mut u8
self.data.as_mut_ptr()
}
}

Expand All @@ -162,19 +163,6 @@ mod tests {
}
}

impl fmt::Debug for XsaveArea {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "[")?;
for i in 0..self.data.len() {
write!(f, "{}", self.data[i])?;
if i != self.data.len() - 1 {
write!(f, ", ")?;
}
}
write!(f, "]")
}
}

// We cannot test `_xsave64`, `_xrstor64`, `_xsaveopt64`, `_xsaves64` and `_xrstors64` directly
// as they are privileged instructions and will need access to the kernel to run and test them.
// See https://github.com/rust-lang/stdarch/issues/209
Expand Down

0 comments on commit 1b3d2c0

Please sign in to comment.