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:
parent
cacd078a49
commit
c60d3866c3
1 changed files with 9 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue