Skip to content

Commit

Permalink
CPU: Test the SHA-512 detection logic for macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed May 19, 2024
1 parent dfc9b54 commit e943bfc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/cpu/arm/darwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,23 @@ pub fn detect_features() -> u32 {

features
}

#[cfg(test)]
mod tests {
use super::*;
use crate::cpu;

#[test]
fn sha512_detection() {
// We intentionally disable static feature detection for SHA-512.
const _SHA512_NOT_STATICALLY_DETECTED: () = assert!((ARMCAP_STATIC & SHA512.mask) == 0);

if cfg!(target_os = "macos") {
// All aarch64-apple-darwin targets have SHA3 enabled statically...
assert!(cfg!(target_feature = "sha3"));

// ...so we should detect it.
assert!(SHA512.available(cpu::features()));
}
}
}

0 comments on commit e943bfc

Please sign in to comment.