Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote testing fixes #72704

Merged
merged 3 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/test/ui-fulldeps/compiler-calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

// ignore-cross-compile
// ignore-stage1
// ignore-remote

#![feature(rustc_private)]

Expand Down
1 change: 1 addition & 0 deletions src/test/ui-fulldeps/mod_dir_path_canonicalized.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// run-pass
// Testing that a librustc_ast can parse modules with canonicalized base path
// ignore-cross-compile
// ignore-remote

#![feature(rustc_private)]

Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ impl Config {
name == util::get_pointer_width(&self.target) || // pointer width
name == self.stage_id.split('-').next().unwrap() || // stage
(self.target != self.host && name == "cross-compile") ||
(self.remote_test_client.is_some() && name == "remote") ||
match self.compare_mode {
Some(CompareMode::Nll) => name == "compare-mode-nll",
Some(CompareMode::Polonius) => name == "compare-mode-polonius",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/remote-test-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ fn run(support_lib_count: usize, exe: String, all_args: Vec<String>) {
// by the client.
for (k, v) in env::vars() {
match &k[..] {
"PATH" | "LD_LIBRARY_PATH" | "PWD" => continue,
"PATH" | "LD_LIBRARY_PATH" | "PWD" | "RUST_TEST_TMPDIR" => continue,
_ => {}
}
t!(client.write_all(k.as_bytes()));
Expand Down
39 changes: 28 additions & 11 deletions src/tools/remote-test-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ macro_rules! t {

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

#[derive(Copy, Clone)]
struct Config {
pub remote: bool,
pub verbose: bool,
Expand Down Expand Up @@ -71,6 +72,12 @@ impl Config {
}
}

fn print_verbose(s: &str, conf: Config) {
if conf.verbose {
println!("{}", s);
}
}

fn main() {
println!("starting test server");

Expand All @@ -83,16 +90,19 @@ fn main() {
};

let listener = t!(TcpListener::bind(bind_addr));
let work: PathBuf = if cfg!(target_os = "android") {
"/data/tmp/work".into()
let (work, tmp): (PathBuf, PathBuf) = if cfg!(target_os = "android") {
("/data/tmp/work".into(), "/data/tmp/work/tmp".into())
} else {
let mut temp_dir = env::temp_dir();
temp_dir.push("work");
temp_dir
let mut work_dir = env::temp_dir();
work_dir.push("work");
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(&tmp));

let lock = Arc::new(Mutex::new(()));

Expand All @@ -103,22 +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();
thread::spawn(move || handle_run(socket, &work, &lock));
let tmp = tmp.clone();
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 "));
Expand All @@ -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 reader = BufReader::new(socket);

Expand Down Expand Up @@ -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
// earlier.
let exe = recv(&path, &mut reader);
print_verbose(&format!("run {:#?}", exe), config);

let mut cmd = Command::new(&exe);
cmd.args(args);
Expand All @@ -226,6 +240,9 @@ fn handle_run(socket: TcpStream, work: &Path, lock: &Mutex<()>) {
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
// fashion (poor man's style)
let mut child =
Expand Down