Debian Codegraph @

debian/rust-vendor/getrandom-0.2.17/tests/rdrand.rs

raw
1 // We only test the RDRAND-based RNG source on supported architectures.
2 #![cfg(any(target_arch = "x86_64", target_arch = "x86"))]
3
4 // rdrand.rs expects to be part of the getrandom main crate, so we need these
5 // additional imports to get rdrand.rs to compile.
6 use getrandom::Error;
7 #[macro_use]
8 extern crate cfg_if;
9 #[path = "../src/lazy.rs"]
10 mod lazy;
11 #[path = "../src/rdrand.rs"]
12 mod rdrand;
13 #[path = "../src/util.rs"]
14 mod util;
15
16 // The rdrand implementation has the signature of getrandom_uninit(), but our
17 // tests expect getrandom_impl() to have the signature of getrandom().
18 fn getrandom_impl(dest: &mut [u8]) -> Result<(), Error> {
19 rdrand::getrandom_inner(unsafe { util::slice_as_uninit_mut(dest) })?;
20 Ok(())
21 }
22 mod common;