diff options
author | Alan Somers <asomers@gmail.com> | 2020-12-02 17:47:35 -0700 |
---|---|---|
committer | Alan Somers <asomers@gmail.com> | 2020-12-06 22:35:30 -0700 |
commit | bf7a5fd606ba48c789bdaf95da2779e46e5f83c6 (patch) | |
tree | 5ff9c603b744eff0c5d1763df5220a661087bb5f /test/test.rs | |
parent | a1eb89568e50132339b5e8a1d5166fb5b5f9b0e8 (diff) | |
download | nix-bf7a5fd606ba48c789bdaf95da2779e46e5f83c6.zip |
Switch all builds from Travis to Cirrus
Travis has been super-slow lately (> 6 hours per build). Cirrus is much
faster: about 20 minutes. Cirrus also has slightly better test
coverage, mainly because it doesn't use SECCOMP.
Also,
* Fix the Redox CI build. The old Travis configuration didn't actually
build for Redox, so we never noticed that Redox can't be built with a
stable compiler. Thanks to @coolreader18 for finding this.
* Disable the udp_offload tests on cross-tested platforms. These tests
are failing with ENOPROTOOPT in Cirrus-CI. I suspect it's due to a
lack of support in QEMU. These tests were skipped on Travis because
its kernel was too old.
* Fix require_kernel_version on Cirrus-CI. Cirrus reports the Linux
kernel version as 4.19.112+, which the semver crate can't handle.
* Fix test_setfsuid on Cirrus. When run on Cirrus, it seems like the
file in /tmp gets deleted as soon as it's closed. Probably an
overzealous temporary file cleaner. Use /var/tmp, because no
temporary file cleaner should run in there.
* Skip mount tests on Cirrus. They fail for an unknown reason.
Issue #1351
* Skip the AF_ALG tests on Cirrus-CI
Issue #1352
Diffstat (limited to 'test/test.rs')
-rw-r--r-- | test/test.rs | 111 |
1 files changed, 2 insertions, 109 deletions
diff --git a/test/test.rs b/test/test.rs index 37c81f94..b57c1a66 100644 --- a/test/test.rs +++ b/test/test.rs @@ -5,115 +5,7 @@ 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}; - - if !has_cap(None, CapSet::Effective, Capability::$capname) - .unwrap() - { - skip!("Insufficient capabilities. Skipping test."); - } - } - } - } else if #[cfg(not(target_os = "redox"))] { - macro_rules! require_capability { - ($capname:ident) => {} - } - } -} - -#[cfg(target_os = "freebsd")] -macro_rules! skip_if_jailed { - ($name:expr) => { - use ::sysctl::CtlValue; - - if let CtlValue::Int(1) = ::sysctl::value("security.jail.jailed") - .unwrap() - { - skip!("{} cannot run in a jail. Skipping test.", $name); - } - } -} - -#[cfg(not(target_os = "redox"))] -macro_rules! skip_if_not_root { - ($name:expr) => { - use nix::unistd::Uid; - - if !Uid::current().is_root() { - skip!("{} requires root privileges. Skipping test.", $name); - } - }; -} - -cfg_if! { - if #[cfg(any(target_os = "android", target_os = "linux"))] { - macro_rules! skip_if_seccomp { - ($name:expr) => { - if let Ok(s) = std::fs::read_to_string("/proc/self/status") { - for l in s.lines() { - let mut fields = l.split_whitespace(); - if fields.next() == Some("Seccomp:") && - fields.next() != Some("0") - { - skip!("{} cannot be run in Seccomp mode. Skipping test.", - stringify!($name)); - } - } - } - } - } - } else if #[cfg(not(target_os = "redox"))] { - macro_rules! skip_if_seccomp { - ($name:expr) => {} - } - } -} - -cfg_if! { - if #[cfg(target_os = "linux")] { - macro_rules! require_kernel_version { - ($name:expr, $version_requirement:expr) => { - use semver::{Version, VersionReq}; - - let version_requirement = VersionReq::parse($version_requirement) - .expect("Bad match_version provided"); - - let uname = nix::sys::utsname::uname(); - - // Linux may report version as 4.18.el8_2.x86_64 or 5.18.200-fc33.x86_64 - // semver sematics does not support underscore. Replace this with hypen. - let mut version = Version::parse( - &uname.release().to_string().replace("_", "-") - ).unwrap(); - - //Keep only numeric parts - version.pre.clear(); - version.build.clear(); - - if !version_requirement.matches(&version) { - skip!("Skip {} because kernel version `{}` doesn't match the requirement `{}`", - stringify!($name), version, version_requirement); - } - } - } - } -} - +mod common; mod sys; #[cfg(not(target_os = "redox"))] mod test_dir; @@ -151,6 +43,7 @@ use std::path::PathBuf; use std::sync::{Mutex, RwLock, RwLockWriteGuard}; use nix::unistd::{chdir, getcwd, read}; + /// Helper function analogous to `std::io::Read::read_exact`, but for `RawFD`s fn read_exact(f: RawFd, buf: &mut [u8]) { let mut len = 0; |