Skip to content

Commit

Permalink
Make keepalive sockopt tests os dependent.
Browse files Browse the repository at this point in the history
  • Loading branch information
yoav-steinberg committed Sep 7, 2020
1 parent 16051ea commit 40e54c1
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions test/sys/test_sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,21 @@ fn test_so_tcp_keepalive() {
setsockopt(fd, sockopt::KeepAlive, &true).unwrap();
assert_eq!(getsockopt(fd, sockopt::KeepAlive).unwrap(), true);

let x = getsockopt(fd, sockopt::TcpKeepIdle).unwrap();
setsockopt(fd, sockopt::TcpKeepIdle, &(x+1)).unwrap();
assert_eq!(getsockopt(fd, sockopt::TcpKeepIdle).unwrap(), x+1);

let x = getsockopt(fd, sockopt::TcpKeepCount).unwrap();
setsockopt(fd, sockopt::TcpKeepCount, &(x+1)).unwrap();
assert_eq!(getsockopt(fd, sockopt::TcpKeepCount).unwrap(), x+1);

let x = getsockopt(fd, sockopt::TcpKeepInterval).unwrap();
setsockopt(fd, sockopt::TcpKeepInterval, &(x+1)).unwrap();
assert_eq!(getsockopt(fd, sockopt::TcpKeepInterval).unwrap(), x+1);
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "nacl"))] {
let x = getsockopt(fd, sockopt::TcpKeepIdle).unwrap();
setsockopt(fd, sockopt::TcpKeepIdle, &(x + 1)).unwrap();
assert_eq!(getsockopt(fd, sockopt::TcpKeepIdle).unwrap(), x + 1);

let x = getsockopt(fd, sockopt::TcpKeepCount).unwrap();
setsockopt(fd, sockopt::TcpKeepCount, &(x + 1)).unwrap();
assert_eq!(getsockopt(fd, sockopt::TcpKeepCount).unwrap(), x + 1);

let x = getsockopt(fd, sockopt::TcpKeepInterval).unwrap();
setsockopt(fd, sockopt::TcpKeepInterval, &(x + 1)).unwrap();
assert_eq!(getsockopt(fd, sockopt::TcpKeepInterval).unwrap(), x + 1);
}
}

0 comments on commit 40e54c1

Please sign in to comment.