diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-03-02 00:36:33 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-03-12 11:31:43 +1100 |
| commit | 15e289846219cc3ad8b0225712bf2309f2c02439 (patch) | |
| tree | d0b3785fdaa3169718c807cb975031e1813ac367 /src/libstd | |
| parent | 6fa4bbeed425ae99d15322fbaa05d1abeae6547f (diff) | |
| download | rust-15e289846219cc3ad8b0225712bf2309f2c02439.tar.gz rust-15e289846219cc3ad8b0225712bf2309f2c02439.zip | |
Remove the dependence of std::io::test on rand.
This replaces it with a manual "task rng" using XorShift and a crappy seeding mechanism. Theoretically good enough for the purposes though (unique for tests).
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/test.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index b491891ff59..d6f7f58f01c 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -12,10 +12,9 @@ #[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}; @@ -65,10 +64,18 @@ pub fn next_test_port() -> u16 { /// 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) } } |
