Skip to content

Commit 0aaaff7

Browse files
committed
Solaris: fixes build and tests, adds CI
Disables some tests for Solaris. test/test_sendfile.rs: Solaris, sendfilev() doesn't support AF_UNIX sockets. Instead, it expects an AF_INET or AF_INET6 sockets. test/sys/test_timer.rs: Note that sys::test_timer::alarm_fires can fail as timer_create(3C) function requires the PRIV_PROC_CLOCK_HIGHRES. But since tests are supposed to run with sudo it should be ok.
1 parent 4b6a5e3 commit 0aaaff7

File tree

13 files changed

+66
-19
lines changed

13 files changed

+66
-19
lines changed

.github/workflows/ci.yml

+21
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,27 @@ jobs:
327327
- name: before_cache_script
328328
run: rm -rf $CARGO_HOME/registry/index
329329

330+
solaris:
331+
name: solaris (x86_64-pc-solaris)
332+
runs-on: ubuntu-latest
333+
steps:
334+
- uses: actions/checkout@v4
335+
- name: build and test
336+
uses: vmactions/solaris-vm@v1
337+
with:
338+
release: "11.4-gcc"
339+
usesh: true
340+
mem: 4096
341+
copyback: false
342+
prepare: |
343+
source <(curl -s https://raw.githubusercontent.com/psumbera/solaris-rust/refs/heads/main/sh.rust-web-install)
344+
echo "~~~~ rustc --version ~~~~"
345+
rustc --version
346+
echo "~~~~ Solaris-version ~~~~"
347+
uname -a
348+
run: |
349+
export PATH=$HOME/.rust_solaris/bin:$PATH
350+
cargo build --target x86_64-pc-solaris --all-targets --all-features && sudo cargo test
330351
331352
# Test that we can build with the lowest version of all dependencies.
332353
# "cargo test" doesn't work because some of our dev-dependencies, like

src/dir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use libc::{dirent, readdir_r};
4646
/// let mut cwd = Dir::open(".", OFlag::O_RDONLY | OFlag::O_CLOEXEC, Mode::empty()).unwrap();
4747
/// for res_entry in cwd.iter() {
4848
/// let entry = res_entry.unwrap();
49-
/// println!("File name: {}", entry.file_name().to_str().unwrap());
49+
/// println!("File name: {}", entry.file_name().to_string_lossy());
5050
/// }
5151
/// ```
5252
#[derive(Debug, Eq, Hash, PartialEq)]

src/fcntl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::ffi::OsString;
1414
#[cfg(not(any(target_os = "redox", target_os = "solaris")))]
1515
use std::ops::{Deref, DerefMut};
1616
use std::os::unix::ffi::OsStringExt;
17-
#[cfg(not(any(target_os = "redox", target_os = "solaris")))]
17+
#[cfg(not(target_os = "redox"))]
1818
use std::os::unix::io::OwnedFd;
1919
use std::os::unix::io::RawFd;
2020
#[cfg(any(
@@ -141,7 +141,7 @@ libc_bitflags!(
141141
#[cfg(any(
142142
freebsdlike,
143143
linux_android,
144-
solarish,
144+
target_os = "illumos",
145145
target_os = "netbsd"
146146
))]
147147
O_DIRECT;

