Skip to content

Commit 40e54c1

Browse files
Make keepalive sockopt tests os dependent.
1 parent 16051ea commit 40e54c1

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

test/sys/test_sockopt.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,21 @@ fn test_so_tcp_keepalive() {
7474
setsockopt(fd, sockopt::KeepAlive, &true).unwrap();
7575
assert_eq!(getsockopt(fd, sockopt::KeepAlive).unwrap(), true);
7676

77-
let x = getsockopt(fd, sockopt::TcpKeepIdle).unwrap();
78-
setsockopt(fd, sockopt::TcpKeepIdle, &(x+1)).unwrap();
79-
assert_eq!(getsockopt(fd, sockopt::TcpKeepIdle).unwrap(), x+1);
80-
81-
let x = getsockopt(fd, sockopt::TcpKeepCount).unwrap();
82-
setsockopt(fd, sockopt::TcpKeepCount, &(x+1)).unwrap();
83-
assert_eq!(getsockopt(fd, sockopt::TcpKeepCount).unwrap(), x+1);
84-
85-
let x = getsockopt(fd, sockopt::TcpKeepInterval).unwrap();
86-
setsockopt(fd, sockopt::TcpKeepInterval, &(x+1)).unwrap();
87-
assert_eq!(getsockopt(fd, sockopt::TcpKeepInterval).unwrap(), x+1);
77+
#[cfg(any(target_os = "android",
78+
target_os = "dragonfly",
79+
target_os = "freebsd",
80+
target_os = "linux",
81+
target_os = "nacl"))] {
82+
let x = getsockopt(fd, sockopt::TcpKeepIdle).unwrap();
83+
setsockopt(fd, sockopt::TcpKeepIdle, &(x + 1)).unwrap();
84+
assert_eq!(getsockopt(fd, sockopt::TcpKeepIdle).unwrap(), x + 1);
85+
86+
let x = getsockopt(fd, sockopt::TcpKeepCount).unwrap();
87+
setsockopt(fd, sockopt::TcpKeepCount, &(x + 1)).unwrap();
88+
assert_eq!(getsockopt(fd, sockopt::TcpKeepCount).unwrap(), x + 1);
89+
90+
let x = getsockopt(fd, sockopt::TcpKeepInterval).unwrap();
91+
setsockopt(fd, sockopt::TcpKeepInterval, &(x + 1)).unwrap();
92+
assert_eq!(getsockopt(fd, sockopt::TcpKeepInterval).unwrap(), x + 1);
93+
}
8894
}

0 commit comments

Comments
 (0)