diff options
author | Alan Somers <asomers@gmail.com> | 2021-04-04 09:21:58 -0600 |
---|---|---|
committer | Alan Somers <asomers@gmail.com> | 2021-04-04 19:32:54 -0600 |
commit | 2ba6999e2e25260693f476e9629a574f196abb17 (patch) | |
tree | 762fd8dd42a18266e11c8de1ea04b8a5d2b591f7 /test/sys/test_socket.rs | |
parent | 6af11c1e70b02e1af36fdc339238d3a117fd3a94 (diff) | |
download | nix-2ba6999e2e25260693f476e9629a574f196abb17.zip |
Check all tests in CI
Travis didn't compile check tests on platforms that couldn't run tests
in CI, so they bitrotted. Let's see how bad they are.
Most annoyingly, 32-bit Android defines mode_t as 16 bits, but
stat.st_mode as 32-bits.
Diffstat (limited to 'test/sys/test_socket.rs')
-rw-r--r-- | test/sys/test_socket.rs | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs index 2b89a453..43f9b5a3 100644 --- a/test/sys/test_socket.rs +++ b/test/sys/test_socket.rs @@ -757,6 +757,7 @@ pub fn test_af_alg_aead() { target_os = "netbsd"))] #[test] pub fn test_sendmsg_ipv4packetinfo() { + use cfg_if::cfg_if; use nix::sys::uio::IoVec; use nix::sys::socket::{socket, sendmsg, bind, AddressFamily, SockType, SockFlag, SockAddr, @@ -778,11 +779,21 @@ pub fn test_sendmsg_ipv4packetinfo() { let iov = [IoVec::from_slice(&slice)]; if let InetAddr::V4(sin) = inet_addr { - let pi = libc::in_pktinfo { - ipi_ifindex: 0, /* Unspecified interface */ - ipi_addr: libc::in_addr { s_addr: 0 }, - ipi_spec_dst: sin.sin_addr, - }; + cfg_if! { + if #[cfg(target_os = "netbsd")] { + drop(sin); + let pi = libc::in_pktinfo { + ipi_ifindex: 0, /* Unspecified interface */ + ipi_addr: libc::in_addr { s_addr: 0 }, + }; + } else { + let pi = libc::in_pktinfo { + ipi_ifindex: 0, /* Unspecified interface */ + ipi_addr: libc::in_addr { s_addr: 0 }, + ipi_spec_dst: sin.sin_addr, + }; + } + } let cmsg = [ControlMessage::Ipv4PacketInfo(&pi)]; @@ -1472,13 +1483,13 @@ pub fn test_recv_ipv6pktinfo() { Some(ControlMessageOwned::Ipv6PacketInfo(pktinfo)) => { let i = if_nametoindex(lo_name.as_bytes()).expect("if_nametoindex"); assert_eq!( - pktinfo.ipi6_ifindex, + pktinfo.ipi6_ifindex as libc::c_uint, i, "unexpected ifindex (expected {}, got {})", i, pktinfo.ipi6_ifindex ); - } + }, _ => (), } assert!(cmsgs.next().is_none(), "unexpected additional control msg"); |