Skip to content

Commit

Permalink
fucking macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
kotauskas committed Apr 15, 2024
1 parent 911bc37 commit 697a198
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
8 changes: 1 addition & 7 deletions src/os/unix/local_socket/name_type.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
use crate::local_socket::{Name, NameInner, NameType, NamespacedNameType, PathNameType};
use std::{
borrow::Cow,
ffi::OsStr,
io,
os::unix::ffi::{OsStrExt, OsStringExt},
path::Path,
};
use std::{borrow::Cow, ffi::OsStr, io, os::unix::prelude::*, path::Path};

tag_enum!(
/// [Mapping](NameType) that produces local socket names referring to Unix domain sockets bound to
Expand Down
17 changes: 12 additions & 5 deletions tests/os/unix/local_socket_fake_ns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use crate::{
};
use std::sync::Arc;

fn test_inner() -> TestResult {
let mut namegen = NameGen::new(make_id!(), |rnum| {
format!("interprocess test/fake ns/test-{:08x}.sock", rnum)
fn test_inner(iter: u32) -> TestResult {
let mut namegen = NameGen::new(&format!("{}{}", make_id!(), iter), |rnum| {
format!("interprocess test {:08x}/fake ns/test.sock", rnum)
.to_ns_name::<SpecialDirUdSocket>()
.map(Arc::new)
});
let (name, _listener) = listen_and_pick_name(&mut namegen, |nm| {
ListenerOptions::new().name(nm.borrow()).create_sync()
dbg!(ListenerOptions::new().name(nm.borrow()).create_sync())
})?;
let name = Arc::try_unwrap(name).unwrap();
let _ = Stream::connect(name.borrow()).opname("client connect")?;
Expand All @@ -22,5 +22,12 @@ fn test_inner() -> TestResult {

#[test]
fn local_socket_fake_ns() -> TestResult {
test_wrapper(test_inner)
test_wrapper(|| {
// fucking macOS
let iterations = if cfg!(target_os = "macos") { 20736 } else { 12 };
for i in 0..iterations {
test_inner(i)?;
}
Ok(())
})
}
2 changes: 1 addition & 1 deletion tests/util/namegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct NameGen<T: ?Sized, F: FnMut(u32) -> NameResult<T>> {
name_fn: F,
}
impl<T: ?Sized, F: FnMut(u32) -> NameResult<T>> NameGen<T, F> {
pub fn new(id: &'static str, name_fn: F) -> Self {
pub fn new(id: &str, name_fn: F) -> Self {
Self {
rng: Xorshift32::from_id(id),
name_fn,
Expand Down
2 changes: 1 addition & 1 deletion tests/util/xorshift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
#[derive(Copy, Clone, Debug)]
pub struct Xorshift32(pub u32);
impl Xorshift32 {
pub fn from_id(id: &'static str) -> Self {
pub fn from_id(id: &str) -> Self {
let mut hasher = DefaultHasher::new();
id.hash(&mut hasher);
let hash64 = hasher.finish();
Expand Down

0 comments on commit 697a198

Please sign in to comment.