Skip to content

Commit b478964

Browse files
authored
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 ```
2 parents fe10f1a + 81df5ac commit b478964

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

src/test/ui-fulldeps/compiler-calls.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
// ignore-cross-compile
55
// ignore-stage1
6+
// ignore-remote
67

78
#![feature(rustc_private)]
89

src/test/ui-fulldeps/mod_dir_path_canonicalized.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// run-pass
22
// Testing that a librustc_ast can parse modules with canonicalized base path
33
// ignore-cross-compile
4+
// ignore-remote
45

56
#![feature(rustc_private)]
67

src/tools/compiletest/src/header.rs

+1
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ impl Config {
853853
name == util::get_pointer_width(&self.target) || // pointer width
854854
name == self.stage_id.split('-').next().unwrap() || // stage
855855
(self.target != self.host && name == "cross-compile") ||
856+
(self.remote_test_client.is_some() && name == "remote") ||
856857
match self.compare_mode {
857858
Some(CompareMode::Nll) => name == "compare-mode-nll",
858859
Some(CompareMode::Polonius) => name == "compare-mode-polonius",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ fn run(support_lib_count: usize, exe: String, all_args: Vec<String>) {
224224
// by the client.
225225
for (k, v) in env::vars() {
226226
match &k[..] {
227-
"PATH" | "LD_LIBRARY_PATH" | "PWD" => continue,
227+
"PATH" | "LD_LIBRARY_PATH" | "PWD" | "RUST_TEST_TMPDIR" => continue,
228228
_ => {}
229229
}
230230
t!(client.write_all(k.as_bytes()));

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

+28-11
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

@@ -83,16 +90,19 @@ fn main() {
8390
};
8491

8592
let listener = t!(TcpListener::bind(bind_addr));
86-
let work: PathBuf = if cfg!(target_os = "android") {
87-
"/data/tmp/work".into()
93+
let (work, tmp): (PathBuf, PathBuf) = if cfg!(target_os = "android") {
94+
("/data/tmp/work".into(), "/data/tmp/work/tmp".into())
8895
} else {
89-
let mut temp_dir = env::temp_dir();
90-
temp_dir.push("work");
91-
temp_dir
96+
let mut work_dir = env::temp_dir();
97+
work_dir.push("work");
98+
let mut tmp_dir = work_dir.clone();
99+
tmp_dir.push("tmp");
100+
(work_dir, tmp_dir)
92101
};
93-
println!("listening!");
102+
println!("listening on {}!", bind_addr);
94103

95104
t!(fs::create_dir_all(&work));
105+
t!(fs::create_dir_all(&tmp));
96106

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

@@ -103,22 +113,25 @@ fn main() {
103113
continue;
104114
}
105115
if &buf[..] == b"ping" {
116+
print_verbose("Received ping", config);
106117
t!(socket.write_all(b"pong"));
107118
} else if &buf[..] == b"push" {
108-
handle_push(socket, &work);
119+
handle_push(socket, &work, config);
109120
} else if &buf[..] == b"run " {
110121
let lock = lock.clone();
111122
let work = work.clone();
112-
thread::spawn(move || handle_run(socket, &work, &lock));
123+
let tmp = tmp.clone();
124+
thread::spawn(move || handle_run(socket, &work, &tmp, &lock, config));
113125
} else {
114126
panic!("unknown command {:?}", buf);
115127
}
116128
}
117129
}
118130

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

123136
let mut socket = reader.into_inner();
124137
t!(socket.write_all(b"ack "));
@@ -134,7 +147,7 @@ impl Drop for RemoveOnDrop<'_> {
134147
}
135148
}
136149

137-
fn handle_run(socket: TcpStream, work: &Path, lock: &Mutex<()>) {
150+
fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, config: Config) {
138151
let mut arg = Vec::new();
139152
let mut reader = BufReader::new(socket);
140153

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

205219
let mut cmd = Command::new(&exe);
206220
cmd.args(args);
@@ -226,6 +240,9 @@ fn handle_run(socket: TcpStream, work: &Path, lock: &Mutex<()>) {
226240
cmd.env("LD_LIBRARY_PATH", format!("{}:{}", work.display(), path.display()));
227241
}
228242

243+
// Some tests assume RUST_TEST_TMPDIR exists
244+
cmd.env("RUST_TEST_TMPDIR", tmp.to_owned());
245+
229246
// Spawn the child and ferry over stdout/stderr to the socket in a framed
230247
// fashion (poor man's style)
231248
let mut child =

0 commit comments

Comments
 (0)