Skip to content

Commit 57b6bd7

Browse files
bors[bot]asomersasomers-ax
authored
Merge #1224
1224: Update the Linux CI environment to Ubuntu Bionic r=asomers a=asomers Co-authored-by: Alan Somers <[email protected]> Co-authored-by: Alan Somers <[email protected]>
2 parents b1ba074 + ec05dd7 commit 57b6bd7

File tree

7 files changed

+43
-38
lines changed

7 files changed

+43
-38
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Based on the "trust" template v0.1.1
22
# https://github.com/japaric/trust/tree/v0.1.1
33

4-
dist: trusty
4+
dist: bionic
55
language: rust
66
services: docker
77

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exclude = [
1717
]
1818

1919
[dependencies]
20-
libc = { git = "https://github.com/rust-lang/libc/", features = [ "extra_traits" ] }
20+
libc = { git = "https://github.com/rust-lang/libc/", rev = "fdc5cf4a1ba362aec989bd3dc7ec88bcd371a23a", features = [ "extra_traits" ] }
2121
bitflags = "1.1"
2222
cfg-if = "0.1.10"
2323

src/sys/statfs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ pub const NFS_SUPER_MAGIC: FsType = FsType(libc::NFS_SUPER_MAGIC);
7272
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
7373
pub const OPENPROM_SUPER_MAGIC: FsType = FsType(libc::OPENPROM_SUPER_MAGIC);
7474
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
75+
pub const OVERLAYFS_SUPER_MAGIC: FsType = FsType(libc::OVERLAYFS_SUPER_MAGIC);
76+
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
7577
pub const PROC_SUPER_MAGIC: FsType = FsType(libc::PROC_SUPER_MAGIC);
7678
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
7779
pub const QNX4_SUPER_MAGIC: FsType = FsType(libc::QNX4_SUPER_MAGIC);

