Skip to content

Commit 54881b8

Browse files
committed
Skip mount tests on Cirrus
They fail for an unknown reason. Issue #1351
1 parent c370fba commit 54881b8

File tree

12 files changed

+150
-163
lines changed

12 files changed

+150
-163
lines changed

.cirrus.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ task:
122122
container:
123123
image: rust:1.36
124124
setup_script:
125-
- setenforce 0
126125
- rustup toolchain install $TOOLCHAIN
127126
- rustup target add --toolchain $TOOLCHAIN $TARGET
128127
- id

test/common/mod.rs

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
use cfg_if::cfg_if;
2+
3+
#[macro_export] macro_rules! skip {
4+
($($reason: expr),+) => {
5+
use ::std::io::{self, Write};
6+
7+
let stderr = io::stderr();
8+
let mut handle = stderr.lock();
9+
writeln!(handle, $($reason),+).unwrap();
10+
return;
11+
}
12+
}
13+
14+
cfg_if! {
15+
if #[cfg(any(target_os = "android", target_os = "linux"))] {
16+
#[macro_export] macro_rules! require_capability {
17+
($capname:ident) => {
18+
use ::caps::{Capability, CapSet, has_cap};
19+
20+
if !has_cap(None, CapSet::Effective, Capability::$capname)
21+
.unwrap()
22+
{
23+
skip!("Insufficient capabilities. Skipping test.");
24+
}
25+
}
26+
}
27+
} else if #[cfg(not(target_os = "redox"))] {
28+
#[macro_export] macro_rules! require_capability {
29+
($capname:ident) => {}
30+
}
31+
}
32+
}
33+
34+
#[cfg(any(target_os = "linux", target_os= "android"))]
35+
#[macro_export] macro_rules! skip_if_cirrus {
36+
($reason:expr) => {
37+
if std::env::var_os("CIRRUS_CI").is_some() {
38+
skip!("{}", $reason);
39+
}
40+
}
41+
}
42+
43+
#[cfg(target_os = "freebsd")]
44+
#[macro_export] macro_rules! skip_if_jailed {
45+
($name:expr) => {
46+
use ::sysctl::CtlValue;
47+
48+
if let CtlValue::Int(1) = ::sysctl::value("security.jail.jailed")
49+
.unwrap()
50+
{
51+
skip!("{} cannot run in a jail. Skipping test.", $name);
52+
}
53+
}
54+
}
55+
56+
#[cfg(not(target_os = "redox"))]
57+
#[macro_export] macro_rules! skip_if_not_root {
58+
($name:expr) => {
59+
use nix::unistd::Uid;
60+
61+
if !Uid::current().is_root() {
62+
skip!("{} requires root privileges. Skipping test.", $name);
63+
}
64+
};
65+
}
66+
67+
cfg_if! {
68+
if #[cfg(any(target_os = "android", target_os = "linux"))] {
69+
#[macro_export] macro_rules! skip_if_seccomp {
70+
($name:expr) => {
71+
if let Ok(s) = std::fs::read_to_string("/proc/self/status") {
72+
for l in s.lines() {
73+
let mut fields = l.split_whitespace();
74+
if fields.next() == Some("Seccomp:") &&
75+
fields.next() != Some("0")
76+
{
77+
skip!("{} cannot be run in Seccomp mode. Skipping test.",
78+
stringify!($name));
79+
}
80+
}
81+
}
82+
}
83+
}
84+
} else if #[cfg(not(target_os = "redox"))] {
85+
#[macro_export] macro_rules! skip_if_seccomp {
86+
($name:expr) => {}
87+
}
88+
}
89+
}
90+
91+
cfg_if! {
92+
if #[cfg(target_os = "linux")] {
93+
#[macro_export] macro_rules! require_kernel_version {
94+
($name:expr, $version_requirement:expr) => {
95+
use semver::{Version, VersionReq};
96+
97+
let version_requirement = VersionReq::parse($version_requirement)
98+
.expect("Bad match_version provided");
99+
100+
let uname = nix::sys::utsname::uname();
101+
println!("{}", uname.sysname());
102+
println!("{}", uname.nodename());
103+
println!("{}", uname.release());
104+
println!("{}", uname.version());
105+
println!("{}", uname.machine());
106+
107+
// Fix stuff that the semver parser can't handle
108+
let fixed_release = &uname.release().to_string()
109+
// Fedora 33 reports version as 4.18.el8_2.x86_64 or
110+
// 5.18.200-fc33.x86_64. Remove the underscore.
111+
.replace("_", "-")
112+
// Cirrus-CI reports version as 4.19.112+ . Remove the +
113+
.replace("+", "");
114+
let mut version = Version::parse(fixed_release).unwrap();
115+
116+
//Keep only numeric parts
117+
version.pre.clear();
118+
version.build.clear();
119+
120+
if !version_requirement.matches(&version) {
121+
skip!("Skip {} because kernel version `{}` doesn't match the requirement `{}`",
122+
stringify!($name), version, version_requirement);
123+
}
124+
}
125+
}
126+
}
127+
}

