Skip to content

Commit

Permalink
CI jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
nikarh committed Sep 12, 2023
1 parent 1793c95 commit fc72a10
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 16 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ jobs:
- uses: taiki-e/install-action@cargo-hack
- name: Run check
run: cargo hack check --feature-powerset --all-targets --examples --bins --tests --target ${{ matrix.target }}
CheckTier3:
name: Check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: ["armv7-sony-vita-newlibeabihf"]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
components: "rust-src"
- uses: taiki-e/install-action@cargo-hack
- name: Run check
run: cargo hack check -Z build-std=std,panic_abort --feature-powerset --all-targets --examples --bins --tests --target ${{ matrix.target }}
Clippy:
name: Clippy
runs-on: ubuntu-latest
Expand All @@ -87,3 +103,18 @@ jobs:
targets: ${{ matrix.target }}
- name: Check docs for docs.rs
run: RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo doc --no-deps --all-features --target ${{ matrix.target }}
DocsTier3:
name: Docs
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: ["armv7-sony-vita-newlibeabihf"]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly # NOTE: need nightly for `doc_cfg` feature.
with:
targets: ${{ matrix.target }}
components: "rust-src"
- name: Check docs for docs.rs
run: RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo doc -Z build-std=std,panic_abort --no-deps --all-features --target ${{ matrix.target }}
7 changes: 3 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,18 +424,17 @@ impl<'a> DerefMut for MaybeUninitSlice<'a> {
/// Configures a socket's TCP keepalive parameters.
///
/// See [`Socket::set_tcp_keepalive`].
#[cfg(not(target_os = "vita"))]
#[derive(Debug, Clone)]
pub struct TcpKeepalive {
#[cfg_attr(target_os = "openbsd", allow(dead_code))]
#[cfg(not(any(target_os = "vita")))]
time: Option<Duration>,
#[cfg(not(any(
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "nto",
target_os = "espidf",
target_os = "vita",
)))]
interval: Option<Duration>,
#[cfg(not(any(
Expand All @@ -445,11 +444,11 @@ pub struct TcpKeepalive {
target_os = "windows",
target_os = "nto",
target_os = "espidf",
target_os = "vita",
)))]
retries: Option<u32>,
}

#[cfg(not(target_os = "vita"))]
impl TcpKeepalive {
/// Returns a new, empty set of TCP keepalive parameters.
pub const fn new() -> TcpKeepalive {
Expand Down Expand Up @@ -689,7 +688,7 @@ impl<'addr, 'bufs, 'control> MsgHdrMut<'addr, 'bufs, 'control> {
///
/// Corresponds to setting `msg_name` and `msg_namelen` on Unix and `name`
/// and `namelen` on Windows.
pub fn with_addr(mut self, addr: &'addr mut SockAddr) -> Self {
pub fn with_addr(mut self, addr: &SockAddr) -> Self {
sys::set_msghdr_name(&mut self.inner, addr);
self
}
Expand Down
5 changes: 4 additions & 1 deletion src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ use std::time::Duration;
use crate::sys::{self, c_int, getsockopt, setsockopt, Bool};
#[cfg(all(unix, not(target_os = "redox")))]
use crate::MsgHdrMut;
use crate::{Domain, Protocol, SockAddr, TcpKeepalive, Type};
#[cfg(not(target_os = "vita"))]
use crate::TcpKeepalive;
use crate::{Domain, Protocol, SockAddr, Type};
#[cfg(not(target_os = "redox"))]
use crate::{MaybeUninitSlice, MsgHdr, RecvFlags};

Expand Down Expand Up @@ -1981,6 +1983,7 @@ impl Socket {
/// # Ok(()) }
/// ```
///
#[cfg(not(target_os = "vita"))]
pub fn set_tcp_keepalive(&self, params: &TcpKeepalive) -> io::Result<()> {
self.set_keepalive(true)?;
sys::set_tcp_keepalive(self.as_raw(), params)
Expand Down
5 changes: 4 additions & 1 deletion src/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ use std::{io, slice};
use libc::ssize_t;
use libc::{in6_addr, in_addr};

use crate::{Domain, Protocol, SockAddr, TcpKeepalive, Type};
#[cfg(not(target_os = "vita"))]
use crate::TcpKeepalive;
use crate::{Domain, Protocol, SockAddr, Type};
#[cfg(not(target_os = "redox"))]
use crate::{MsgHdr, MsgHdrMut, RecvFlags};

Expand Down Expand Up @@ -1162,6 +1164,7 @@ pub(crate) fn keepalive_time(fd: Socket) -> io::Result<Duration> {
}

#[allow(unused_variables)]
#[cfg(not(target_os = "vita"))]
pub(crate) fn set_tcp_keepalive(fd: Socket, keepalive: &TcpKeepalive) -> io::Result<()> {
#[cfg(not(any(
target_os = "haiku",
Expand Down
16 changes: 6 additions & 10 deletions tests/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ use windows_sys::Win32::Foundation::{GetHandleInformation, HANDLE_FLAG_INHERIT};

#[cfg(not(any(target_os = "redox", target_os = "vita")))]
use socket2::MaybeUninitSlice;
use socket2::{Domain, Protocol, SockAddr, Socket, TcpKeepalive, Type};
#[cfg(not(target_os = "vita"))]
use socket2::TcpKeepalive;
use socket2::{Domain, Protocol, SockAddr, Socket, Type};

#[test]
fn domain_for_address() {
Expand Down Expand Up @@ -826,11 +828,10 @@ fn udp_pair_connected() -> (Socket, Socket) {
}

#[test]
#[cfg(not(target_os = "vita"))]
fn tcp_keepalive() {
let socket = Socket::new(Domain::IPV4, Type::STREAM, None).unwrap();
let params = TcpKeepalive::new();
#[cfg(not(any(target_os = "vita")))]
let params = params.with_time(Duration::from_secs(200));
let params = TcpKeepalive::new().with_time(Duration::from_secs(200));

#[cfg(all(
feature = "all",
Expand Down Expand Up @@ -870,12 +871,7 @@ fn tcp_keepalive() {

#[cfg(all(
feature = "all",
not(any(
windows,
target_os = "haiku",
target_os = "openbsd",
target_os = "vita"
))
not(any(windows, target_os = "haiku", target_os = "openbsd",))
))]
assert_eq!(socket.keepalive_time().unwrap(), Duration::from_secs(200));

Expand Down

0 comments on commit fc72a10

Please sign in to comment.