Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests on illumos. #1238

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/event/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ impl<'a> Iterator for Iter<'a> {
repr(packed)
)]
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(
all(solarish, any(target_arch = "x86", target_arch = "x86_64")),
repr(packed(4))
)]
pub struct Event {
/// Which specific event(s) occurred.
pub flags: EventFlags,
Expand Down Expand Up @@ -451,7 +455,6 @@ mod tests {

#[test]
fn test_epoll_layouts() {
check_renamed_type!(Event, epoll_event);
check_renamed_type!(Event, epoll_event);
check_renamed_struct_renamed_field!(Event, epoll_event, flags, events);
#[cfg(libc)]
Expand Down
4 changes: 2 additions & 2 deletions tests/net/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ fn test_sockopts_socket(s: &OwnedFd) {

// Set the send buffer size.
let size = sockopt::get_socket_send_buffer_size(s).unwrap();
sockopt::set_socket_send_buffer_size(s, size * 4).unwrap();
sockopt::set_socket_send_buffer_size(s, size * 2).unwrap();

// Check that the send buffer size is set.
assert!(sockopt::get_socket_send_buffer_size(s).unwrap() >= size * 4);
assert!(sockopt::get_socket_send_buffer_size(s).unwrap() >= size * 2);

// Check that the oobinline flag is not initially set.
assert!(!sockopt::get_socket_oobinline(s).unwrap());
Expand Down
24 changes: 23 additions & 1 deletion tests/pty/openpty.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unused_mut, unused_imports)]

use rustix::fs::{openat, Mode, OFlags, CWD};
use rustix::pty::*;
use std::fs::File;
Expand Down Expand Up @@ -37,7 +39,24 @@ fn openpty_basic() {
controller.write_all(b"Hello, world!\n\x04").unwrap();

let mut s = String::new();
user.read_to_string(&mut s).unwrap();

// Read the string back. Our `\x04` above ended the stream, so we can
// read to the end of the stream.
#[cfg(not(target_os = "illumos"))]
{
user.read_to_string(&mut s).unwrap();
}

// Except on illumos, where the `\0x04` doesn't seem to translate into an
// EOF, so we didn't end the stream, so just the line.
#[cfg(target_os = "illumos")]
use std::io::{BufRead, BufReader};
#[cfg(target_os = "illumos")]
let mut user = BufReader::new(user);
#[cfg(target_os = "illumos")]
{
user.read_line(&mut s).unwrap();
}

assert_eq!(s, "Hello, world!\n");
}
Expand Down Expand Up @@ -70,6 +89,9 @@ fn openpty_get_peer() {
controller.write_all(b"Hello, world!\n\x04").unwrap();

let mut s = String::new();

// Read the string back. Our `\x04` above ended the stream, so we can
// read to the end of the stream.
user.read_to_string(&mut s).unwrap();

assert_eq!(s, "Hello, world!\n");
Expand Down
Loading