diff options
| author | Brian Anderson <banderson@mozilla.com> | 2013-07-08 14:41:07 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2013-07-08 14:41:07 -0700 |
| commit | 4282539523905c95f34131e5cf8923764079b3be (patch) | |
| tree | 60d7a82cddbee8e86cff2818592775d7516fd87d /src/libstd | |
| parent | 1098d6980b13dc00e3f20deae987423e3bcae9ce (diff) | |
| download | rust-4282539523905c95f34131e5cf8923764079b3be.tar.gz rust-4282539523905c95f34131e5cf8923764079b3be.zip | |
std::rt: Add a hack to allocate different test port ranges to different bots
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/rt/test.rs | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/src/libstd/rt/test.rs b/src/libstd/rt/test.rs index 659c7eb4985..89687cf3fd2 100644 --- a/src/libstd/rt/test.rs +++ b/src/libstd/rt/test.rs @@ -9,6 +9,7 @@ // except according to those terms. use cell::Cell; +use libc; use uint; use option::{Some, None}; use rt::sched::Scheduler; @@ -316,10 +317,10 @@ pub fn spawntask_thread(f: ~fn()) -> Thread { /// Get a port number, starting at 9600, for use in tests pub fn next_test_port() -> u16 { unsafe { - return rust_dbg_next_port() as u16; + return rust_dbg_next_port(base_port() as libc::uintptr_t) as u16; } extern { - fn rust_dbg_next_port() -> ::libc::uintptr_t; + fn rust_dbg_next_port(base: libc::uintptr_t) -> libc::uintptr_t; } } @@ -328,6 +329,47 @@ pub fn next_test_ip4() -> IpAddr { Ipv4(127, 0, 0, 1, next_test_port()) } +/* +XXX: Welcome to MegaHack City. + +The bots run multiple builds at the same time, and these builds +all want to use ports. This function figures out which workspace +it is running in and assigns a port range based on it. +*/ +fn base_port() -> uint { + use os; + use str::StrSlice; + use to_str::ToStr; + use vec::ImmutableVector; + + let base = 9600u; + let range = 1000; + + let bases = [ + ("32-opt", base + range * 1), + ("32-noopt", base + range * 2), + ("64-opt", base + range * 3), + ("64-noopt", base + range * 4), + ("64-opt-vg", base + range * 5), + ("all-opt", base + range * 6), + ("snap3", base + range * 7), + ("dist", base + range * 8) + ]; + + let path = os::getcwd().to_str(); + + let mut final_base = base; + + for bases.iter().advance |&(dir, base)| { + if path.contains(dir) { + final_base = base; + break; + } + } + + return final_base; +} + /// Get a constant that represents the number of times to repeat /// stress tests. Default 1. pub fn stress_factor() -> uint { |
