test: Add a crust function stress test

This commit is contained in:
Brian Anderson 2012-02-15 01:16:53 -08:00
parent 450c4f3fa8
commit 9f95ccb426

View file

@ -0,0 +1,28 @@
// This creates a bunch of yielding tasks that run concurrently
// while holding onto C stacks
native mod rustrt {
fn rust_dbg_call(cb: *u8,
data: ctypes::uintptr_t) -> ctypes::uintptr_t;
}
crust fn cb(data: ctypes::uintptr_t) -> ctypes::uintptr_t {
if data == 1u {
data
} else {
task::yield();
count(data - 1u) + count(data - 1u)
}
}
fn count(n: uint) -> uint {
rustrt::rust_dbg_call(cb, n)
}
fn main() {
iter::repeat(100u) {||
task::spawn {||
count(5u);
};
}
}