diff options
author | Frank Denis <github@pureftpd.org> | 2016-01-29 12:00:46 +0100 |
---|---|---|
committer | Kamal Marhubi <kamal@marhubi.com> | 2016-01-29 16:48:08 -0500 |
commit | e04842ec519fb8bef4d8f76f4e1528225710ec45 (patch) | |
tree | f9db2ba54397177783c9f8093a29987cd15c2e05 /test/sys | |
parent | dc61f352f6b48503fb7ded86c87c84db62d8292c (diff) | |
download | nix-e04842ec519fb8bef4d8f76f4e1528225710ec45.zip |
Add tests for sockopt (SndBuf, RcvBuf, SndBufForce, RcvBufForce)
Diffstat (limited to 'test/sys')
-rw-r--r-- | test/sys/mod.rs | 1 | ||||
-rw-r--r-- | test/sys/test_sockopt.rs | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/test/sys/mod.rs b/test/sys/mod.rs index fd4e984d..a5f3351d 100644 --- a/test/sys/mod.rs +++ b/test/sys/mod.rs @@ -1,4 +1,5 @@ mod test_socket; +mod test_sockopt; mod test_termios; mod test_ioctl; mod test_wait; diff --git a/test/sys/test_sockopt.rs b/test/sys/test_sockopt.rs new file mode 100644 index 00000000..92769e52 --- /dev/null +++ b/test/sys/test_sockopt.rs @@ -0,0 +1,14 @@ +use rand::{thread_rng, Rng}; +use nix::sys::socket::{socket, sockopt, getsockopt, setsockopt, AddressFamily, SockType, SockFlag, SockLevel}; + +#[test] +fn test_so_buf() { + let fd = socket(AddressFamily::Inet, SockType::Datagram, SockFlag::empty(), SockLevel::Udp as i32).unwrap(); + let bufsize: usize = thread_rng().gen_range(4096, 131072); + setsockopt(fd, sockopt::SndBuf, &bufsize).unwrap(); + let actual = getsockopt(fd, sockopt::SndBuf).unwrap(); + assert!(actual >= bufsize); + setsockopt(fd, sockopt::RcvBuf, &bufsize).unwrap(); + let actual = getsockopt(fd, sockopt::RcvBuf).unwrap(); + assert!(actual >= bufsize); +} |