Skip to content

Commit

Permalink
Rollup merge of rust-lang#126917 - ferrocene:hoverbear/riscv64-inacce…
Browse files Browse the repository at this point in the history
…ssible-temp-dir-resolution, r=jieyouxu

Disable rmake test `inaccessible-temp-dir` on riscv64

In rust-lang#126279 the `inaccessible-temp-dir` test was moved to rmake, I followed up with a 'fix' derived from rust-lang#126355 in rust-lang#126707.

That 'fix' was misguided and hiding the true issue of the linker being incorrect for `riscv64gc-unknown-linux-gnu` (addressed in rust-lang#126916).

Unfortunately, even with the linker fixed, this test doesn't work. I asked myself why this appeared to work on other platforms and investigated why. Both the containers for `armhf-gnu` and `riscv64gc` run their tests as `root` and have `NO_CHANGE_USER` set:

https://github.com/rust-lang/rust/blob/553a69030e5a086eb3841d020db8c9c463948c72/src/ci/docker/host-x86_64/disabled/riscv64gc-gnu/Dockerfile#L99

This means the tests are run as `root`. As `root`, it's perfectly normal and reasonable to violate permission checks this way:

```bash
$ sudo mkdir scratch
$ sudo chmod o-w scratch
$ sudo mkdir scratch/backs
$
```

Because of this, this PR makes the test ignored on `riscv64gc` for now.

As an alternative, I believe the best long-term strategy would be to not run the tests as `root` for this job.

## Testing

> [!NOTE]
> `riscv64gc-unknown-linux-gnu` is a [**Tier 2 with Host Tools** platform](https://doc.rust-lang.org/beta/rustc/platform-support.html), all tests may not necessarily pass! This change should only ignore `inaccessible-temp-dir` and not affect other tests.

You can test out the job locally:

```sh
mv src/ci/docker/host-x86_64/disabled/riscv64gc-gnu src/ci/docker/host-x86_64/riscv64gc-gnu
DEPLOY=1 ./src/ci/docker/run.sh riscv64gc-gnu
```
  • Loading branch information
matthiaskrgr authored Jul 2, 2024
2 parents 0799a2c + 8c353cb commit 1aa14d0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/run-make/inaccessible-temp-dir/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@
// use a directory with non-existing parent like `/does-not-exist/output`.
// See https://github.com/rust-lang/rust/issues/66530

//@ ignore-riscv64
// FIXME: The riscv build container runs as root, and can always write
// into `inaccessible/tmp`. Ideally, the riscv64-gnu docker container
// would use a non-root user, but this leads to issues with
// `mkfs.ext4 -d`, as well as mounting a loop device for the rootfs.
//@ ignore-arm
// Reason: linker error on `armhf-gnu`
//@ ignore-windows
// Reason: `set_readonly` has no effect on directories
// and does not prevent modification.

use run_make_support::{fs_wrapper, rustc, target, test_while_readonly};
use run_make_support::{fs_wrapper, rustc, test_while_readonly};

fn main() {
// Create an inaccessible directory.
Expand All @@ -28,7 +33,6 @@ fn main() {
// Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one,
// so that it can't create `tmp`.
rustc()
.target(target())
.input("program.rs")
.arg("-Ztemps-dir=inaccessible/tmp")
.run_fail()
Expand Down

0 comments on commit 1aa14d0

Please sign in to comment.