Skip to content

Commit 52e7e9f

Browse files
committed
tests: Test CPU-based RNG on all x86 targets
This allows us to verify the RDRAND implementation on Linux. Signed-off-by: Joe Richey <[email protected]>
1 parent 1375181 commit 52e7e9f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ jobs:
122122
script:
123123
# We test that getrandom builds for all targets
124124
- echo $STD_TARGETS | xargs -t -n1 cargo build --target
125-
- echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --target
125+
- echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=cpu --target
126126
# also test minimum dependency versions are usable
127127
- cargo generate-lockfile -Z minimal-versions
128128
- echo $STD_TARGETS | xargs -t -n1 cargo build --target
129-
- echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --target
129+
- echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=cpu --target
130130

131131
# Trust cross-built/emulated targets. We must repeat all non-default values.
132132
- name: "Linux (MIPS, big-endian)"

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,5 @@ pub fn getrandom(dest: &mut [u8]) -> Result<(), Error> {
217217

218218
#[cfg(test)]
219219
mod test_common;
220+
#[cfg(test)]
221+
mod test_cpu;

src/test_cpu.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// We only test the CPU-based RNG source on supported architectures.
2+
#![cfg(target_arch = "x86_64")]
3+
4+
#[path = "rdrand.rs"]
5+
mod rdrand;
6+
use rdrand::getrandom_inner as getrandom;
7+
#[path = "test_common.rs"]
8+
mod test_common;

0 commit comments

Comments
 (0)