mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 19:15:46 +00:00
d5f5648b37
We use cargo vendor to generate a .cargo/config file and the vendor directory. Vendoring allows us to lock our dependencies and to modify them easily from the top level Cargo.toml. We vendor all dependencies, including the crates.io ones, which allows for network isolated builds. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
32 lines
875 B
Rust
32 lines
875 B
Rust
extern crate rand_jitter;
|
|
extern crate rand_core;
|
|
|
|
use rand_jitter::JitterRng;
|
|
#[cfg(feature = "std")]
|
|
use rand_core::RngCore;
|
|
|
|
#[cfg(feature = "std")]
|
|
#[test]
|
|
fn test_jitter_init() {
|
|
// Because this is a debug build, measurements here are not representive
|
|
// of the final release build.
|
|
// Don't fail this test if initializing `JitterRng` fails because of a
|
|
// bad timer (the timer from the standard library may not have enough
|
|
// accuracy on all platforms).
|
|
match JitterRng::new() {
|
|
Ok(ref mut rng) => {
|
|
// false positives are possible, but extremely unlikely
|
|
assert!(rng.next_u32() | rng.next_u32() != 0);
|
|
},
|
|
Err(_) => {},
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_jitter_bad_timer() {
|
|
fn bad_timer() -> u64 { 0 }
|
|
let mut rng = JitterRng::new_with_timer(bad_timer);
|
|
assert!(rng.test_timer().is_err());
|
|
}
|
|
|