|
| 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