test: Add a crust function stress test
This commit is contained in:
parent
450c4f3fa8
commit
9f95ccb426
28
src/test/run-pass/crust-stress.rs
Normal file
28
src/test/run-pass/crust-stress.rs
Normal 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);
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user