std::rt: Add a hack to allocate different test port ranges to different bots
This commit is contained in:
parent
1098d6980b
commit
4282539523
@ -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 {
|
||||
|
@ -168,11 +168,11 @@ rust_dbg_extern_identity_TwoDoubles(TwoDoubles u) {
|
||||
|
||||
// Generates increasing port numbers for network testing
|
||||
extern "C" CDECL uintptr_t
|
||||
rust_dbg_next_port() {
|
||||
rust_dbg_next_port(uintptr_t base_port) {
|
||||
static lock_and_signal dbg_port_lock;
|
||||
static uintptr_t next_port = 9600;
|
||||
static uintptr_t next_offset = 0;
|
||||
scoped_lock with(dbg_port_lock);
|
||||
uintptr_t this_port = next_port;
|
||||
next_port += 1;
|
||||
uintptr_t this_port = base_port + next_offset;
|
||||
next_offset += 1;
|
||||
return this_port;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user