Skip to content

Commit

Permalink
rewrite inaccessible-temp-dir to rmake format
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jun 12, 2024
1 parent d226890 commit 03982da
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 33 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
Expand Up @@ -66,7 +66,6 @@ run-make/foreign-double-unwind/Makefile
run-make/foreign-exceptions/Makefile
run-make/foreign-rust-exceptions/Makefile
run-make/glibc-staticlib-args/Makefile
run-make/inaccessible-temp-dir/Makefile
run-make/include_bytes_deps/Makefile
run-make/incr-add-rust-src-component/Makefile
run-make/incr-foreign-head-span/Makefile
Expand Down
32 changes: 0 additions & 32 deletions tests/run-make/inaccessible-temp-dir/Makefile

This file was deleted.

44 changes: 44 additions & 0 deletions tests/run-make/inaccessible-temp-dir/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Issue #66530: We would ICE if someone compiled with `-o /dev/null`,
// because we would try to generate auxiliary files in `/dev/` (which
// at least the OS X file system rejects).
//
// An attempt to `-Ztemps-dir` into a directory we cannot write into should
// indeed be an error; but not an ICE.
//
// However, some folks run tests as root, which can write `/dev/` and end
// up clobbering `/dev/null`. Instead we'll use an inaccessible path, which
// also used to ICE, but even root can't magically write there.
//
// Note that `-Ztemps-dir` uses `create_dir_all` so it is not sufficient to
// use a directory with non-existing parent like `/does-not-exist/output`.
// See https://github.com/rust-lang/rust/issues/66530

//@ only-linux
// Reason: set_mode is only available on Unix

//@ ignore-arm
// Reason: linker error on `armhf-gnu`

use run_make_support::{fs_wrapper, rustc};

fn main() {
// Create an inaccessible directory.
fs_wrapper::create_dir("inaccessible");
let meta = fs_wrapper::metadata("inaccessible");
let mut perms = meta.permissions();
perms.set_mode(0o000); // Lock down the directory.
fs_wrapper::set_permissions("inaccessible", perms);

// Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one,
// so that it can't create `tmp`.
rustc()
.input("program.rs")
.arg("-Ztemps-dir=inaccessible/tmp")
.run_fail()
.assert_stderr_contains(
"failed to find or create the directory specified by `--temps-dir`",
);

perms.set_mode(0o666); // Unlock the directory, so that compiletest can delete it.
fs_wrapper::set_permissions("inaccessible", perms);
}

0 comments on commit 03982da

Please sign in to comment.