Skip to content

Commit b34cff1

Browse files
committed
Auto merge of rust-lang#102193 - ferrocene:pa-remote-test-server-improvements, r=Mark-Simulacrum
Change argument handling in `remote-test-server` and add new flags This PR updates `remote-test-server` to add two new flags: * `--sequential` disables parallel test execution, accepting one connection at the time instead. We need this for Ferrocene as one of our emulators occasionally deadlocks when running multiple tests in parallel. * `--bind <ip:port>` allows customizing the IP and port `remote-test-server` binds to, rather than using the default value. While I was changing the flags, and [after chatting on what to do on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/remote-test-server.20flags), I took this opportunity to cleanup argument handling in `remote-test-server`, which is a breaking change: * The `verbose` argument has been renamed to the `--verbose` flag. * The `remote` argument has been removed in favor of the `--bind 0.0.0.0:12345` flag. The only thing the argument did was to change the bound IP to 0.0.0.0, which can easily be replicated with `--bind` and also is not secure as our "remote" default. I'm also open to keep the old arguments with deprecation warnings. r? `@Mark-Simulacrum`
2 parents 57f097e + 20638eb commit b34cff1

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

Diff for: src/bootstrap/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1313
- Change the names for `dist` commands to match the component they generate. [#90684](https://github.com/rust-lang/rust/pull/90684)
1414
- The `build.fast-submodules` option has been removed. Fast submodule checkouts are enabled unconditionally. Automatic submodule handling can still be disabled with `build.submodules = false`.
1515
- Several unsupported `./configure` options have been removed: `optimize`, `parallel-compiler`. These can still be enabled with `--set`, although it isn't recommended.
16+
- `remote-test-server`'s `verbose` argument has been removed in favor of the `--verbose` flag
17+
- `remote-test-server`'s `remote` argument has been removed in favor of the `--bind` flag. Use `--bind 0.0.0.0:12345` to replicate the behavior of the `remote` argument.
1618

1719
### Non-breaking changes
1820

Diff for: src/tools/remote-test-server/src/main.rs

+31-17
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
#[cfg(not(windows))]
1414
use std::fs::Permissions;
15+
use std::net::SocketAddr;
1516
#[cfg(not(windows))]
1617
use std::os::unix::prelude::*;
1718

@@ -41,30 +42,44 @@ static TEST: AtomicUsize = AtomicUsize::new(0);
4142

4243
#[derive(Copy, Clone)]
4344
struct Config {
44-
pub remote: bool,
45-
pub verbose: bool,
45+
verbose: bool,
46+
sequential: bool,
47+
bind: SocketAddr,
4648
}
4749

4850
impl Config {
4951
pub fn default() -> Config {
50-
Config { remote: false, verbose: false }
52+
Config {
53+
verbose: false,
54+
sequential: false,
55+
bind: if cfg!(target_os = "android") || cfg!(windows) {
56+
([0, 0, 0, 0], 12345).into()
57+
} else {
58+
([10, 0, 2, 15], 12345).into()
59+
},
60+
}
5161
}
5262

5363
pub fn parse_args() -> Config {
5464
let mut config = Config::default();
5565

5666
let args = env::args().skip(1);
67+
let mut next_is_bind = false;
5768
for argument in args {
5869
match &argument[..] {
59-
"remote" => {
60-
config.remote = true;
61-
}
62-
"verbose" | "-v" => {
63-
config.verbose = true;
70+
bind if next_is_bind => {
71+
config.bind = t!(bind.parse());
72+
next_is_bind = false;
6473
}
74+
"--bind" => next_is_bind = true,
75+
"--sequential" => config.sequential = true,
76+
"--verbose" | "-v" => config.verbose = true,
6577
arg => panic!("unknown argument: {}", arg),
6678
}
6779
}
80+
if next_is_bind {
81+
panic!("missing value for --bind");
82+
}
6883

6984
config
7085
}
@@ -81,13 +96,7 @@ fn main() {
8196

8297
let config = Config::parse_args();
8398

84-
let bind_addr = if cfg!(target_os = "android") || cfg!(windows) || config.remote {
85-
"0.0.0.0:12345"
86-
} else {
87-
"10.0.2.15:12345"
88-
};
89-
90-
let listener = t!(TcpListener::bind(bind_addr));
99+
let listener = t!(TcpListener::bind(config.bind));
91100
let (work, tmp): (PathBuf, PathBuf) = if cfg!(target_os = "android") {
92101
("/data/tmp/work".into(), "/data/tmp/work/tmp".into())
93102
} else {
@@ -97,7 +106,7 @@ fn main() {
97106
tmp_dir.push("tmp");
98107
(work_dir, tmp_dir)
99108
};
100-
println!("listening on {}!", bind_addr);
109+
println!("listening on {}!", config.bind);
101110

102111
t!(fs::create_dir_all(&work));
103112
t!(fs::create_dir_all(&tmp));
@@ -119,7 +128,12 @@ fn main() {
119128
let lock = lock.clone();
120129
let work = work.clone();
121130
let tmp = tmp.clone();
122-
thread::spawn(move || handle_run(socket, &work, &tmp, &lock, config));
131+
let f = move || handle_run(socket, &work, &tmp, &lock, config);
132+
if config.sequential {
133+
f();
134+
} else {
135+
thread::spawn(f);
136+
}
123137
} else {
124138
panic!("unknown command {:?}", buf);
125139
}

0 commit comments

Comments
 (0)