Skip to content

Commit

Permalink
Re-enable.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Jan 24, 2025
1 parent fe669cd commit b0c0afa
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 26 deletions.
10 changes: 0 additions & 10 deletions src/backend/libc/net/read_sockaddr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ pub(crate) unsafe fn read_sockaddr(
storage: *const c::sockaddr_storage,
len: usize,
) -> io::Result<SocketAddrAny> {
dbg!(len);
#[cfg(unix)]
let offsetof_sun_path = super::addr::offsetof_sun_path();

Expand Down Expand Up @@ -239,14 +238,12 @@ pub(crate) unsafe fn maybe_read_sockaddr_os(
storage: *const c::sockaddr_storage,
len: usize,
) -> Option<SocketAddrAny> {
dbg!(len);
if len == 0 {
return None;
}

assert!(len >= size_of::<c::sa_family_t>());
let family = read_ss_family(storage).into();
dbg!(&family);
if family == c::AF_UNSPEC {
return None;
}
Expand All @@ -270,10 +267,8 @@ pub(crate) unsafe fn read_sockaddr_os(
storage: *const c::sockaddr_storage,
len: usize,
) -> SocketAddrAny {
dbg!(len);
assert!(len >= size_of::<c::sa_family_t>());
let family = read_ss_family(storage).into();
dbg!(&family);
inner_read_sockaddr_os(family, storage, len)
}

Expand All @@ -282,7 +277,6 @@ unsafe fn inner_read_sockaddr_os(
storage: *const c::sockaddr_storage,
len: usize,
) -> SocketAddrAny {
dbg!(len);
#[cfg(unix)]
let offsetof_sun_path = super::addr::offsetof_sun_path();

Expand All @@ -308,8 +302,6 @@ unsafe fn inner_read_sockaddr_os(
}
#[cfg(unix)]
c::AF_UNIX => {
dbg!("line");
dbg!(len, offsetof_sun_path);
assert!(len >= offsetof_sun_path);
if len == offsetof_sun_path {
SocketAddrAny::Unix(SocketAddrUnix::new(&[][..]).unwrap())
Expand All @@ -336,14 +328,12 @@ unsafe fn inner_read_sockaddr_os(
assert_eq!(decode.sun_path[len - 1 - offsetof_sun_path], 0);
let path_bytes = &decode.sun_path[..len - 1 - offsetof_sun_path];

dbg!(&path_bytes);
// FreeBSD and illumos sometimes set the length to longer than
// the length of the NUL-terminated string. Find the NUL and
// truncate the string accordingly.
#[cfg(any(solarish, target_os = "freebsd"))]
let path_bytes = &path_bytes[..path_bytes.iter().position(|b| *b == 0).unwrap()];

dbg!(&path_bytes);
SocketAddrAny::Unix(
SocketAddrUnix::new(core::mem::transmute::<&[c::c_char], &[u8]>(path_bytes))
.unwrap(),
Expand Down
4 changes: 0 additions & 4 deletions tests/net/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,22 @@
#![cfg(not(any(target_os = "redox", target_os = "wasi")))]
#![cfg_attr(core_c_str, feature(core_c_str))]

/*
mod addr;
#[cfg(unix)]
mod cmsg;
mod connect_bind_send;
mod dgram;
#[cfg(feature = "event")]
mod poll;
*/
#[cfg(unix)]
mod recv_trunc;
/*
mod sockopt;
#[cfg(unix)]
mod unix;
#[cfg(unix)]
mod unix_alloc;
mod v4;
mod v6;
*/

#[cfg(windows)]
mod windows {
Expand Down
12 changes: 0 additions & 12 deletions tests/net/recv_trunc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::mem::MaybeUninit;

/// Test `recv_uninit` with the `RecvFlags::Trunc` flag.
#[test]
#[ignore]
fn net_recv_uninit_trunc() {
crate::init();

Expand Down Expand Up @@ -55,9 +54,7 @@ fn net_recvmsg_trunc() {

let tmpdir = tempfile::tempdir().unwrap();
let path = tmpdir.path().join("recvmsg_trunc");
dbg!(&path);
let name = SocketAddrUnix::new(&path).unwrap();
dbg!(&name);

let receiver = rustix::net::socket(AddressFamily::UNIX, SocketType::DGRAM, None).unwrap();
rustix::net::bind_unix(&receiver, &name).expect("bind");
Expand All @@ -73,7 +70,6 @@ fn net_recvmsg_trunc() {
assert_eq!(n, request.len());

let mut response = [0_u8; 5];
dbg!("line");
let result = rustix::net::recvmsg(
&receiver,
&mut [IoSliceMut::new(&mut response)],
Expand All @@ -82,8 +78,6 @@ fn net_recvmsg_trunc() {
)
.expect("recvmsg");

dbg!(&result.address);

// We used the `TRUNC` flag, so we should have received 15 bytes,
// truncated to 5 bytes, and the `TRUNC` flag should have been returned.
assert_eq!(&response, b"Hello");
Expand All @@ -97,7 +91,6 @@ fn net_recvmsg_trunc() {

// This time receive it with `TRUNC` and a big enough buffer.
let mut response = [0_u8; 30];
dbg!("line");
let result = rustix::net::recvmsg(
&receiver,
&mut [IoSliceMut::new(&mut response)],
Expand All @@ -106,7 +99,6 @@ fn net_recvmsg_trunc() {
)
.expect("recvmsg");

dbg!(&result.address);
// We used the `TRUNC` flag, so we should have received 15 bytes
// and the buffer was big enough so the `TRUNC` flag should not have
// been returned.
Expand All @@ -120,7 +112,6 @@ fn net_recvmsg_trunc() {

// This time receive it without `TRUNC` but a big enough buffer.
let mut response = [0_u8; 30];
dbg!("line");
let result = rustix::net::recvmsg(
&receiver,
&mut [IoSliceMut::new(&mut response)],
Expand All @@ -129,7 +120,6 @@ fn net_recvmsg_trunc() {
)
.expect("recvmsg");

dbg!(&result.address);
// We didn't use the `TRUNC` flag, but the buffer was big enough,
// so we should have received 15 bytes, and the `TRUNC` flag should
// have been returned.
Expand All @@ -142,7 +132,6 @@ fn net_recvmsg_trunc() {

// This time receive it without `TRUNC` and a small buffer.
let mut response = [0_u8; 5];
dbg!("line");
let result = rustix::net::recvmsg(
&receiver,
&mut [IoSliceMut::new(&mut response)],
Expand All @@ -151,7 +140,6 @@ fn net_recvmsg_trunc() {
)
.expect("recvmsg");

dbg!(&result.address);
// We didn't use the `TRUNC` flag, so we should have received 15 bytes,
// truncated to 5 bytes, and the `TRUNC` flag should have been returned.
assert_eq!(&response[..result.bytes], b"Hello");
Expand Down

0 comments on commit b0c0afa

Please sign in to comment.