diff options
| author | Eric Holk <eholk@mozilla.com> | 2011-06-28 12:54:41 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-06-28 16:12:34 -0700 |
| commit | f6f8a06d6bf010b8d30c23786976792cccfbd6de (patch) | |
| tree | 7aeb93091cdb19e6ac3b2a63fd7f828a4b3c1499 /src/rt/test/rust_test_runtime.cpp | |
| parent | 657e5a2bd579f7f1698f8ba88cb1142ced7a477f (diff) | |
| download | rust-f6f8a06d6bf010b8d30c23786976792cccfbd6de.tar.gz rust-f6f8a06d6bf010b8d30c23786976792cccfbd6de.zip | |
Resurrecting the runtime unit tests, and modifying them so they compile under the latest refactoring changes.
Diffstat (limited to 'src/rt/test/rust_test_runtime.cpp')
| -rw-r--r-- | src/rt/test/rust_test_runtime.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/rt/test/rust_test_runtime.cpp b/src/rt/test/rust_test_runtime.cpp new file mode 100644 index 00000000000..acb3557b8c1 --- /dev/null +++ b/src/rt/test/rust_test_runtime.cpp @@ -0,0 +1,67 @@ +#include "rust_test_runtime.h" + +rust_test_runtime::rust_test_runtime() { +} + +rust_test_runtime::~rust_test_runtime() { +} + +#define DOMAINS 32 +#define TASKS 32 + +void +rust_domain_test::worker::run() { + rust_scheduler *handle = kernel->get_scheduler(); + for (int i = 0; i < TASKS; i++) { + handle->create_task(NULL, "child"); + } + sync::random_sleep(1000); +} + +bool +rust_domain_test::run() { + rust_srv srv; + rust_kernel kernel(&srv); + + array_list<worker *> workers; + for (int i = 0; i < DOMAINS; i++) { + worker *worker = new rust_domain_test::worker (&kernel); + workers.append(worker); + worker->start(); + } + + // We don't join the worker threads here in order to simulate ad-hoc + // termination of domains. If we join_all_domains before all domains + // are actually spawned, this could crash, thus the reason for the + // sleep below. + + sync::sleep(100); + return true; +} + +void task_entry() { + printf("task entry\n"); +} + +void +rust_task_test::worker::run() { + rust_scheduler *scheduler = kernel->get_scheduler(); + scheduler->root_task->start((uintptr_t)&task_entry, (uintptr_t)NULL); + scheduler->start_main_loop(0); +} + +bool +rust_task_test::run() { + rust_srv srv; + rust_kernel kernel(&srv); + + array_list<worker *> workers; + for (int i = 0; i < DOMAINS; i++) { + worker *worker = new rust_task_test::worker (&kernel, this); + workers.append(worker); + worker->start(); + } + + sync::random_sleep(1000); + return true; +} |
