#[macro_escape];
+use libc;
use os;
use prelude::*;
-use rand;
-use rand::Rng;
use std::io::net::ip::*;
use sync::atomics::{AtomicUint, INIT_ATOMIC_UINT, Relaxed};
/// Get a temporary path which could be the location of a unix socket
pub fn next_test_unix() -> Path {
+ static mut COUNT: AtomicUint = INIT_ATOMIC_UINT;
+ // base port and pid are an attempt to be unique between multiple
+ // test-runners of different configurations running on one
+ // buildbot, the count is to be unique within this executable.
+ let string = format!("rust-test-unix-path-{}-{}-{}",
+ base_port(),
+ unsafe {libc::getpid()},
+ unsafe {COUNT.fetch_add(1, Relaxed)});
if cfg!(unix) {
- os::tmpdir().join(rand::task_rng().gen_ascii_str(20))
+ os::tmpdir().join(string)
} else {
- Path::new(r"\\.\pipe\" + rand::task_rng().gen_ascii_str(20))
+ Path::new(r"\\.\pipe\" + string)
}
}