Skip to content

Commit a1d6764

Browse files
committed
Always run the mount tests, but "skip" (actually pass) when the buggy
errno is returned.
1 parent 3873c49 commit a1d6764

File tree

4 files changed

+74
-23
lines changed

4 files changed

+74
-23
lines changed

.travis.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,74 @@ matrix:
1616
# don't need
1717
include:
1818
# Linux
19+
- env: TARGET=aarch64-unknown-linux-gnu
20+
rust: 1.13.0
21+
- env: TARGET=arm-unknown-linux-gnueabi
22+
rust: 1.13.0
23+
# - env: TARGET=arm-unknown-linux-musleabi
24+
- env: TARGET=armv7-unknown-linux-gnueabihf
25+
rust: 1.13.0
26+
- env: TARGET=i686-unknown-linux-gnu
27+
rust: 1.13.0
28+
- env: TARGET=i686-unknown-linux-musl
29+
rust: 1.13.0
30+
- env: TARGET=mips-unknown-linux-gnu
31+
rust: 1.13.0
32+
# - env: TARGET=mips64-unknown-linux-gnuabi64
33+
# - env: TARGET=mips64el-unknown-linux-gnuabi64
34+
- env: TARGET=mipsel-unknown-linux-gnu
35+
rust: 1.13.0
36+
- env: TARGET=powerpc-unknown-linux-gnu
37+
rust: 1.13.0
38+
- env: TARGET=powerpc64-unknown-linux-gnu
39+
rust: 1.13.0
40+
- env: TARGET=powerpc64le-unknown-linux-gnu
41+
rust: 1.13.0
42+
# - env: TARGET=s390x-unknown-linux-gnu
1943
- env: TARGET=x86_64-unknown-linux-gnu
2044
rust: 1.13.0
45+
- env: TARGET=x86_64-unknown-linux-musl
46+
rust: 1.13.0
2147

2248
# OSX
49+
- env: TARGET=i686-apple-darwin
50+
rust: 1.13.0
51+
os: osx
2352
- env: TARGET=x86_64-apple-darwin
2453
rust: 1.13.0
2554
os: osx
2655

56+
# *BSD
57+
- env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1
58+
rust: 1.13.0
59+
# - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 # Uses BuildBot instead
60+
- env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1
61+
rust: 1.13.0
62+
2763
# Testing beta on main targets
2864
- env: TARGET=x86_64-unknown-linux-gnu
2965
rust: beta
66+
- env: TARGET=x86_64-apple-darwin
67+
os: osx
68+
rust: beta
3069

3170
# Testing nightly on main targets (allowed to fail)
3271
- env: TARGET=x86_64-unknown-linux-gnu
3372
rust: nightly
73+
- env: TARGET=x86_64-apple-darwin
74+
os: osx
75+
rust: nightly
76+
77+
# Testing nightlies on main targets. These might fail because of issues
78+
# with the compiler, so we allow failures here.
79+
allow_failures:
80+
# Failures for nightlies may be because of compiler bugs, so don't fail the
81+
# build if these fail.
82+
- env: TARGET=x86_64-unknown-linux-gnu
83+
rust: nightly
84+
- env: TARGET=x86_64-apple-darwin
85+
os: osx
86+
rust: nightly
3487

3588
before_install: set -e
3689

ci/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ main() {
1717
| $sort --version-sort \
1818
| tail -n1)
1919
curl -LSfs https://japaric.github.io/trust/install.sh | \
20-
sh -xs -- \
20+
sh -s -- \
2121
--force \
2222
--git japaric/cross \
2323
--tag $tag \

ci/script.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ main() {
99
fi
1010

1111
# Build debug and release targets
12-
rustup default stable-x86_64-unknown-linux-gnu # XXX does cross require a default toolchain?
1312
cross build --target $TARGET
1413
cross build --target $TARGET --release
1514

test/test_mount.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ mod test_mount {
1717

1818
use libc::{EACCES, EROFS};
1919

20+
use nix::errno::Errno;
2021
use nix::mount::{mount, umount, MsFlags, MS_BIND, MS_RDONLY, MS_NOEXEC};
2122
use nix::sched::{unshare, CLONE_NEWNS, CLONE_NEWUSER};
2223
use nix::sys::stat::{self, S_IRWXU, S_IRWXG, S_IRWXO, S_IXUSR, S_IXGRP, S_IXOTH};
2324
use nix::unistd::getuid;
24-
use nix::sys::utsname;
2525

2626
use tempdir::TempDir;
2727

@@ -31,20 +31,6 @@ exit 23";
3131
const EXPECTED_STATUS: i32 = 23;
3232

3333
const NONE: Option<&'static [u8]> = None;
34-
35-
// Skip tests on kernel 4.4.0, which has a bug regarding tmpfs in namespaces
36-
// https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1659087
37-
pub fn check_kernel() {
38-
let u = utsname::uname();
39-
if u.release().starts_with("4.4.0") {
40-
let stderr = io::stderr();
41-
let mut handle = stderr.lock();
42-
writeln!(handle, "Linux kernel 4.4.0 has known bugs with tmpfs in namespaces. Skipping test.")
43-
.unwrap();
44-
process::exit(0);
45-
}
46-
}
47-
4834
pub fn test_mount_tmpfs_without_flags_allows_rwx() {
4935
let tempdir = TempDir::new("nix-test_mount")
5036
.unwrap_or_else(|e| panic!("tempdir failed: {}", e));
@@ -64,6 +50,23 @@ exit 23";
6450
.write(true)
6551
.mode((S_IRWXU | S_IRWXG | S_IRWXO).bits())
6652
.open(&test_path)
53+
.or_else(|e|
54+
if Errno::from_i32(e.raw_os_error().unwrap()) == Errno::EOVERFLOW {
55+
// Skip tests on certain Linux kernels which have a bug
56+
// regarding tmpfs in namespaces.
57+
// Ubuntu 14.04 and 16.04 are known to be affected; 16.10 is
58+
// not. There is no legitimate reason for open(2) to return
59+
// EOVERFLOW here.
60+
// https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1659087
61+
let stderr = io::stderr();
62+
let mut handle = stderr.lock();
63+
writeln!(handle, "Buggy Linux kernel detected. Skipping test.")
64+
.unwrap();
65+
process::exit(0);
66+
} else {
67+
panic!("open failed: {}", e);
68+
}
69+
)
6770
.and_then(|mut f| f.write(SCRIPT_CONTENTS))
6871
.unwrap_or_else(|e| panic!("write failed: {}", e));
6972

@@ -200,7 +203,6 @@ exit 23";
200203
.write(true)
201204
.open("/proc/self/uid_map")
202205
.and_then(|mut f| f.write(format!("1000 {} 1\n", uid).as_bytes()))
203-
//.and_then(|mut f| f.write(format!("1000 {} 1\n", uid).as_bytes()))
204206
.unwrap_or_else(|e| panic!("could not write uid map: {}", e));
205207
}
206208
}
@@ -225,12 +227,9 @@ macro_rules! run_tests {
225227

226228
#[cfg(target_os = "linux")]
227229
fn main() {
228-
use test_mount::{setup_namespaces, check_kernel,
229-
test_mount_tmpfs_without_flags_allows_rwx,
230-
test_mount_rdonly_disallows_write,
231-
test_mount_noexec_disallows_exec,
230+
use test_mount::{setup_namespaces, test_mount_tmpfs_without_flags_allows_rwx,
231+
test_mount_rdonly_disallows_write, test_mount_noexec_disallows_exec,
232232
test_mount_bind};
233-
check_kernel();
234233
setup_namespaces();
235234

236235
run_tests!(test_mount_tmpfs_without_flags_allows_rwx,

0 commit comments

Comments
 (0)