Skip to content

Commit

Permalink
tests: Test CPU-based RNG on all x86 targets
Browse files Browse the repository at this point in the history
This allows us to verify the RDRAND implementation on Linux.

Signed-off-by: Joe Richey <[email protected]>
  • Loading branch information
josephlr committed Feb 19, 2020
1 parent 1375181 commit 52e7e9f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ jobs:
script:
# We test that getrandom builds for all targets
- echo $STD_TARGETS | xargs -t -n1 cargo build --target
- echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --target
- echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=cpu --target
# also test minimum dependency versions are usable
- cargo generate-lockfile -Z minimal-versions
- echo $STD_TARGETS | xargs -t -n1 cargo build --target
- echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --target
- echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=cpu --target

# Trust cross-built/emulated targets. We must repeat all non-default values.
- name: "Linux (MIPS, big-endian)"
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,5 @@ pub fn getrandom(dest: &mut [u8]) -> Result<(), Error> {

#[cfg(test)]
mod test_common;
#[cfg(test)]
mod test_cpu;
8 changes: 8 additions & 0 deletions src/test_cpu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// We only test the CPU-based RNG source on supported architectures.
#![cfg(target_arch = "x86_64")]

#[path = "rdrand.rs"]
mod rdrand;
use rdrand::getrandom_inner as getrandom;
#[path = "test_common.rs"]
mod test_common;

0 comments on commit 52e7e9f

Please sign in to comment.