Add a way to run the test suite with the new scheduler
TESTARGS=--newrt make check-stage1-rpass Conflicts: src/rt/rustrt.def.in
This commit is contained in:
parent
a882554a78
commit
044703435b
8 changed files with 95 additions and 22 deletions
|
|
@ -63,6 +63,9 @@ pub struct config {
|
|||
// Run tests using the JIT
|
||||
jit: bool,
|
||||
|
||||
// Run tests using the new runtime
|
||||
newrt: bool,
|
||||
|
||||
// Explain what's going on
|
||||
verbose: bool
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ pub fn parse_config(args: ~[~str]) -> config {
|
|||
getopts::optopt(~"runtool"), getopts::optopt(~"rustcflags"),
|
||||
getopts::optflag(~"verbose"),
|
||||
getopts::optopt(~"logfile"),
|
||||
getopts::optflag(~"jit")];
|
||||
getopts::optflag(~"jit"),
|
||||
getopts::optflag(~"newrt")];
|
||||
|
||||
fail_unless!(!args.is_empty());
|
||||
let args_ = vec::tail(args);
|
||||
|
|
@ -95,6 +96,7 @@ pub fn parse_config(args: ~[~str]) -> config {
|
|||
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
|
||||
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
|
||||
jit: getopts::opt_present(matches, ~"jit"),
|
||||
newrt: getopts::opt_present(matches, ~"newrt"),
|
||||
verbose: getopts::opt_present(matches, ~"verbose")
|
||||
}
|
||||
}
|
||||
|
|
@ -114,6 +116,7 @@ pub fn log_config(config: config) {
|
|||
logv(c, fmt!("runtool: %s", opt_str(config.runtool)));
|
||||
logv(c, fmt!("rustcflags: %s", opt_str(config.rustcflags)));
|
||||
logv(c, fmt!("jit: %b", config.jit));
|
||||
logv(c, fmt!("newrt: %b", config.newrt));
|
||||
logv(c, fmt!("verbose: %b", config.verbose));
|
||||
logv(c, fmt!("\n"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -483,9 +483,17 @@ fn compile_test_(config: config, props: TestProps,
|
|||
|
||||
fn exec_compiled_test(config: config, props: TestProps,
|
||||
testfile: &Path) -> ProcRes {
|
||||
|
||||
// If testing the new runtime then set the RUST_NEWRT env var
|
||||
let env = if config.newrt {
|
||||
props.exec_env + ~[(~"RUST_NEWRT", ~"1")]
|
||||
} else {
|
||||
props.exec_env
|
||||
};
|
||||
|
||||
compose_and_run(config, testfile,
|
||||
make_run_args(config, props, testfile),
|
||||
props.exec_env,
|
||||
env,
|
||||
config.run_lib_path, None)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use libc::c_char;
|
||||
|
||||
// Some basic logging
|
||||
macro_rules! rtdebug_ (
|
||||
|
|
@ -44,3 +45,33 @@ mod stack;
|
|||
mod context;
|
||||
mod thread;
|
||||
pub mod env;
|
||||
|
||||
pub fn initialize() {
|
||||
unsafe { rust_initialize_global_state(); }
|
||||
extern {
|
||||
fn rust_initialize_global_state();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn start(main: *u8, _argc: int, _argv: *c_char, _crate_map: *u8) -> int {
|
||||
use self::sched::{Scheduler, Task};
|
||||
use self::uvio::UvEventLoop;
|
||||
|
||||
// XXX: Would rather do this lazily in Scheduler
|
||||
initialize();
|
||||
|
||||
let loop_ = ~UvEventLoop::new();
|
||||
let mut sched = ~Scheduler::new(loop_);
|
||||
let main_task = ~do Task::new(&mut sched.stack_pool) {
|
||||
// XXX: Can't call a C function pointer from Rust yet
|
||||
unsafe { rust_call_nullary_fn(main) };
|
||||
};
|
||||
sched.task_queue.push_back(main_task);
|
||||
sched.run();
|
||||
return 0;
|
||||
|
||||
extern {
|
||||
fn rust_call_nullary_fn(f: *u8);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,16 +120,25 @@ pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str {
|
|||
#[lang="start"]
|
||||
pub fn start(main: *u8, argc: int, argv: *c_char,
|
||||
crate_map: *u8) -> int {
|
||||
use libc::getenv;
|
||||
use rt::start;
|
||||
|
||||
unsafe {
|
||||
let use_new_rt = do str::as_c_str("RUST_NEWRT") |s| {
|
||||
getenv(s).is_null()
|
||||
};
|
||||
if use_new_rt {
|
||||
return rust_start(main as *c_void, argc as c_int, argv,
|
||||
crate_map as *c_void) as int;
|
||||
} else {
|
||||
return start(main, argc, argv, crate_map);
|
||||
}
|
||||
}
|
||||
|
||||
extern {
|
||||
fn rust_start(main: *c_void, argc: c_int, argv: *c_char,
|
||||
crate_map: *c_void) -> c_int;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
return rust_start(main as *c_void, argc as c_int, argv,
|
||||
crate_map as *c_void) as int;
|
||||
}
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
|
|
|
|||
|
|
@ -21,17 +21,6 @@
|
|||
|
||||
void* global_crate_map = NULL;
|
||||
|
||||
#ifndef _WIN32
|
||||
pthread_key_t sched_key;
|
||||
#else
|
||||
DWORD sched_key;
|
||||
#endif
|
||||
|
||||
extern "C" void*
|
||||
rust_get_sched_tls_key() {
|
||||
return &sched_key;
|
||||
}
|
||||
|
||||
/**
|
||||
The runtime entrypoint. The (C ABI) main function generated by rustc calls
|
||||
`rust_start`, providing the address of the Rust ABI main function, the
|
||||
|
|
@ -41,10 +30,6 @@ rust_get_sched_tls_key() {
|
|||
extern "C" CDECL int
|
||||
rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
||||
|
||||
#ifndef _WIN32
|
||||
pthread_key_create(&sched_key, NULL);
|
||||
#endif
|
||||
|
||||
// Load runtime configuration options from the environment.
|
||||
// FIXME #1497: Should provide a way to get these from the command
|
||||
// line as well.
|
||||
|
|
|
|||
|
|
@ -882,6 +882,37 @@ rust_get_rt_env() {
|
|||
return task->kernel->env;
|
||||
}
|
||||
|
||||
typedef void *(*nullary_fn)();
|
||||
|
||||
extern "C" CDECL void
|
||||
rust_call_nullary_fn(nullary_fn f) {
|
||||
f();
|
||||
}
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
pthread_key_t sched_key;
|
||||
#else
|
||||
DWORD sched_key;
|
||||
#endif
|
||||
|
||||
extern "C" void*
|
||||
rust_get_sched_tls_key() {
|
||||
return &sched_key;
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
rust_initialize_global_state() {
|
||||
|
||||
#ifndef _WIN32
|
||||
assert(!pthread_key_create(&sched_key, NULL));
|
||||
#else
|
||||
sched_key = TlsAlloc();
|
||||
assert(sched_key != TLS_OUT_OF_INDEXES);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
|
|
|
|||
|
|
@ -210,4 +210,7 @@ rust_uv_ip4_addrp
|
|||
rust_uv_ip6_addrp
|
||||
rust_uv_free_ip4_addr
|
||||
rust_uv_free_ip6_addr
|
||||
rust_call_nullary_fn
|
||||
rust_initialize_global_state
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue