chiark / gitweb /
sort out pausing
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 23 Dec 2020 14:39:16 +0000 (14:39 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 23 Dec 2020 14:39:16 +0000 (14:39 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Cargo.lock.example
wdriver.rs
wdriver/Cargo.toml
wdriver/wdt-simple.rs

index a8fd6090b0212450b736452236e2437dac23cfc9..26cd911c37687f5f8828b6cd78b43ae9440d545b 100644 (file)
@@ -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",
index 611ed6e4bbb57ea6fe545a0308743021e1f4afa7..9d8e2ecd1c4992313c3a89e410d72fce97e2dfd9 100644 (file)
@@ -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, &current_exe)?;
index 3abaa5036bcc72b2c42422474eaccc00f5853d22..cbf67c01bc8a5a4503cba54c1167ba9345b10742 100644 (file)
@@ -13,6 +13,7 @@ edition = "2018"
 [dependencies]
 anyhow = "1"
 fehler = "1"
+humantime = "2"
 libc = "0.2"
 nix = "0.19"
 structopt = "0.3"
index d3eca3312942a8ac9eec33bf761292c9c998b99c..8411ebf1b9aae4ca43e5d7cff760aebbed7ee6f1 100644 (file)
@@ -17,6 +17,6 @@ fn main(){
       .wait().context("wait")?;
     println!("s = {:?}", &s);
 
-    std::thread::sleep_ms(500);
+    std::thread::sleep(500 * MS);
   }
 }