diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-07-19 06:28:12 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-07-19 06:28:12 +0000 |
commit | 07e6c2f5c2d2a95fcfcd509556c4d1441a91adfb (patch) | |
tree | e5ae497aac510dacc277c5decbca2c10d80f880b /test/sys | |
parent | 3d24ae9588ebad1e495bedc909a226c84662a4c2 (diff) | |
parent | bee13c8c348324f7dabb5eed8d4be17be2c2efd2 (diff) | |
download | nix-07e6c2f5c2d2a95fcfcd509556c4d1441a91adfb.zip |
Merge #681
681: Remove feature flags r=Susurrus
These are vestiges of the initial push to get this working on Rust 1.0. These feature flags are undocumented and so hard to discover (only learned about them today!), prevent functions being included that should be and this also affects documentation on docs.rs, and none of the features are tested in CI and the `execvpe` has been broken for forever.
The solution is to conditionally compile everything supported for a given platform and do away completely with the feature flags. The `execvpe` function is completely removed as it's not available for *nix platforms in libc and is already broken, so no loss removing it. We'll add it back once it's back in libc (rust-lang/libc#670).
Closes #98.
Closes #206.
Closes #306.
Closes #308.
Diffstat (limited to 'test/sys')
-rw-r--r-- | test/sys/mod.rs | 2 | ||||
-rw-r--r-- | test/sys/test_aio.rs | 4 | ||||
-rw-r--r-- | test/sys/test_signalfd.rs | 26 | ||||
-rw-r--r-- | test/sys/test_uio.rs | 4 |
4 files changed, 32 insertions, 4 deletions
diff --git a/test/sys/mod.rs b/test/sys/mod.rs index 4edb6af0..2ecc36f8 100644 --- a/test/sys/mod.rs +++ b/test/sys/mod.rs @@ -2,6 +2,8 @@ mod test_signal; #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd", target_os = "macos", target_os = "linux"))] mod test_aio; +#[cfg(target_os = "linux")] +mod test_signalfd; mod test_socket; mod test_sockopt; mod test_termios; diff --git a/test/sys/test_aio.rs b/test/sys/test_aio.rs index 7e2bef63..54ee5a96 100644 --- a/test/sys/test_aio.rs +++ b/test/sys/test_aio.rs @@ -244,7 +244,7 @@ extern fn sigfunc(_: c_int) { #[cfg_attr(any(all(target_env = "musl", target_arch = "x86_64"), target_arch = "mips"), ignore)] fn test_write_sigev_signal() { #[allow(unused_variables)] - let m = ::SIGUSR2_MTX.lock().expect("Mutex got poisoned by another test"); + let m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test"); let sa = SigAction::new(SigHandler::Handler(sigfunc), SA_RESETHAND, SigSet::empty()); @@ -375,7 +375,7 @@ fn test_lio_listio_nowait() { #[cfg_attr(any(target_arch = "mips", target_env = "musl"), ignore)] fn test_lio_listio_signal() { #[allow(unused_variables)] - let m = ::SIGUSR2_MTX.lock().expect("Mutex got poisoned by another test"); + let m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test"); const INITIAL: &'static [u8] = b"abcdef123456"; const WBUF: &'static [u8] = b"CDEF"; let rbuf = Rc::new(vec![0; 4].into_boxed_slice()); diff --git a/test/sys/test_signalfd.rs b/test/sys/test_signalfd.rs new file mode 100644 index 00000000..6d65e6a0 --- /dev/null +++ b/test/sys/test_signalfd.rs @@ -0,0 +1,26 @@ +#[test] +fn test_signalfd() { + use nix::sys::signalfd::SignalFd; + use nix::sys::signal::{self, raise, Signal, SigSet}; + + // Grab the mutex for altering signals so we don't interfere with other tests. + #[allow(unused_variables)] + let m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test"); + + // Block the SIGUSR1 signal from automatic processing for this thread + let mut mask = SigSet::empty(); + mask.add(signal::SIGUSR1); + mask.thread_block().unwrap(); + + let mut fd = SignalFd::new(&mask).unwrap(); + + // Send a SIGUSR1 signal to the current process. Note that this uses `raise` instead of `kill` + // because `kill` with `getpid` isn't correct during multi-threaded execution like during a + // cargo test session. Instead use `raise` which does the correct thing by default. + raise(signal::SIGUSR1).ok().expect("Error: raise(SIGUSR1) failed"); + + // And now catch that same signal. + let res = fd.read_signal().unwrap().unwrap(); + let signo = Signal::from_c_int(res.ssi_signo as i32).unwrap(); + assert_eq!(signo, signal::SIGUSR1); +} diff --git a/test/sys/test_uio.rs b/test/sys/test_uio.rs index 90cda56f..d805b3b3 100644 --- a/test/sys/test_uio.rs +++ b/test/sys/test_uio.rs @@ -129,7 +129,7 @@ fn test_pread() { } #[test] -#[cfg(feature = "preadv_pwritev")] +#[cfg(target_os = "linux")] fn test_pwritev() { use std::io::Read; @@ -159,7 +159,7 @@ fn test_pwritev() { } #[test] -#[cfg(feature = "preadv_pwritev")] +#[cfg(target_os = "linux")] fn test_preadv() { use std::io::Write; |