test/sys/test_ptrace.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use nix::sys::ptrace::Options;
88
#[cfg(any(target_os = "android", target_os = "linux"))]
99
use std::mem;
1010

11+
use crate::*;
12+
1113
#[test]
1214
fn test_ptrace() {
1315
// Just make sure ptrace can be called at all, for now.

test/sys/test_socket.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use std::slice;
99
use std::str::FromStr;
1010
use libc::c_char;
1111
use tempfile;
12+
#[cfg(any(target_os = "linux", target_os= "android"))]
13+
use crate::*;
1214

1315
#[test]
1416
pub fn test_inetv4_addr_to_sock_addr() {
@@ -1031,7 +1033,7 @@ fn test_too_large_cmsgspace() {
10311033
fn test_impl_scm_credentials_and_rights(mut space: Vec<u8>) {
10321034
use libc::ucred;
10331035
use nix::sys::uio::IoVec;
1034-
use nix::unistd::{pipe, read, write, close, getpid, getuid, getgid};
1036+
use nix::unistd::{pipe, write, close, getpid, getuid, getgid};
10351037
use nix::sys::socket::{socketpair, sendmsg, recvmsg, setsockopt,
10361038
SockType, SockFlag,
10371039
ControlMessage, ControlMessageOwned, MsgFlags};

test/sys/test_sockopt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use rand::{thread_rng, Rng};
22
use nix::sys::socket::{socket, sockopt, getsockopt, setsockopt, AddressFamily, SockType, SockFlag, SockProtocol};
3+
#[cfg(any(target_os = "android", target_os = "linux"))]
4+
use crate::*;
35

46
#[cfg(target_os = "linux")]
57
#[test]

test/sys/test_uio.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ fn test_process_vm_readv() {
203203
use nix::unistd::ForkResult::*;
204204
use nix::sys::signal::*;
205205
use nix::sys::wait::*;
206+
use crate::*;
206207

207208
require_capability!(CAP_SYS_PTRACE);
208209
let _ = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");

test/sys/test_wait.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ mod ptrace {
6767
use nix::unistd::*;
6868
use nix::unistd::ForkResult::*;
6969
use libc::_exit;
70+
use crate::*;
7071

7172
fn ptrace_child() -> ! {
7273
ptrace::traceme().unwrap();

test/test.rs

Lines changed: 2 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -5,132 +5,7 @@ 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-
19-
cfg_if! {
20-
if #[cfg(any(target_os = "android", target_os = "linux"))] {
21-
macro_rules! require_capability {
22-
($capname:ident) => {
23-
use ::caps::{Capability, CapSet, has_cap};
24-
25-
if !has_cap(None, CapSet::Effective, Capability::$capname)
26-
.unwrap()
27-
{
28-
skip!("Insufficient capabilities. Skipping test.");
29-
}
30-
}
31-
}
32-
} else if #[cfg(not(target_os = "redox"))] {
33-
macro_rules! require_capability {
34-
($capname:ident) => {}
35-
}
36-
}
37-
}
38-
39-
#[cfg(any(target_os = "linux", target_os= "android"))]
40-
macro_rules! skip_if_cirrus {
41-
($reason:expr) => {
42-
if std::env::var_os("CIRRUS_CI").is_some() {
43-
skip!("{}", $reason);
44-
}
45-
}
46-
}
47-
48-
#[cfg(target_os = "freebsd")]
49-
macro_rules! skip_if_jailed {
50-
($name:expr) => {
51-
use ::sysctl::CtlValue;
52-
53-
if let CtlValue::Int(1) = ::sysctl::value("security.jail.jailed")
54-
.unwrap()
55-
{
56-
skip!("{} cannot run in a jail. Skipping test.", $name);
57-
}
58-
}
59-
}
60-
61-
#[cfg(not(target_os = "redox"))]
62-
macro_rules! skip_if_not_root {
63-
($name:expr) => {
64-
use nix::unistd::Uid;
65-
66-
if !Uid::current().is_root() {
67-
skip!("{} requires root privileges. Skipping test.", $name);
68-
}
69-
};
70-
}
71-
72-
cfg_if! {
73-
if #[cfg(any(target_os = "android", target_os = "linux"))] {
74-
macro_rules! skip_if_seccomp {
75-
($name:expr) => {
76-
if let Ok(s) = std::fs::read_to_string("/proc/self/status") {
77-
for l in s.lines() {
78-
let mut fields = l.split_whitespace();
79-
if fields.next() == Some("Seccomp:") &&
80-
fields.next() != Some("0")
81-
{
82-
skip!("{} cannot be run in Seccomp mode. Skipping test.",
83-
stringify!($name));
84-
}
85-
}
86-
}
87-
}
88-
}
89-
} else if #[cfg(not(target_os = "redox"))] {
90-
macro_rules! skip_if_seccomp {
91-
($name:expr) => {}
92-
}
93-
}
94-
}
95-
96-
cfg_if! {
97-
if #[cfg(target_os = "linux")] {
98-
macro_rules! require_kernel_version {
99-
($name:expr, $version_requirement:expr) => {
100-
use semver::{Version, VersionReq};
101-
102-
let version_requirement = VersionReq::parse($version_requirement)
103-
.expect("Bad match_version provided");
104-
105-
let uname = nix::sys::utsname::uname();
106-
println!("{}", uname.sysname());
107-
println!("{}", uname.nodename());
108-
println!("{}", uname.release());
109-
println!("{}", uname.version());
110-
println!("{}", uname.machine());
111-
112-
// Fix stuff that the semver parser can't handle
113-
let fixed_release = &uname.release().to_string()
114-
// Fedora 33 reports version as 4.18.el8_2.x86_64 or
115-
// 5.18.200-fc33.x86_64. Remove the underscore.
116-
.replace("_", "-")
117-
// Cirrus-CI reports version as 4.19.112+ . Remove the +
118-
.replace("+", "");
119-
let mut version = Version::parse(fixed_release).unwrap();
120-
121-
//Keep only numeric parts
122-
version.pre.clear();
123-
version.build.clear();
124-
125-
if !version_requirement.matches(&version) {
126-
skip!("Skip {} because kernel version `{}` doesn't match the requirement `{}`",
127-
stringify!($name), version, version_requirement);
128-
}
129-
}
130-
}
131-
}
132-
}
133-
8+
mod common;
1349
mod sys;
13510
#[cfg(not(target_os = "redox"))]
13611
mod test_dir;
@@ -168,6 +43,7 @@ use std::path::PathBuf;
16843
use std::sync::{Mutex, RwLock, RwLockWriteGuard};
16944
use nix::unistd::{chdir, getcwd, read};
17045

46+
17147
/// Helper function analogous to `std::io::Read::read_exact`, but for `RawFD`s
17248
fn read_exact(f: RawFd, buf: &mut [u8]) {
17349
let mut len = 0;

test/test_fcntl.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use std::io::prelude::*;
1919
#[cfg(not(target_os = "redox"))]
2020
use std::os::unix::fs;
2121

22+
use crate::*;
23+
2224
#[test]
2325
#[cfg(not(target_os = "redox"))]
2426
fn test_openat() {
@@ -93,6 +95,8 @@ mod linux_android {
9395

9496
use tempfile::{tempfile, NamedTempFile};
9597

98+
use crate::*;
99+
96100
/// This test creates a temporary file containing the contents
97101
/// 'foobarbaz' and uses the `copy_file_range` call to transfer
98102
/// 3 bytes at offset 3 (`bar`) to another empty file at offset 0. The

test/test_kmod/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::fs::copy;
22
use std::path::PathBuf;
33
use std::process::Command;
44
use tempfile::{tempdir, TempDir};
5+
use crate::*;
56

67
fn compile_kernel_module() -> (PathBuf, String, TempDir) {
78
let _m = crate::FORK_MTX

0 commit comments

Comments
 (0)