Skip to content

Commit 36e3999

Browse files
authored
Fix a test failures on illumos. (#900)
See the comments in the code for details.
1 parent 1ab21e6 commit 36e3999

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

src/backend/libc/net/read_sockaddr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ unsafe fn inner_read_sockaddr_os(
289289
assert_eq!(decode.sun_path[len - 1 - offsetof_sun_path], 0);
290290
let path_bytes = &decode.sun_path[..len - 1 - offsetof_sun_path];
291291

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

298298
SocketAddrAny::Unix(

tests/io/read_write.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -321,17 +321,22 @@ fn test_p_offsets() {
321321
Ok(_) => panic!("pwrite unexpectedly succeeded"),
322322
Err(e) => panic!("pwrite failed with an unexpected error: {:?}", e),
323323
}
324-
match preadv(&f, &mut [IoSliceMut::new(&mut buf)], invalid_offset) {
325-
Err(rustix::io::Errno::OPNOTSUPP | rustix::io::Errno::NOSYS) => {}
326-
Err(rustix::io::Errno::INVAL) => {}
327-
Ok(_) => panic!("preadv unexpectedly succeeded"),
328-
Err(e) => panic!("preadv failed with an unexpected error: {:?}", e),
329-
}
330-
match pwritev(&f, &[IoSlice::new(&buf)], invalid_offset) {
331-
Err(rustix::io::Errno::OPNOTSUPP | rustix::io::Errno::NOSYS) => {}
332-
Err(rustix::io::Errno::INVAL) => {}
333-
Ok(_) => panic!("pwritev unexpectedly succeeded"),
334-
Err(e) => panic!("pwritev failed with an unexpected error: {:?}", e),
324+
// illumos doesn't seem to diagnose a negative offset in
325+
// `preadv`/`pwritev`.
326+
#[cfg(not(target_os = "illumos"))]
327+
{
328+
match preadv(&f, &mut [IoSliceMut::new(&mut buf)], invalid_offset) {
329+
Err(rustix::io::Errno::OPNOTSUPP | rustix::io::Errno::NOSYS) => {}
330+
Err(rustix::io::Errno::INVAL) => {}
331+
Ok(_) => panic!("preadv unexpectedly succeeded"),
332+
Err(e) => panic!("preadv failed with an unexpected error: {:?}", e),
333+
}
334+
match pwritev(&f, &[IoSlice::new(&buf)], invalid_offset) {
335+
Err(rustix::io::Errno::OPNOTSUPP | rustix::io::Errno::NOSYS) => {}
336+
Err(rustix::io::Errno::INVAL) => {}
337+
Ok(_) => panic!("pwritev unexpectedly succeeded"),
338+
Err(e) => panic!("pwritev failed with an unexpected error: {:?}", e),
339+
}
335340
}
336341
#[cfg(linux_kernel)]
337342
{

tests/net/sockopt.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ fn test_sockopts_tcp(s: &OwnedFd) {
216216
// Set keepalive values:
217217
sockopt::set_tcp_keepcnt(&s, 42).unwrap();
218218
sockopt::set_tcp_keepidle(&s, Duration::from_secs(3601)).unwrap();
219-
sockopt::set_tcp_keepintvl(&s, Duration::from_secs(61)).unwrap();
219+
sockopt::set_tcp_keepintvl(&s, Duration::from_secs(60)).unwrap();
220220

221221
// Check keepalive values:
222222
assert_eq!(sockopt::get_tcp_keepcnt(&s).unwrap(), 42);
@@ -226,8 +226,17 @@ fn test_sockopts_tcp(s: &OwnedFd) {
226226
);
227227
assert_eq!(
228228
sockopt::get_tcp_keepintvl(&s).unwrap(),
229-
Duration::from_secs(61)
229+
Duration::from_secs(60)
230230
);
231+
232+
#[cfg(not(target_os = "illumos"))]
233+
{
234+
sockopt::set_tcp_keepintvl(&s, Duration::from_secs(61)).unwrap();
235+
assert_eq!(
236+
sockopt::get_tcp_keepintvl(&s).unwrap(),
237+
Duration::from_secs(61)
238+
);
239+
}
231240
}
232241

233242
// Check the initial value of TCP_QUICKACK, set it, and check it.

0 commit comments

Comments
 (0)