Rollup merge of #72704 - tblah:remote-testing-fixes, r=Mark-Simulacrum

Remote testing fixes

Improvements for remote testing

- Create a `RUST_TEST_TMPDIR` directory on the remote testing host
- Verbose mode for remote-test-server
- Skip tests which don't support remote testing using `// ignore-remote`

To test:
- Build `remote-test-server` for the target machine and copy it over
- On the target:
``` sh
remote-test-server remote
```
- On the build machine
``` sh
export TEST_DEVICE_ADDR="1.2.3.4:12345"
./x.py test
```
This commit is contained in:
Dylan DPC 2020-06-03 02:38:59 +02:00 committed by GitHub
commit b47896492c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 12 deletions

View file

@ -3,6 +3,7 @@
// ignore-cross-compile // ignore-cross-compile
// ignore-stage1 // ignore-stage1
// ignore-remote
#![feature(rustc_private)] #![feature(rustc_private)]

View file

@ -1,6 +1,7 @@
// run-pass // run-pass
// Testing that a librustc_ast can parse modules with canonicalized base path // Testing that a librustc_ast can parse modules with canonicalized base path
// ignore-cross-compile // ignore-cross-compile
// ignore-remote
#![feature(rustc_private)] #![feature(rustc_private)]

View file

@ -853,6 +853,7 @@ impl Config {
name == util::get_pointer_width(&self.target) || // pointer width name == util::get_pointer_width(&self.target) || // pointer width
name == self.stage_id.split('-').next().unwrap() || // stage name == self.stage_id.split('-').next().unwrap() || // stage
(self.target != self.host && name == "cross-compile") || (self.target != self.host && name == "cross-compile") ||
(self.remote_test_client.is_some() && name == "remote") ||
match self.compare_mode { match self.compare_mode {
Some(CompareMode::Nll) => name == "compare-mode-nll", Some(CompareMode::Nll) => name == "compare-mode-nll",
Some(CompareMode::Polonius) => name == "compare-mode-polonius", Some(CompareMode::Polonius) => name == "compare-mode-polonius",

View file

@ -224,7 +224,7 @@ fn run(support_lib_count: usize, exe: String, all_args: Vec<String>) {
// by the client. // by the client.
for (k, v) in env::vars() { for (k, v) in env::vars() {
match &k[..] { match &k[..] {
"PATH" | "LD_LIBRARY_PATH" | "PWD" => continue, "PATH" | "LD_LIBRARY_PATH" | "PWD" | "RUST_TEST_TMPDIR" => continue,
_ => {} _ => {}
} }
t!(client.write_all(k.as_bytes())); t!(client.write_all(k.as_bytes()));

View file

@ -41,6 +41,7 @@ macro_rules! t {
static TEST: AtomicUsize = AtomicUsize::new(0); static TEST: AtomicUsize = AtomicUsize::new(0);
#[derive(Copy, Clone)]
struct Config { struct Config {
pub remote: bool, pub remote: bool,
pub verbose: bool, pub verbose: bool,
@ -71,6 +72,12 @@ impl Config {
} }
} }
fn print_verbose(s: &str, conf: Config) {
if conf.verbose {
println!("{}", s);
}
}
fn main() { fn main() {
println!("starting test server"); println!("starting test server");
@ -83,16 +90,19 @@ fn main() {
}; };
let listener = t!(TcpListener::bind(bind_addr)); let listener = t!(TcpListener::bind(bind_addr));
let work: PathBuf = if cfg!(target_os = "android") { let (work, tmp): (PathBuf, PathBuf) = if cfg!(target_os = "android") {
"/data/tmp/work".into() ("/data/tmp/work".into(), "/data/tmp/work/tmp".into())
} else { } else {
let mut temp_dir = env::temp_dir(); let mut work_dir = env::temp_dir();
temp_dir.push("work"); work_dir.push("work");
temp_dir let mut tmp_dir = work_dir.clone();
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(&work));
t!(fs::create_dir_all(&tmp));
let lock = Arc::new(Mutex::new(())); let lock = Arc::new(Mutex::new(()));
@ -103,22 +113,25 @@ fn main() {
continue; continue;
} }
if &buf[..] == b"ping" { if &buf[..] == b"ping" {
print_verbose("Received ping", config);
t!(socket.write_all(b"pong")); t!(socket.write_all(b"pong"));
} else if &buf[..] == b"push" { } else if &buf[..] == b"push" {
handle_push(socket, &work); handle_push(socket, &work, config);
} else if &buf[..] == b"run " { } else if &buf[..] == b"run " {
let lock = lock.clone(); let lock = lock.clone();
let work = work.clone(); let work = work.clone();
thread::spawn(move || handle_run(socket, &work, &lock)); let tmp = tmp.clone();
thread::spawn(move || handle_run(socket, &work, &tmp, &lock, config));
} else { } else {
panic!("unknown command {:?}", buf); 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); 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(); let mut socket = reader.into_inner();
t!(socket.write_all(b"ack ")); t!(socket.write_all(b"ack "));
@ -134,7 +147,7 @@ impl Drop for RemoveOnDrop<'_> {
} }
} }
fn handle_run(socket: TcpStream, work: &Path, lock: &Mutex<()>) { fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, config: Config) {
let mut arg = Vec::new(); let mut arg = Vec::new();
let mut reader = BufReader::new(socket); let mut reader = BufReader::new(socket);
@ -201,6 +214,7 @@ fn handle_run(socket: TcpStream, work: &Path, lock: &Mutex<()>) {
// binary is and then we'll download it all to the exe path we calculated // binary is and then we'll download it all to the exe path we calculated
// earlier. // earlier.
let exe = recv(&path, &mut reader); let exe = recv(&path, &mut reader);
print_verbose(&format!("run {:#?}", exe), config);
let mut cmd = Command::new(&exe); let mut cmd = Command::new(&exe);
cmd.args(args); cmd.args(args);
@ -226,6 +240,9 @@ fn handle_run(socket: TcpStream, work: &Path, lock: &Mutex<()>) {
cmd.env("LD_LIBRARY_PATH", format!("{}:{}", work.display(), path.display())); cmd.env("LD_LIBRARY_PATH", format!("{}:{}", work.display(), path.display()));
} }
// Some tests assume RUST_TEST_TMPDIR exists
cmd.env("RUST_TEST_TMPDIR", tmp.to_owned());
// Spawn the child and ferry over stdout/stderr to the socket in a framed // Spawn the child and ferry over stdout/stderr to the socket in a framed
// fashion (poor man's style) // fashion (poor man's style)
let mut child = let mut child =