Skip to content

Commit

Permalink
Fix the mount tests (#2269)
Browse files Browse the repository at this point in the history
* Fix the mount tests

As originally written by @kamalmarhubi in #231, these tests made
clever use of Linux namespaces in order to run as unprivileged users.
However, a subsequent kernel bug broke this functionality, and it hasn't
been fixed even 6 years later.  The tests have been skipped ever since.

Get the tests to run again by removing the namespace stuff and
requiring privileges instead.  Also, remove the custom test harness.
Now Nix will be compatible with tools like cargo-nextest.

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1659087

* Move the mount tests into the "test" program

Now that we aren't using namespaces, they don't need their own program.

* Use "sudo" to run tests on github workflows.

Because several of the tests require root privileges.

But don't use sudo with cross.  It fails due to a known issue upstream:
cross-rs/cross#526
  • Loading branch information
asomers committed Feb 9, 2024
1 parent 0dfcf32 commit ca173ff
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 243 deletions.
7 changes: 6 additions & 1 deletion .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ inputs:
TARGET:
required: true

SUDO:
description: 'Set it to an empty string to run the tests as the current user, leave it with the default value to test with "sudo"'
required: false
default: sudo --preserve-env=HOME

TOOL:
description: 'Tool used to involve the test command, can be cargo or cross'
required: false
Expand All @@ -24,4 +29,4 @@ runs:
- name: test
shell: bash
run: ${{ inputs.TOOL }} test --target ${{ inputs.TARGET }} --all-features
run: ${{ inputs.SUDO }} $(which ${{ inputs.TOOL }}) test --target ${{ inputs.TARGET }} --all-features
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
uses: ./.github/actions/test
with:
TARGET: '${{ matrix.target }}'
SUDO: ""
TOOL: cross
RUSTFLAGS: --cfg qemu -D warnings

Expand Down
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ path = "test/sys/test_aio_drop.rs"
name = "test-clearenv"
path = "test/test_clearenv.rs"

[[test]]
name = "test-mount"
path = "test/test_mount.rs"
harness = false

[[test]]
name = "test-prctl"
path = "test/sys/test_prctl.rs"
2 changes: 2 additions & 0 deletions test/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ mod test_errno;
mod test_fcntl;
#[cfg(linux_android)]
mod test_kmod;
#[cfg(target_os = "linux")]
mod test_mount;
#[cfg(any(
freebsdlike,
target_os = "fushsia",
Expand Down

0 comments on commit ca173ff

Please sign in to comment.