iOS: fixed test build
Now it is possible to run tests on a jailbroken device
This commit is contained in:
parent
1fb91dc1c2
commit
ac0607acb2
|
@ -23,16 +23,23 @@ pub fn next_test_port() -> u16 {
|
||||||
base_port() + NEXT_OFFSET.fetch_add(1, Ordering::Relaxed) as u16
|
base_port() + NEXT_OFFSET.fetch_add(1, Ordering::Relaxed) as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a temporary path which could be the location of a unix socket
|
// iOS has a pretty long tmpdir path which causes pipe creation
|
||||||
pub fn next_test_unix() -> Path {
|
// to like: invalid argument: path must be smaller than SUN_LEN
|
||||||
|
fn next_test_unix_socket() -> String {
|
||||||
static COUNT: AtomicUint = ATOMIC_UINT_INIT;
|
static COUNT: AtomicUint = ATOMIC_UINT_INIT;
|
||||||
// base port and pid are an attempt to be unique between multiple
|
// base port and pid are an attempt to be unique between multiple
|
||||||
// test-runners of different configurations running on one
|
// test-runners of different configurations running on one
|
||||||
// buildbot, the count is to be unique within this executable.
|
// buildbot, the count is to be unique within this executable.
|
||||||
let string = format!("rust-test-unix-path-{}-{}-{}",
|
format!("rust-test-unix-path-{}-{}-{}",
|
||||||
base_port(),
|
base_port(),
|
||||||
unsafe {libc::getpid()},
|
unsafe {libc::getpid()},
|
||||||
COUNT.fetch_add(1, Ordering::Relaxed));
|
COUNT.fetch_add(1, Ordering::Relaxed))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get a temporary path which could be the location of a unix socket
|
||||||
|
#[cfg(not(target_os = "ios"))]
|
||||||
|
pub fn next_test_unix() -> Path {
|
||||||
|
let string = next_test_unix_socket();
|
||||||
if cfg!(unix) {
|
if cfg!(unix) {
|
||||||
os::tmpdir().join(string)
|
os::tmpdir().join(string)
|
||||||
} else {
|
} else {
|
||||||
|
@ -40,6 +47,12 @@ pub fn next_test_unix() -> Path {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a temporary path which could be the location of a unix socket
|
||||||
|
#[cfg(target_os = "ios")]
|
||||||
|
pub fn next_test_unix() -> Path {
|
||||||
|
Path::new(format!("/var/tmp/{}", next_test_unix_socket()))
|
||||||
|
}
|
||||||
|
|
||||||
/// Get a unique IPv4 localhost:port pair starting at 9600
|
/// Get a unique IPv4 localhost:port pair starting at 9600
|
||||||
pub fn next_test_ip4() -> SocketAddr {
|
pub fn next_test_ip4() -> SocketAddr {
|
||||||
SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: next_test_port() }
|
SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: next_test_port() }
|
||||||
|
@ -99,7 +112,7 @@ pub fn raise_fd_limit() {
|
||||||
/// multithreaded scheduler testing, depending on the number of cores available.
|
/// multithreaded scheduler testing, depending on the number of cores available.
|
||||||
///
|
///
|
||||||
/// This fixes issue #7772.
|
/// This fixes issue #7772.
|
||||||
#[cfg(target_os="macos")]
|
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
mod darwin_fd_limit {
|
mod darwin_fd_limit {
|
||||||
use libc;
|
use libc;
|
||||||
|
@ -156,7 +169,7 @@ mod darwin_fd_limit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os="macos"))]
|
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||||
mod darwin_fd_limit {
|
mod darwin_fd_limit {
|
||||||
pub unsafe fn raise_fd_limit() {}
|
pub unsafe fn raise_fd_limit() {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue