Skip to content

Commit 6a37860

Browse files
committed
Merge #633
633: Skip the mount tests on kernel 4.4.0 r=asomers Some versions of that kernel have a known bug with tmpfs in namespaces. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1659087 Fixes #610
2 parents 274b09e + 899d20b commit 6a37860

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/test_mount.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ 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};
@@ -49,6 +50,23 @@ exit 23";
4950
.write(true)
5051
.mode((S_IRWXU | S_IRWXG | S_IRWXO).bits())
5152
.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+
)
5270
.and_then(|mut f| f.write(SCRIPT_CONTENTS))
5371
.unwrap_or_else(|e| panic!("write failed: {}", e));
5472

0 commit comments

Comments
 (0)