aboutsummaryrefslogtreecommitdiff
path: root/tests/utils/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-08-15 19:01:56 +0200
committerUlf Lilleengen <[email protected]>2025-08-25 19:44:50 +0200
commit3a6ea3a31c90179fb3cbd30c18e3a310e2ee647c (patch)
tree9dcbd98e58bd2a0569b4f30562b51c4e677ea5b9 /tests/utils/src
parenta34e0b1ec57350cfa1d61aa6fc2eced077be5623 (diff)
Load all crates in the graph, honor the "publish" flag to prevent publishing examples/tests.
Diffstat (limited to 'tests/utils/src')
-rw-r--r--tests/utils/src/bin/saturate_serial.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/utils/src/bin/saturate_serial.rs b/tests/utils/src/bin/saturate_serial.rs
index 18ca12fb7..85676b106 100644
--- a/tests/utils/src/bin/saturate_serial.rs
+++ b/tests/utils/src/bin/saturate_serial.rs
@@ -2,7 +2,7 @@ use std::path::Path;
2use std::time::Duration; 2use std::time::Duration;
3use std::{env, io, process, thread}; 3use std::{env, io, process, thread};
4 4
5use rand::random; 5use rand::{rng, Rng};
6use serial::SerialPort; 6use serial::SerialPort;
7 7
8pub fn main() { 8pub fn main() {
@@ -34,14 +34,15 @@ fn saturate<T: SerialPort>(port: &mut T, idles: bool) -> io::Result<()> {
34 })?; 34 })?;
35 35
36 let mut written = 0; 36 let mut written = 0;
37 let mut rng = rng();
37 loop { 38 loop {
38 let len = random::<usize>() % 0x1000; 39 let len = rng.random_range(1..=0x1000);
39 let buf: Vec<u8> = (written..written + len).map(|x| x as u8).collect(); 40 let buf: Vec<u8> = (written..written + len).map(|x| x as u8).collect();
40 41
41 port.write_all(&buf)?; 42 port.write_all(&buf)?;
42 43
43 if idles { 44 if idles {
44 let micros = (random::<usize>() % 1000) as u64; 45 let micros = rng.random_range(1..=1000) as u64;
45 println!("Sleeping {}us", micros); 46 println!("Sleeping {}us", micros);
46 port.flush().unwrap(); 47 port.flush().unwrap();
47 thread::sleep(Duration::from_micros(micros)); 48 thread::sleep(Duration::from_micros(micros));