Skip to content

Commit b7b096a

Browse files
Fensteernobody
authored andcommitted
Add test for tcp_congestion
1 parent 9ceb732 commit b7b096a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/sys/test_sockopt.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use rand::{thread_rng, Rng};
22
use nix::sys::socket::{socket, sockopt, getsockopt, setsockopt, AddressFamily, SockType, SockFlag, SockProtocol};
3+
use std::ffi::OsString;
34

45
#[test]
56
fn test_so_buf() {
@@ -13,3 +14,19 @@ fn test_so_buf() {
1314
let actual = getsockopt(fd, sockopt::RcvBuf).unwrap();
1415
assert!(actual >= bufsize);
1516
}
17+
18+
#[test]
19+
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
20+
fn test_tcp_congestion() {
21+
let fd = socket(AddressFamily::Inet, SockType::Stream, SockFlag::empty(), None).unwrap();
22+
23+
let val = getsockopt(fd, sockopt::TcpCongestion).unwrap();
24+
setsockopt(fd, sockopt::TcpCongestion, &val).unwrap();
25+
26+
setsockopt(fd, sockopt::TcpCongestion, &OsString::from("tcp_congestion_does_not_exist")).unwrap_err();
27+
28+
assert_eq!(
29+
getsockopt(fd, sockopt::TcpCongestion).unwrap(),
30+
val
31+
);
32+
}

0 commit comments

Comments
 (0)