Skip to content

Commit

Permalink
Add tests for sockopt::IpMulticastTtl #2073
Browse files Browse the repository at this point in the history
On Linux and Android, sockopt::IpMulticastTtl can be set for both IPv4
and IPv6 sockets, but not on all platforms.
  • Loading branch information
sgasse committed Aug 30, 2023
1 parent f3ab777 commit 507f22e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/sys/test_sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,34 @@ fn test_ttl_opts() {
.expect("setting ipv6ttl on an inet6 socket should succeed");
}

#[test]
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
fn test_multicast_ttl_opts_ipv4() {
let fd4 = socket(
AddressFamily::Inet,
SockType::Datagram,
SockFlag::empty(),
None,
)
.unwrap();
setsockopt(&fd4, sockopt::IpMulticastTtl, &2)
.expect("setting ipmulticastttl on an inet socket should succeed");
}

#[test]
#[cfg(any(target_os = "android", target_os = "linux"))]
fn test_multicast_ttl_opts_ipv6() {
let fd6 = socket(
AddressFamily::Inet6,
SockType::Datagram,
SockFlag::empty(),
None,
)
.unwrap();
setsockopt(&fd6, sockopt::IpMulticastTtl, &2)
.expect("setting ipmulticastttl on an inet6 socket should succeed");
}

#[test]
#[cfg(any(target_os = "ios", target_os = "macos"))]
fn test_dontfrag_opts() {
Expand Down

0 comments on commit 507f22e

Please sign in to comment.