Skip to content

Commit

Permalink
tests: port jobserver-error.rs to rmake.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Noa <[email protected]>
Co-authored-by: Oneirical <[email protected]>
  • Loading branch information
3 people committed Jan 13, 2025
1 parent 1037167 commit aaddf77
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
run-make/cat-and-grep-sanity-check/Makefile
run-make/extern-fn-reachable/Makefile
run-make/jobserver-error/Makefile
run-make/split-debuginfo/Makefile
run-make/symbol-mangling-hashed/Makefile
run-make/translation/Makefile
17 changes: 0 additions & 17 deletions tests/run-make/jobserver-error/Makefile

This file was deleted.

55 changes: 55 additions & 0 deletions tests/run-make/jobserver-error/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//! If the environment variables contain an invalid `jobserver-auth`, this used to cause an ICE
//! until this was fixed in [do not panic on failure to acquire jobserver token
//! #109694](https://github.com/rust-lang/rust/pull/109694).
//!
//! Proper handling has been added, and this test checks that helpful warnings and errors are
//! printed instead in case of a wrong jobserver. See
//! <https://github.com/rust-lang/rust/issues/46981>.
//@ only-linux
//@ ignore-cross-compile

use run_make_support::{diff, rustc};

fn main() {
let out = rustc()
.stdin_buf(("fn main() {}").as_bytes())
.env("MAKEFLAGS", "--jobserver-auth=5,5")
.run_fail()
.stderr_utf8();
diff().expected_file("cannot_open_fd.stderr").actual_text("actual", out).run();

// SAFETY(io-safety): we don't have overlapping fd 3.
let out = unsafe {
rustc()
.stdin_buf(("fn main() {}").as_bytes())
.input("-")
.env("MAKEFLAGS", "--jobserver-auth=3,3")
.set_aux_fd(3, std::fs::File::open("/dev/null").unwrap())
.run()
.stderr_utf8()
};
diff().expected_file("not_a_pipe.stderr").actual_text("actual", out).run();

// FIXME(#110321): this case is spurious because:
//
// > the jobserver helper thread launched here gets starved out and doesn't run, while the
// > coordinator thread continually processes work using the implicit jobserver token, never
// > yielding long enough for the jobserver helper to do its work (and process the error).
//
// but is not necessarily worth fixing as it might require changing coordinator behavior that
// might regress performance. See discussion at
// <https://github.com/rust-lang/rust/issues/110321#issuecomment-1636914956>.

//let (readpipe, _) = std::pipe::pipe().unwrap();
//let out = unsafe {
// rustc()
// .stdin("fn main() {}")
// .input("-")
// .env("MAKEFLAGS", "--jobserver-auth=3,3")
// .set_aux_fd(3, readpipe)
// .run()
// .stderr_utf8()
//};
//diff().expected_file("poisoned_pipe.stderr").actual_text("actual", out).run();
}

0 comments on commit aaddf77

Please sign in to comment.