summaryrefslogtreecommitdiffstats
path: root/tests/run-make/inaccessible-temp-dir/Makefile
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /tests/run-make/inaccessible-temp-dir/Makefile
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/inaccessible-temp-dir/Makefile')
-rw-r--r--tests/run-make/inaccessible-temp-dir/Makefile32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/run-make/inaccessible-temp-dir/Makefile b/tests/run-make/inaccessible-temp-dir/Makefile
new file mode 100644
index 000000000..abdba4eb8
--- /dev/null
+++ b/tests/run-make/inaccessible-temp-dir/Makefile
@@ -0,0 +1,32 @@
+# only-linux
+# ignore-arm - linker error on `armhf-gnu`
+
+include ../tools.mk
+
+# 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`.
+
+all:
+ # Create an inaccessible directory
+ mkdir $(TMPDIR)/inaccessible
+ chmod 000 $(TMPDIR)/inaccessible
+
+ # Run rustc with `-Ztemps-dir` set to a directory
+ # *inside* the inaccessible one, so that it can't create it
+ $(RUSTC) program.rs -Ztemps-dir=$(TMPDIR)/inaccessible/tmp 2>&1 \
+ | $(CGREP) 'failed to find or create the directory specified by `--temps-dir`'
+
+ # Make the inaccessible directory accessible,
+ # so that compiletest can delete the temp dir
+ chmod +rw $(TMPDIR)/inaccessible