From: Ian Jackson Date: Wed, 23 Dec 2020 14:39:16 +0000 (+0000) Subject: sort out pausing X-Git-Tag: otter-0.2.0~147 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=daca63e527d6b580cb0e6267143c19b3f76efd88;p=otter.git sort out pausing Signed-off-by: Ian Jackson --- diff --git a/Cargo.lock.example b/Cargo.lock.example index a8fd6090..26cd911c 100644 --- a/Cargo.lock.example +++ b/Cargo.lock.example @@ -943,6 +943,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e" +[[package]] +name = "humantime" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a" + [[package]] name = "hyper" version = "0.10.16" @@ -1556,6 +1562,7 @@ version = "0.0.1" dependencies = [ "anyhow", "fehler", + "humantime", "libc", "nix 0.19.1", "structopt", diff --git a/wdriver.rs b/wdriver.rs index 611ed6e4..9d8e2ecd 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -19,7 +19,10 @@ pub use std::os::unix::fs::DirBuilderExt; pub use std::os::linux::fs::MetadataExt; // todo why linux for st_mode?? pub use std::path; pub use std::process::{Command, Stdio}; +pub use std::thread::sleep; +pub use std::time; +pub const MS : time::Duration = time::Duration::from_millis(1); pub type AE = anyhow::Error; #[derive(Debug,Clone)] @@ -30,6 +33,9 @@ struct Opts { #[structopt(long="--tmp-dir", default_value="tmp")] tmp_dir: String, + + #[structopt(long="--pause", default_value="0ms")] + pause: humantime::Duration, } #[derive(Debug)] @@ -364,7 +370,7 @@ pub fn setup() -> Setup { } eprintln!("pid = {}", nix::unistd::getpid()); - std::thread::sleep_ms(3500); + sleep(opts.pause.into()); let cln = cleanup_notify::Handle::new()?; let (tmp, abstmp) = prepare_tmpdir(&opts, ¤t_exe)?; diff --git a/wdriver/Cargo.toml b/wdriver/Cargo.toml index 3abaa503..cbf67c01 100644 --- a/wdriver/Cargo.toml +++ b/wdriver/Cargo.toml @@ -13,6 +13,7 @@ edition = "2018" [dependencies] anyhow = "1" fehler = "1" +humantime = "2" libc = "0.2" nix = "0.19" structopt = "0.3" diff --git a/wdriver/wdt-simple.rs b/wdriver/wdt-simple.rs index d3eca331..8411ebf1 100644 --- a/wdriver/wdt-simple.rs +++ b/wdriver/wdt-simple.rs @@ -17,6 +17,6 @@ fn main(){ .wait().context("wait")?; println!("s = {:?}", &s); - std::thread::sleep_ms(500); + std::thread::sleep(500 * MS); } }