From 9f95ccb4269f2bb795c56d0fa7692cb7705c608e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 15 Feb 2012 01:16:53 -0800 Subject: [PATCH] test: Add a crust function stress test --- src/test/run-pass/crust-stress.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test/run-pass/crust-stress.rs diff --git a/src/test/run-pass/crust-stress.rs b/src/test/run-pass/crust-stress.rs new file mode 100644 index 00000000000..73dac3f48c4 --- /dev/null +++ b/src/test/run-pass/crust-stress.rs @@ -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); + }; + } +} \ No newline at end of file