Auto merge of #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`
This commit is contained in:
commit
b34cff1736
@ -13,6 +13,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Change the names for `dist` commands to match the component they generate. [#90684](https://github.com/rust-lang/rust/pull/90684)
|
||||
- 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`.
|
||||
- Several unsupported `./configure` options have been removed: `optimize`, `parallel-compiler`. These can still be enabled with `--set`, although it isn't recommended.
|
||||
- `remote-test-server`'s `verbose` argument has been removed in favor of the `--verbose` flag
|
||||
- `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.
|
||||
|
||||
### Non-breaking changes
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#[cfg(not(windows))]
|
||||
use std::fs::Permissions;
|
||||
use std::net::SocketAddr;
|
||||
#[cfg(not(windows))]
|
||||
use std::os::unix::prelude::*;
|
||||
|
||||
@ -41,30 +42,44 @@ static TEST: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct Config {
|
||||
pub remote: bool,
|
||||
pub verbose: bool,
|
||||
verbose: bool,
|
||||
sequential: bool,
|
||||
bind: SocketAddr,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn default() -> Config {
|
||||
Config { remote: false, verbose: false }
|
||||
Config {
|
||||
verbose: false,
|
||||
sequential: false,
|
||||
bind: if cfg!(target_os = "android") || cfg!(windows) {
|
||||
([0, 0, 0, 0], 12345).into()
|
||||
} else {
|
||||
([10, 0, 2, 15], 12345).into()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_args() -> Config {
|
||||
let mut config = Config::default();
|
||||
|
||||
let args = env::args().skip(1);
|
||||
let mut next_is_bind = false;
|
||||
for argument in args {
|
||||
match &argument[..] {
|
||||
"remote" => {
|
||||
config.remote = true;
|
||||
}
|
||||
"verbose" | "-v" => {
|
||||
config.verbose = true;
|
||||
bind if next_is_bind => {
|
||||
config.bind = t!(bind.parse());
|
||||
next_is_bind = false;
|
||||
}
|
||||
"--bind" => next_is_bind = true,
|
||||
"--sequential" => config.sequential = true,
|
||||
"--verbose" | "-v" => config.verbose = true,
|
||||
arg => panic!("unknown argument: {}", arg),
|
||||
}
|
||||
}
|
||||
if next_is_bind {
|
||||
panic!("missing value for --bind");
|
||||
}
|
||||
|
||||
config
|
||||
}
|
||||
@ -81,13 +96,7 @@ fn main() {
|
||||
|
||||
let config = Config::parse_args();
|
||||
|
||||
let bind_addr = if cfg!(target_os = "android") || cfg!(windows) || config.remote {
|
||||
"0.0.0.0:12345"
|
||||
} else {
|
||||
"10.0.2.15:12345"
|
||||
};
|
||||
|
||||
let listener = t!(TcpListener::bind(bind_addr));
|
||||
let listener = t!(TcpListener::bind(config.bind));
|
||||
let (work, tmp): (PathBuf, PathBuf) = if cfg!(target_os = "android") {
|
||||
("/data/tmp/work".into(), "/data/tmp/work/tmp".into())
|
||||
} else {
|
||||
@ -97,7 +106,7 @@ fn main() {
|
||||
tmp_dir.push("tmp");
|
||||
(work_dir, tmp_dir)
|
||||
};
|
||||
println!("listening on {}!", bind_addr);
|
||||
println!("listening on {}!", config.bind);
|
||||
|
||||
t!(fs::create_dir_all(&work));
|
||||
t!(fs::create_dir_all(&tmp));
|
||||
@ -119,7 +128,12 @@ fn main() {
|
||||
let lock = lock.clone();
|
||||
let work = work.clone();
|
||||
let tmp = tmp.clone();
|
||||
thread::spawn(move || handle_run(socket, &work, &tmp, &lock, config));
|
||||
let f = move || handle_run(socket, &work, &tmp, &lock, config);
|
||||
if config.sequential {
|
||||
f();
|
||||
} else {
|
||||
thread::spawn(f);
|
||||
}
|
||||
} else {
|
||||
panic!("unknown command {:?}", buf);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user