From 39fa192d8b8e16c84a884297255a5e7d7f26a383 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Tue, 25 Apr 2023 15:06:32 +0000 Subject: [PATCH 1/4] Fix `ui/io-checks/inaccessbile-temp-dir.rs` test --- tests/run-make/inaccessbile-temp-dir/Makefile | 31 +++++++++++++++ .../run-make/inaccessbile-temp-dir/program.rs | 1 + tests/ui/io-checks/inaccessbile-temp-dir.rs | 39 ------------------- .../ui/io-checks/inaccessbile-temp-dir.stderr | 4 -- 4 files changed, 32 insertions(+), 43 deletions(-) create mode 100644 tests/run-make/inaccessbile-temp-dir/Makefile create mode 100644 tests/run-make/inaccessbile-temp-dir/program.rs delete mode 100644 tests/ui/io-checks/inaccessbile-temp-dir.rs delete mode 100644 tests/ui/io-checks/inaccessbile-temp-dir.stderr diff --git a/tests/run-make/inaccessbile-temp-dir/Makefile b/tests/run-make/inaccessbile-temp-dir/Makefile new file mode 100644 index 0000000000000..f701dde829b30 --- /dev/null +++ b/tests/run-make/inaccessbile-temp-dir/Makefile @@ -0,0 +1,31 @@ +# only-linux + +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 diff --git a/tests/run-make/inaccessbile-temp-dir/program.rs b/tests/run-make/inaccessbile-temp-dir/program.rs new file mode 100644 index 0000000000000..f328e4d9d04c3 --- /dev/null +++ b/tests/run-make/inaccessbile-temp-dir/program.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/tests/ui/io-checks/inaccessbile-temp-dir.rs b/tests/ui/io-checks/inaccessbile-temp-dir.rs deleted file mode 100644 index 9c0aa01357217..0000000000000 --- a/tests/ui/io-checks/inaccessbile-temp-dir.rs +++ /dev/null @@ -1,39 +0,0 @@ -// 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 `-o` 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 a non-existent path, which -// also used to ICE, but even root can't magically write there. - -// compile-flags: -Z temps-dir=/does-not-exist/output - -// The error-pattern check occurs *before* normalization, and the error patterns -// are wildly different between build environments. So this is a cop-out (and we -// rely on the checking of the normalized stderr output as our actual -// "verification" of the diagnostic). - -// error-pattern: error - -// On Mac OS X, we get an error like the below -// normalize-stderr-test "failed to write bytecode to /does-not-exist/output.non_ice_error_on_worker_io_fail.*" -> "io error modifying /does-not-exist/" - -// On Linux, we get an error like the below -// normalize-stderr-test "couldn't create a temp dir.*" -> "io error modifying /does-not-exist/" - -// ignore-windows - this is a unix-specific test -// ignore-emscripten - the file-system issues do not replicate here -// ignore-wasm - the file-system issues do not replicate here -// ignore-arm - the file-system issues do not replicate here, at least on armhf-gnu - -#![crate_type = "lib"] -#![cfg_attr(not(feature = "std"), no_std)] -pub mod task { - pub mod __internal { - use crate::task::Waker; - } - pub use core::task::Waker; -} diff --git a/tests/ui/io-checks/inaccessbile-temp-dir.stderr b/tests/ui/io-checks/inaccessbile-temp-dir.stderr deleted file mode 100644 index 2fc5f93ef791a..0000000000000 --- a/tests/ui/io-checks/inaccessbile-temp-dir.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: failed to find or create the directory specified by `--temps-dir` - -error: aborting due to previous error - From e6ed0ca3dd842701e2475f010dd6c39b33f58732 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Tue, 25 Apr 2023 15:25:19 +0000 Subject: [PATCH 2/4] Improve `non-ice-error-on-worker-io-fail.rs` test - Remove unrelated code - Use a local dir path --- .../io-checks/non-ice-error-on-worker-io-fail.rs | 16 ++++------------ .../non-ice-error-on-worker-io-fail.stderr | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/tests/ui/io-checks/non-ice-error-on-worker-io-fail.rs b/tests/ui/io-checks/non-ice-error-on-worker-io-fail.rs index 134e7d420e3ea..6ec81a943067b 100644 --- a/tests/ui/io-checks/non-ice-error-on-worker-io-fail.rs +++ b/tests/ui/io-checks/non-ice-error-on-worker-io-fail.rs @@ -9,7 +9,7 @@ // up clobbering `/dev/null`. Instead we'll use a non-existent path, which // also used to ICE, but even root can't magically write there. -// compile-flags: -o /does-not-exist/output +// compile-flags: -o ./does-not-exist/output // The error-pattern check occurs *before* normalization, and the error patterns // are wildly different between build environments. So this is a cop-out (and we @@ -19,22 +19,14 @@ // error-pattern: error // On Mac OS X, we get an error like the below -// normalize-stderr-test "failed to write bytecode to /does-not-exist/output.non_ice_error_on_worker_io_fail.*" -> "io error modifying /does-not-exist/" +// normalize-stderr-test "failed to write bytecode to ./does-not-exist/output.non_ice_error_on_worker_io_fail.*" -> "io error modifying ./does-not-exist/" // On Linux, we get an error like the below -// normalize-stderr-test "couldn't create a temp dir.*" -> "io error modifying /does-not-exist/" +// normalize-stderr-test "couldn't create a temp dir.*" -> "io error modifying ./does-not-exist/" // ignore-windows - this is a unix-specific test // ignore-emscripten - the file-system issues do not replicate here // ignore-wasm - the file-system issues do not replicate here // ignore-arm - the file-system issues do not replicate here, at least on armhf-gnu -#![crate_type="lib"] - -#![cfg_attr(not(feature = "std"), no_std)] -pub mod task { - pub mod __internal { - use crate::task::Waker; - } - pub use core::task::Waker; -} +#![crate_type = "lib"] diff --git a/tests/ui/io-checks/non-ice-error-on-worker-io-fail.stderr b/tests/ui/io-checks/non-ice-error-on-worker-io-fail.stderr index edadecf273a7b..f1d9ed8ac8b76 100644 --- a/tests/ui/io-checks/non-ice-error-on-worker-io-fail.stderr +++ b/tests/ui/io-checks/non-ice-error-on-worker-io-fail.stderr @@ -1,6 +1,6 @@ warning: ignoring --out-dir flag due to -o flag -error: io error modifying /does-not-exist/ +error: io error modifying ./does-not-exist/ error: aborting due to previous error; 1 warning emitted From e80b24cc1451f918bbed5705e61bd86c533e5ea2 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 27 Apr 2023 13:07:14 +0000 Subject: [PATCH 3/4] fix typo in the `inaccessible-temp-dir` test name (formally `...inaccessbile...`) --- .../{inaccessbile-temp-dir => inaccessible-temp-dir}/Makefile | 0 .../{inaccessbile-temp-dir => inaccessible-temp-dir}/program.rs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/run-make/{inaccessbile-temp-dir => inaccessible-temp-dir}/Makefile (100%) rename tests/run-make/{inaccessbile-temp-dir => inaccessible-temp-dir}/program.rs (100%) diff --git a/tests/run-make/inaccessbile-temp-dir/Makefile b/tests/run-make/inaccessible-temp-dir/Makefile similarity index 100% rename from tests/run-make/inaccessbile-temp-dir/Makefile rename to tests/run-make/inaccessible-temp-dir/Makefile diff --git a/tests/run-make/inaccessbile-temp-dir/program.rs b/tests/run-make/inaccessible-temp-dir/program.rs similarity index 100% rename from tests/run-make/inaccessbile-temp-dir/program.rs rename to tests/run-make/inaccessible-temp-dir/program.rs From 1d847b86593d79511ddc78aa374c0f20536a449c Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 27 Apr 2023 13:09:41 +0000 Subject: [PATCH 4/4] ignore failing test on arm --- tests/run-make/inaccessible-temp-dir/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/run-make/inaccessible-temp-dir/Makefile b/tests/run-make/inaccessible-temp-dir/Makefile index f701dde829b30..25b7b87a15ab7 100644 --- a/tests/run-make/inaccessible-temp-dir/Makefile +++ b/tests/run-make/inaccessible-temp-dir/Makefile @@ -1,4 +1,5 @@ # only-linux +# ignore-arm - linker error on `armhf-gnu` include ../tools.mk