1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

dev random blocks on linux

This commit is contained in:
Chad Brewbaker 2021-05-18 15:10:51 -05:00
parent cacd078a49
commit c60d3866c3

View file

@ -347,10 +347,18 @@ fn test_squeeze_blank_before_numbering() {
#[cfg(unix)]
fn test_dev_random() {
let mut buf = [0; 2048];
let mut proc = new_ucmd!().args(&["/dev/random"]).run_no_wait();
#[cfg(target_os = "linux")]
fn rand_gen() -> &'static str { "/dev/urandom"}
#[cfg(not(target_os = "linux"))]
fn rand_gen() -> &'static str { "/dev/random"}
let mut proc = new_ucmd!().args(&[rand_gen()]).run_no_wait();
let mut proc_stdout = proc.stdout.take().unwrap();
println!("I got to 1");
proc_stdout.read_exact(&mut buf).unwrap();
println!("I got to 3");
let num_zeroes = buf.iter().fold(0, |mut acc, &n| {
if n == 0 {
acc += 1;