Skip to content

Remove tests that weren't mine #909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,65 +255,3 @@ pub fn test_syscontrol() {
// requires root privileges
// connect(fd, &sockaddr).expect("connect failed");
}

/// Test non-blocking mode on new sockets via SockFlag::O_NONBLOCK
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"))]
#[test]
pub fn test_sockflag_nonblock() {
use libc;
use nix::fcntl::{fcntl};
use nix::fcntl::FcntlArg::{F_GETFL};
use nix::sys::socket::{socket, AddressFamily, SockType, SockFlag};

/* first, try without SockFlag::SOCK_NONBLOCK */
let sock = socket(AddressFamily::Unix, SockType::Stream, SockFlag::empty(), None)
.expect("socket failed");

let fcntl_res = fcntl(sock, F_GETFL).expect("fcntl failed");

assert!(fcntl_res & libc::O_NONBLOCK == 0);

/* next, try with SockFlag::SOCK_NONBLOCK */
let sock = socket(AddressFamily::Unix, SockType::Stream, SockFlag::SOCK_NONBLOCK, None)
.expect("socket failed");

let fcntl_res = fcntl(sock, F_GETFL).expect("fcntl failed");

assert!(fcntl_res & libc::O_NONBLOCK == libc::O_NONBLOCK);
}

/// Test close-on-exec on new sockets via SockFlag::SOCK_CLOEXEC
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"))]
#[test]
pub fn test_sockflag_cloexec() {
use libc;
use nix::fcntl::{fcntl};
use nix::fcntl::FcntlArg::{F_GETFD};
use nix::sys::socket::{socket, AddressFamily, SockType, SockFlag};

/* first, test without SockFlag::SOCK_CLOEXEC */
let sock = socket(AddressFamily::Unix, SockType::Stream, SockFlag::empty(), None)
.expect("socket failed");

let fcntl_res = fcntl(sock, F_GETFD).expect("fcntl failed");

assert!(fcntl_res & libc::FD_CLOEXEC == 0);

/* next, test without SockFlag::SOCK_CLOEXEC */
let sock = socket(AddressFamily::Unix, SockType::Stream, SockFlag::SOCK_CLOEXEC, None)
.expect("socket failed");

let fcntl_res = fcntl(sock, F_GETFD).expect("fcntl failed");

assert!(fcntl_res & libc::FD_CLOEXEC == libc::FD_CLOEXEC);
}