test/sys/test_ptrace.rs

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ fn test_ptrace_syscall() {
128128
use nix::unistd::getpid;
129129
use nix::unistd::ForkResult::*;
130130

131+
require_capability!(CAP_SYS_PTRACE);
132+
131133
let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
132134

133135
match fork().expect("Error: Fork Failed") {

test/test.rs

+18-33
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@ extern crate nix;
55
#[macro_use]
66
extern crate lazy_static;
77

8+
macro_rules! skip {
9+
($($reason: expr),+) => {
10+
use ::std::io::{self, Write};
11+
12+
let stderr = io::stderr();
13+
let mut handle = stderr.lock();
14+
writeln!(handle, $($reason),+).unwrap();
15+
return;
16+
}
17+
}
18+
819
cfg_if! {
920
if #[cfg(any(target_os = "android", target_os = "linux"))] {
1021
macro_rules! require_capability {
1122
($capname:ident) => {
1223
use ::caps::{Capability, CapSet, has_cap};
13-
use ::std::io::{self, Write};
1424

1525
if !has_cap(None, CapSet::Effective, Capability::$capname)
1626
.unwrap()
1727
{
18-
let stderr = io::stderr();
19-
let mut handle = stderr.lock();
20-
writeln!(handle,
21-
"Insufficient capabilities. Skipping test.")
22-
.unwrap();
23-
return;
28+
skip!("Insufficient capabilities. Skipping test.");
2429
}
2530
}
2631
}
@@ -39,12 +44,7 @@ macro_rules! skip_if_jailed {
3944
if let CtlValue::Int(1) = ::sysctl::value("security.jail.jailed")
4045
.unwrap()
4146
{
42-
use ::std::io::Write;
43-
let stderr = ::std::io::stderr();
44-
let mut handle = stderr.lock();
45-
writeln!(handle, "{} cannot run in a jail. Skipping test.", $name)
46-
.unwrap();
47-
return;
47+
skip!("{} cannot run in a jail. Skipping test.", $name);
4848
}
4949
}
5050
}
@@ -55,11 +55,7 @@ macro_rules! skip_if_not_root {
5555
use nix::unistd::Uid;
5656

5757
if !Uid::current().is_root() {
58-
use ::std::io::Write;
59-
let stderr = ::std::io::stderr();
60-
let mut handle = stderr.lock();
61-
writeln!(handle, "{} requires root privileges. Skipping test.", $name).unwrap();
62-
return;
58+
skip!("{} requires root privileges. Skipping test.", $name);
6359
}
6460
};
6561
}
@@ -74,13 +70,8 @@ cfg_if! {
7470
if fields.next() == Some("Seccomp:") &&
7571
fields.next() != Some("0")
7672
{
77-
use ::std::io::Write;
78-
let stderr = ::std::io::stderr();
79-
let mut handle = stderr.lock();
80-
writeln!(handle,
81-
"{} cannot be run in Seccomp mode. Skipping test.",
82-
stringify!($name)).unwrap();
83-
return;
73+
skip!("{} cannot be run in Seccomp mode. Skipping test.",
74+
stringify!($name));
8475
}
8576
}
8677
}
@@ -97,7 +88,6 @@ cfg_if! {
9788
if #[cfg(target_os = "linux")] {
9889
macro_rules! require_kernel_version {
9990
($name:expr, $version_requirement:expr) => {
100-
use ::std::io::Write;
10191
use semver::{Version, VersionReq};
10292

10393
let version_requirement = VersionReq::parse($version_requirement)
@@ -112,13 +102,8 @@ cfg_if! {
112102
version.build.clear();
113103

114104
if !version_requirement.matches(&version) {
115-
let stderr = ::std::io::stderr();
116-
let mut handle = stderr.lock();
117-
118-
writeln!(handle,
119-
"Skip {} because kernel version `{}` doesn't match the requirement `{}`",
120-
stringify!($name), version, version_requirement).unwrap();
121-
return;
105+
skip!("Skip {} because kernel version `{}` doesn't match the requirement `{}`",
106+
stringify!($name), version, version_requirement);
122107
}
123108
}
124109
}

test/test_fcntl.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,19 @@ mod linux_android {
228228
target_arch = "mips64",
229229
target_arch = "mips64el",
230230
target_arch = "powerpc64",
231-
target_arch = "powerpc64le")))]
231+
target_arch = "powerpc64le",
232+
target_env = "musl")))]
232233
fn test_ofd_write_lock() {
233234
let tmp = NamedTempFile::new().unwrap();
234235

235236
let fd = tmp.as_raw_fd();
237+
let statfs = nix::sys::statfs::fstatfs(&tmp).unwrap();
238+
if statfs.filesystem_type() == nix::sys::statfs::OVERLAYFS_SUPER_MAGIC {
239+
// OverlayFS is a union file system. It returns one inode value in
240+
// stat(2), but a different one shows up in /proc/locks. So we must
241+
// skip the test.
242+
skip!("/proc/locks does not work on overlayfs");
243+
}
236244
let inode = fstat(fd).expect("fstat failed").st_ino as usize;
237245

238246
let mut flock = libc::flock {
@@ -262,11 +270,19 @@ mod linux_android {
262270
target_arch = "mips64",
263271
target_arch = "mips64el",
264272
target_arch = "powerpc64",
265-
target_arch = "powerpc64le")))]
273+
target_arch = "powerpc64le",
274+
target_env = "musl")))]
266275
fn test_ofd_read_lock() {
267276
let tmp = NamedTempFile::new().unwrap();
268277

269278
let fd = tmp.as_raw_fd();
279+
let statfs = nix::sys::statfs::fstatfs(&tmp).unwrap();
280+
if statfs.filesystem_type() == nix::sys::statfs::OVERLAYFS_SUPER_MAGIC {
281+
// OverlayFS is a union file system. It returns one inode value in
282+
// stat(2), but a different one shows up in /proc/locks. So we must
283+
// skip the test.
284+
skip!("/proc/locks does not work on overlayfs");
285+
}
270286
let inode = fstat(fd).expect("fstat failed").st_ino as usize;
271287

272288
let mut flock = libc::flock {

test/test_unistd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ fn test_access_file_exists() {
936936
#[test]
937937
fn test_setfsuid() {
938938
use std::os::unix::fs::PermissionsExt;
939-
use std::{fs, thread};
939+
use std::{fs, io, thread};
940940
require_capability!(CAP_SETUID);
941941

942942
// get the UID of the "nobody" user

0 commit comments

Comments
 (0)