Skip to content

Commit 9f95ccb

Browse files
committed
test: Add a crust function stress test
1 parent 450c4f3 commit 9f95ccb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/test/run-pass/crust-stress.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This creates a bunch of yielding tasks that run concurrently
2+
// while holding onto C stacks
3+
4+
native mod rustrt {
5+
fn rust_dbg_call(cb: *u8,
6+
data: ctypes::uintptr_t) -> ctypes::uintptr_t;
7+
}
8+
9+
crust fn cb(data: ctypes::uintptr_t) -> ctypes::uintptr_t {
10+
if data == 1u {
11+
data
12+
} else {
13+
task::yield();
14+
count(data - 1u) + count(data - 1u)
15+
}
16+
}
17+
18+
fn count(n: uint) -> uint {
19+
rustrt::rust_dbg_call(cb, n)
20+
}
21+
22+
fn main() {
23+
iter::repeat(100u) {||
24+
task::spawn {||
25+
count(5u);
26+
};
27+
}
28+
}

0 commit comments

Comments
 (0)