Skip to content

Commit

Permalink
Merge #1224
Browse files Browse the repository at this point in the history
1224: Update the Linux CI environment to Ubuntu Bionic r=asomers a=asomers



Co-authored-by: Alan Somers <asomers@gmail.com>
Co-authored-by: Alan Somers <asomers@axcient.com>
  • Loading branch information
3 people committed Jul 25, 2020
2 parents b1ba074 + ec05dd7 commit 57b6bd7
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,7 +1,7 @@
# Based on the "trust" template v0.1.1
# https://github.com/japaric/trust/tree/v0.1.1

dist: trusty
dist: bionic
language: rust
services: docker

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -17,7 +17,7 @@ exclude = [
]

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

Expand Down
2 changes: 2 additions & 0 deletions src/sys/statfs.rs
Expand Up @@ -72,6 +72,8 @@ pub const NFS_SUPER_MAGIC: FsType = FsType(libc::NFS_SUPER_MAGIC);
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
pub const OPENPROM_SUPER_MAGIC: FsType = FsType(libc::OPENPROM_SUPER_MAGIC);
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
pub const OVERLAYFS_SUPER_MAGIC: FsType = FsType(libc::OVERLAYFS_SUPER_MAGIC);
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
pub const PROC_SUPER_MAGIC: FsType = FsType(libc::PROC_SUPER_MAGIC);
#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))]
pub const QNX4_SUPER_MAGIC: FsType = FsType(libc::QNX4_SUPER_MAGIC);
Expand Down
2 changes: 2 additions & 0 deletions test/sys/test_ptrace.rs
Expand Up @@ -128,6 +128,8 @@ fn test_ptrace_syscall() {
use nix::unistd::getpid;
use nix::unistd::ForkResult::*;

require_capability!(CAP_SYS_PTRACE);

let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");

match fork().expect("Error: Fork Failed") {
Expand Down
51 changes: 18 additions & 33 deletions test/test.rs
Expand Up @@ -5,22 +5,27 @@ extern crate nix;
#[macro_use]
extern crate lazy_static;

macro_rules! skip {
($($reason: expr),+) => {
use ::std::io::{self, Write};

let stderr = io::stderr();
let mut handle = stderr.lock();
writeln!(handle, $($reason),+).unwrap();
return;
}
}

cfg_if! {
if #[cfg(any(target_os = "android", target_os = "linux"))] {
macro_rules! require_capability {
($capname:ident) => {
use ::caps::{Capability, CapSet, has_cap};
use ::std::io::{self, Write};

if !has_cap(None, CapSet::Effective, Capability::$capname)
.unwrap()
{
let stderr = io::stderr();
let mut handle = stderr.lock();
writeln!(handle,
"Insufficient capabilities. Skipping test.")
.unwrap();
return;
skip!("Insufficient capabilities. Skipping test.");
}
}
}
Expand All @@ -39,12 +44,7 @@ macro_rules! skip_if_jailed {
if let CtlValue::Int(1) = ::sysctl::value("security.jail.jailed")
.unwrap()
{
use ::std::io::Write;
let stderr = ::std::io::stderr();
let mut handle = stderr.lock();
writeln!(handle, "{} cannot run in a jail. Skipping test.", $name)
.unwrap();
return;
skip!("{} cannot run in a jail. Skipping test.", $name);
}
}
}
Expand All @@ -55,11 +55,7 @@ macro_rules! skip_if_not_root {
use nix::unistd::Uid;

if !Uid::current().is_root() {
use ::std::io::Write;
let stderr = ::std::io::stderr();
let mut handle = stderr.lock();
writeln!(handle, "{} requires root privileges. Skipping test.", $name).unwrap();
return;
skip!("{} requires root privileges. Skipping test.", $name);
}
};
}
Expand All @@ -74,13 +70,8 @@ cfg_if! {
if fields.next() == Some("Seccomp:") &&
fields.next() != Some("0")
{
use ::std::io::Write;
let stderr = ::std::io::stderr();
let mut handle = stderr.lock();
writeln!(handle,
"{} cannot be run in Seccomp mode. Skipping test.",
stringify!($name)).unwrap();
return;
skip!("{} cannot be run in Seccomp mode. Skipping test.",
stringify!($name));
}
}
}
Expand All @@ -97,7 +88,6 @@ cfg_if! {
if #[cfg(target_os = "linux")] {
macro_rules! require_kernel_version {
($name:expr, $version_requirement:expr) => {
use ::std::io::Write;
use semver::{Version, VersionReq};

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

if !version_requirement.matches(&version) {
let stderr = ::std::io::stderr();
let mut handle = stderr.lock();

writeln!(handle,
"Skip {} because kernel version `{}` doesn't match the requirement `{}`",
stringify!($name), version, version_requirement).unwrap();
return;
skip!("Skip {} because kernel version `{}` doesn't match the requirement `{}`",
stringify!($name), version, version_requirement);
}
}
}
Expand Down
20 changes: 18 additions & 2 deletions test/test_fcntl.rs
Expand Up @@ -228,11 +228,19 @@ mod linux_android {
target_arch = "mips64",
target_arch = "mips64el",
target_arch = "powerpc64",
target_arch = "powerpc64le")))]
target_arch = "powerpc64le",
target_env = "musl")))]
fn test_ofd_write_lock() {
let tmp = NamedTempFile::new().unwrap();

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

let mut flock = libc::flock {
Expand Down Expand Up @@ -262,11 +270,19 @@ mod linux_android {
target_arch = "mips64",
target_arch = "mips64el",
target_arch = "powerpc64",
target_arch = "powerpc64le")))]
target_arch = "powerpc64le",
target_env = "musl")))]
fn test_ofd_read_lock() {
let tmp = NamedTempFile::new().unwrap();

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

let mut flock = libc::flock {
Expand Down
2 changes: 1 addition & 1 deletion test/test_unistd.rs
Expand Up @@ -936,7 +936,7 @@ fn test_access_file_exists() {
#[test]
fn test_setfsuid() {
use std::os::unix::fs::PermissionsExt;
use std::{fs, thread};
use std::{fs, io, thread};
require_capability!(CAP_SETUID);

// get the UID of the "nobody" user
Expand Down

0 comments on commit 57b6bd7

Please sign in to comment.