src/sys/mman.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ libc_bitflags! {
3838
/// Additional parameters for [`mmap`].
3939
pub struct MapFlags: c_int {
4040
/// Compatibility flag. Ignored.
41+
#[cfg(not(target_os = "solaris"))]
4142
MAP_FILE;
4243
/// Share this mapping. Mutually exclusive with `MAP_PRIVATE`.
4344
MAP_SHARED;

src/sys/signal.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ libc_enum! {
110110
SIGEMT,
111111
#[cfg(not(any(linux_android, target_os = "emscripten",
112112
target_os = "fuchsia", target_os = "redox",
113-
target_os = "haiku", target_os = "aix")))]
113+
target_os = "haiku", target_os = "aix",
114+
target_os = "solaris")))]
114115
/// Information request
115116
SIGINFO,
116117
}
@@ -188,7 +189,8 @@ impl FromStr for Signal {
188189
target_os = "fuchsia",
189190
target_os = "redox",
190191
target_os = "aix",
191-
target_os = "haiku"
192+
target_os = "haiku",
193+
target_os = "solaris"
192194
)))]
193195
"SIGINFO" => Signal::SIGINFO,
194196
_ => return Err(Errno::EINVAL),
@@ -272,7 +274,8 @@ impl Signal {
272274
target_os = "fuchsia",
273275
target_os = "redox",
274276
target_os = "aix",
275-
target_os = "haiku"
277+
target_os = "haiku",
278+
target_os = "solaris"
276279
)))]
277280
Signal::SIGINFO => "SIGINFO",
278281
}
@@ -356,13 +359,22 @@ const SIGNALS: [Signal; 30] = [
356359
SIGURG, SIGPOLL, SIGIO, SIGSTOP, SIGTSTP, SIGCONT, SIGTTIN, SIGTTOU,
357360
SIGVTALRM, SIGPROF, SIGXCPU, SIGXFSZ, SIGTRAP,
358361
];
362+
#[cfg(target_os = "solaris")]
363+
#[cfg(feature = "signal")]
364+
const SIGNALS: [Signal; 30] = [
365+
SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGABRT, SIGBUS, SIGFPE, SIGKILL,
366+
SIGUSR1, SIGSEGV, SIGUSR2, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGCONT,
367+
SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGURG, SIGXCPU, SIGXFSZ, SIGVTALRM,
368+
SIGPROF, SIGWINCH, SIGIO, SIGSYS, SIGEMT,
369+
];
359370
#[cfg(not(any(
360371
linux_android,
361372
target_os = "fuchsia",
362373
target_os = "emscripten",
363374
target_os = "aix",
364375
target_os = "redox",
365-
target_os = "haiku"
376+
target_os = "haiku",
377+
target_os = "solaris"
366378
)))]
367379
#[cfg(feature = "signal")]
368380
const SIGNALS: [Signal; 31] = [

src/sys/socket/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1679,12 +1679,9 @@ impl ControlMessage<'_> {
16791679
/// let localhost = SockaddrIn::from_str("1.2.3.4:8080").unwrap();
16801680
/// let fd = socket(AddressFamily::Inet, SockType::Datagram, SockFlag::empty(),
16811681
/// None).unwrap();
1682-
/// let (r, w) = pipe().unwrap();
16831682
///
16841683
/// let iov = [IoSlice::new(b"hello")];
1685-
/// let fds = [r.as_raw_fd()];
1686-
/// let cmsg = ControlMessage::ScmRights(&fds);
1687-
/// sendmsg(fd.as_raw_fd(), &iov, &[cmsg], MsgFlags::empty(), Some(&localhost)).unwrap();
1684+
/// sendmsg(fd.as_raw_fd(), &iov, &[], MsgFlags::empty(), Some(&localhost)).unwrap();
16881685
/// ```
16891686
pub fn sendmsg<S>(fd: RawFd, iov: &[IoSlice<'_>], cmsgs: &[ControlMessage],
16901687
flags: MsgFlags, addr: Option<&S>) -> Result<usize>

src/sys/termios.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ libc_enum! {
418418
VEOL,
419419
VEOL2,
420420
VERASE,
421-
#[cfg(any(freebsdlike, solarish))]
421+
#[cfg(any(freebsdlike, target_os = "illumos"))]
422422
VERASE2,
423423
VINTR,
424424
VKILL,
@@ -431,7 +431,7 @@ libc_enum! {
431431
#[cfg(not(target_os = "haiku"))]
432432
VREPRINT,
433433
VSTART,
434-
#[cfg(any(bsd, solarish))]
434+
#[cfg(any(bsd, target_os = "illumos"))]
435435
VSTATUS,
436436
VSTOP,
437437
VSUSP,
@@ -463,6 +463,10 @@ impl SpecialCharacterIndices {
463463
pub use libc::NCCS;
464464
#[cfg(any(linux_android, target_os = "aix", bsd))]
465465
pub use libc::_POSIX_VDISABLE;
466+
// Solaris can use libc::_POSIX_VDISABLE once following is pulled in:
467+
// https://github.com/rust-lang/libc/pull/4103
468+
#[cfg(target_os = "solaris")]
469+
pub const _POSIX_VDISABLE: u8 = 0;
466470

467471
libc_bitflags! {
468472
/// Flags for configuring the input mode of a terminal

src/syslog.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ libc_bitflags! {
138138
/// which file descriptors are allocated.
139139
LOG_NDELAY;
140140
/// Write the message to standard error output as well to the system log.
141-
#[cfg(not(any(target_os = "redox", target_os = "illumos")))]
141+
#[cfg(not(any(solarish, target_os = "redox")))]
142142
LOG_PERROR;
143143
}
144144
}

src/unistd.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,9 @@ pub mod alarm {
21572157
//! sigset.add(Signal::SIGALRM);
21582158
//! sigset.wait();
21592159
//!
2160-
//! assert!(start.elapsed() >= Duration::from_secs(1));
2160+
//! // On Solaris, the signal can arrive before the full second.
2161+
//! const TOLERANCE: Duration = Duration::from_millis(10);
2162+
//! assert!(start.elapsed() + TOLERANCE >= Duration::from_secs(1));
21612163
//! ```
21622164
//!
21632165
//! # References

test/sys/test_stat.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ fn test_mkdirat_fail() {
368368
freebsdlike,
369369
apple_targets,
370370
target_os = "haiku",
371-
target_os = "redox"
371+
target_os = "redox",
372+
target_os = "solaris"
372373
)))]
373374
fn test_mknod() {
374375
use stat::{lstat, mknod, SFlag};

test/sys/test_termios.rs

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ fn test_output_flags() {
8080

8181
// Test modifying local flags
8282
#[test]
83+
#[cfg(not(target_os = "solaris"))]
8384
fn test_local_flags() {
8485
// openpty uses ptname(3) internally
8586
let _m = crate::PTSNAME_MTX.lock();

test/test_pty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ fn make_raw<Fd: AsFd>(fd: Fd) {
148148

149149
/// Test `io::Read` on the PTTY master
150150
#[test]
151+
#[cfg(not(target_os = "solaris"))]
151152
fn test_read_ptty_pair() {
152153
let (mut master, mut slave) = open_ptty_pair();
153154
make_raw(&slave);

test/test_sendfile.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ use tempfile::tempfile;
77
cfg_if! {
88
if #[cfg(linux_android)] {
99
use nix::unistd::{pipe, read};
10-
} else if #[cfg(any(freebsdlike, apple_targets, solarish))] {
10+
} else if #[cfg(any(freebsdlike, apple_targets))] {
1111
use std::net::Shutdown;
1212
use std::os::unix::net::UnixStream;
13+
} else if #[cfg(solarish)] {
14+
use std::net::Shutdown;
15+
use std::net::{TcpListener, TcpStream};
1316
}
1417
}
1518

@@ -222,7 +225,11 @@ fn test_sendfilev() {
222225
trailer_data
223226
.write_all(trailer_strings.concat().as_bytes())
224227
.unwrap();
225-
let (mut rd, wr) = UnixStream::pair().unwrap();
228+
// Create a TCP socket pair (listener and client)
229+
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
230+
let addr = listener.local_addr().unwrap();
231+
let mut rd = TcpStream::connect(addr).unwrap();
232+
let (wr, _) = listener.accept().unwrap();
226233
let vec: &[SendfileVec] = &[
227234
SendfileVec::new(
228235
header_data.as_fd(),
@@ -243,7 +250,7 @@ fn test_sendfilev() {
243250

244251
let (res, bytes_written) = sendfilev(&wr, vec);
245252
assert!(res.is_ok());
246-
wr.shutdown(Shutdown::Both).unwrap();
253+
wr.shutdown(Shutdown::Write).unwrap();
247254

248255
// Prepare the expected result
249256
let expected_string = header_strings.concat()

0 commit comments

Comments
 (0)