diff options
| author | Tom Eccles <tom.eccles@codethink.co.uk> | 2020-05-28 17:53:29 +0100 |
|---|---|---|
| committer | Tom Eccles <tom.eccles@codethink.co.uk> | 2020-06-02 14:00:18 +0100 |
| commit | 9e137bb8b685785fce6d1bc870bc197634b3796e (patch) | |
| tree | 6d9432688ac361eb284589865deb8cd36288bfb0 /src/tools/remote-test-server | |
| parent | 1b7ec76c16b18b01acd07f987db488a642492049 (diff) | |
| download | rust-9e137bb8b685785fce6d1bc870bc197634b3796e.tar.gz rust-9e137bb8b685785fce6d1bc870bc197634b3796e.zip | |
tools/remote-test-server: make use of verbose option
There was an unused verbose command line argument. Add some prints if verbose is set.
Diffstat (limited to 'src/tools/remote-test-server')
| -rw-r--r-- | src/tools/remote-test-server/src/main.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/tools/remote-test-server/src/main.rs b/src/tools/remote-test-server/src/main.rs index ce8e52a42f3..8c56910e2df 100644 --- a/src/tools/remote-test-server/src/main.rs +++ b/src/tools/remote-test-server/src/main.rs @@ -41,6 +41,7 @@ macro_rules! t { static TEST: AtomicUsize = AtomicUsize::new(0); +#[derive(Copy, Clone)] struct Config { pub remote: bool, pub verbose: bool, @@ -71,6 +72,12 @@ impl Config { } } +fn print_verbose(s: &str, conf: Config) { + if conf.verbose { + println!("{}", s); + } +} + fn main() { println!("starting test server"); @@ -92,7 +99,7 @@ fn main() { tmp_dir.push("tmp"); (work_dir, tmp_dir) }; - println!("listening!"); + println!("listening on {}!", bind_addr); t!(fs::create_dir_all(&work)); t!(fs::create_dir_all(&tmp)); @@ -106,23 +113,25 @@ fn main() { continue; } if &buf[..] == b"ping" { + print_verbose("Received ping", config); t!(socket.write_all(b"pong")); } else if &buf[..] == b"push" { - handle_push(socket, &work); + handle_push(socket, &work, config); } else if &buf[..] == b"run " { let lock = lock.clone(); let work = work.clone(); let tmp = tmp.clone(); - thread::spawn(move || handle_run(socket, &work, &tmp, &lock)); + thread::spawn(move || handle_run(socket, &work, &tmp, &lock, config)); } else { panic!("unknown command {:?}", buf); } } } -fn handle_push(socket: TcpStream, work: &Path) { +fn handle_push(socket: TcpStream, work: &Path, config: Config) { let mut reader = BufReader::new(socket); - recv(&work, &mut reader); + let dst = recv(&work, &mut reader); + print_verbose(&format!("push {:#?}", dst), config); let mut socket = reader.into_inner(); t!(socket.write_all(b"ack ")); @@ -138,7 +147,7 @@ impl Drop for RemoveOnDrop<'_> { } } -fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>) { +fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, config: Config) { let mut arg = Vec::new(); let mut reader = BufReader::new(socket); @@ -205,6 +214,7 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>) { // binary is and then we'll download it all to the exe path we calculated // earlier. let exe = recv(&path, &mut reader); + print_verbose(&format!("run {:#?}", exe), config); let mut cmd = Command::new(&exe); cmd.args(args); |
