Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aaddf77

Browse files
jieyouxucoolreader18Oneirical
committedJan 13, 2025
tests: port jobserver-error.rs to rmake.rs
Co-authored-by: Noa <coolreader18@gmail.com> Co-authored-by: Oneirical <manchot@videotron.ca>
1 parent 1037167 commit aaddf77

File tree

3 files changed

+55
-18
lines changed

3 files changed

+55
-18
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
run-make/cat-and-grep-sanity-check/Makefile
22
run-make/extern-fn-reachable/Makefile
3-
run-make/jobserver-error/Makefile
43
run-make/split-debuginfo/Makefile
54
run-make/symbol-mangling-hashed/Makefile
65
run-make/translation/Makefile

‎tests/run-make/jobserver-error/Makefile

-17
This file was deleted.
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//! If the environment variables contain an invalid `jobserver-auth`, this used to cause an ICE
2+
//! until this was fixed in [do not panic on failure to acquire jobserver token
3+
//! #109694](https://github.com/rust-lang/rust/pull/109694).
4+
//!
5+
//! Proper handling has been added, and this test checks that helpful warnings and errors are
6+
//! printed instead in case of a wrong jobserver. See
7+
//! <https://github.com/rust-lang/rust/issues/46981>.
8+
9+
//@ only-linux
10+
//@ ignore-cross-compile
11+
12+
use run_make_support::{diff, rustc};
13+
14+
fn main() {
15+
let out = rustc()
16+
.stdin_buf(("fn main() {}").as_bytes())
17+
.env("MAKEFLAGS", "--jobserver-auth=5,5")
18+
.run_fail()
19+
.stderr_utf8();
20+
diff().expected_file("cannot_open_fd.stderr").actual_text("actual", out).run();
21+
22+
// SAFETY(io-safety): we don't have overlapping fd 3.
23+
let out = unsafe {
24+
rustc()
25+
.stdin_buf(("fn main() {}").as_bytes())
26+
.input("-")
27+
.env("MAKEFLAGS", "--jobserver-auth=3,3")
28+
.set_aux_fd(3, std::fs::File::open("/dev/null").unwrap())
29+
.run()
30+
.stderr_utf8()
31+
};
32+
diff().expected_file("not_a_pipe.stderr").actual_text("actual", out).run();
33+
34+
// FIXME(#110321): this case is spurious because:
35+
//
36+
// > the jobserver helper thread launched here gets starved out and doesn't run, while the
37+
// > coordinator thread continually processes work using the implicit jobserver token, never
38+
// > yielding long enough for the jobserver helper to do its work (and process the error).
39+
//
40+
// but is not necessarily worth fixing as it might require changing coordinator behavior that
41+
// might regress performance. See discussion at
42+
// <https://github.com/rust-lang/rust/issues/110321#issuecomment-1636914956>.
43+
44+
//let (readpipe, _) = std::pipe::pipe().unwrap();
45+
//let out = unsafe {
46+
// rustc()
47+
// .stdin("fn main() {}")
48+
// .input("-")
49+
// .env("MAKEFLAGS", "--jobserver-auth=3,3")
50+
// .set_aux_fd(3, readpipe)
51+
// .run()
52+
// .stderr_utf8()
53+
//};
54+
//diff().expected_file("poisoned_pipe.stderr").actual_text("actual", out).run();
55+
}

0 commit comments

Comments
 (0)
Failed to load comments.