Skip to content

Commit 9e137bb

Browse files
committed
tools/remote-test-server: make use of verbose option
There was an unused verbose command line argument. Add some prints if verbose is set.
1 parent 1b7ec76 commit 9e137bb

File tree

1 file changed

+16
-6
lines changed
  • src/tools/remote-test-server/src

1 file changed

+16
-6
lines changed

src/tools/remote-test-server/src/main.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ macro_rules! t {
4141

4242
static TEST: AtomicUsize = AtomicUsize::new(0);
4343

44+
#[derive(Copy, Clone)]
4445
struct Config {
4546
pub remote: bool,
4647
pub verbose: bool,
@@ -71,6 +72,12 @@ impl Config {
7172
}
7273
}
7374

75+
fn print_verbose(s: &str, conf: Config) {
76+
if conf.verbose {
77+
println!("{}", s);
78+
}
79+
}
80+
7481
fn main() {
7582
println!("starting test server");
7683

@@ -92,7 +99,7 @@ fn main() {
9299
tmp_dir.push("tmp");
93100
(work_dir, tmp_dir)
94101
};
95-
println!("listening!");
102+
println!("listening on {}!", bind_addr);
96103

97104
t!(fs::create_dir_all(&work));
98105
t!(fs::create_dir_all(&tmp));
@@ -106,23 +113,25 @@ fn main() {
106113
continue;
107114
}
108115
if &buf[..] == b"ping" {
116+
print_verbose("Received ping", config);
109117
t!(socket.write_all(b"pong"));
110118
} else if &buf[..] == b"push" {
111-
handle_push(socket, &work);
119+
handle_push(socket, &work, config);
112120
} else if &buf[..] == b"run " {
113121
let lock = lock.clone();
114122
let work = work.clone();
115123
let tmp = tmp.clone();
116-
thread::spawn(move || handle_run(socket, &work, &tmp, &lock));
124+
thread::spawn(move || handle_run(socket, &work, &tmp, &lock, config));
117125
} else {
118126
panic!("unknown command {:?}", buf);
119127
}
120128
}
121129
}
122130

123-
fn handle_push(socket: TcpStream, work: &Path) {
131+
fn handle_push(socket: TcpStream, work: &Path, config: Config) {
124132
let mut reader = BufReader::new(socket);
125-
recv(&work, &mut reader);
133+
let dst = recv(&work, &mut reader);
134+
print_verbose(&format!("push {:#?}", dst), config);
126135

127136
let mut socket = reader.into_inner();
128137
t!(socket.write_all(b"ack "));
@@ -138,7 +147,7 @@ impl Drop for RemoveOnDrop<'_> {
138147
}
139148
}
140149

141-
fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>) {
150+
fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, config: Config) {
142151
let mut arg = Vec::new();
143152
let mut reader = BufReader::new(socket);
144153

@@ -205,6 +214,7 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>) {
205214
// binary is and then we'll download it all to the exe path we calculated
206215
// earlier.
207216
let exe = recv(&path, &mut reader);
217+
print_verbose(&format!("run {:#?}", exe), config);
208218

209219
let mut cmd = Command::new(&exe);
210220
cmd.args(args);

0 commit comments

Comments
 (0)