Skip to content

Commit ca173ff

Browse files
authored
Fix the mount tests (#2269)
* 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
1 parent 0dfcf32 commit ca173ff

File tree

5 files changed

+162
-243
lines changed

5 files changed

+162
-243
lines changed

.github/actions/test/action.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ inputs:
55
TARGET:
66
required: true
77

8+
SUDO:
9+
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"'
10+
required: false
11+
default: sudo --preserve-env=HOME
12+
813
TOOL:
914
description: 'Tool used to involve the test command, can be cargo or cross'
1015
required: false
@@ -24,4 +29,4 @@ runs:
2429
2530
- name: test
2631
shell: bash
27-
run: ${{ inputs.TOOL }} test --target ${{ inputs.TARGET }} --all-features
32+
run: ${{ inputs.SUDO }} $(which ${{ inputs.TOOL }}) test --target ${{ inputs.TARGET }} --all-features

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ jobs:
9292
uses: ./.github/actions/test
9393
with:
9494
TARGET: '${{ matrix.target }}'
95+
SUDO: ""
9596
TOOL: cross
9697
RUSTFLAGS: --cfg qemu -D warnings
9798

Cargo.toml

-5
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ path = "test/sys/test_aio_drop.rs"
9999
name = "test-clearenv"
100100
path = "test/test_clearenv.rs"
101101

102-
[[test]]
103-
name = "test-mount"
104-
path = "test/test_mount.rs"
105-
harness = false
106-
107102
[[test]]
108103
name = "test-prctl"
109104
path = "test/sys/test_prctl.rs"

test/test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ mod test_errno;
1111
mod test_fcntl;
1212
#[cfg(linux_android)]
1313
mod test_kmod;
14+
#[cfg(target_os = "linux")]
15+
mod test_mount;
1416
#[cfg(any(
1517
freebsdlike,
1618
target_os = "fushsia",

0 commit comments

Comments
 (0)