rt: Remove bitrotted tests

This commit is contained in:
Brian Anderson 2012-02-02 14:57:13 -08:00
parent 65f4b0587a
commit 7f2980b749
8 changed files with 0 additions and 309 deletions

View File

@ -62,9 +62,6 @@ RUNTIME_CS_$(1) := \
rt/rust_debug.cpp \
rt/memory_region.cpp \
rt/boxed_region.cpp \
rt/test/rust_test_harness.cpp \
rt/test/rust_test_runtime.cpp \
rt/test/rust_test_util.cpp \
rt/arch/$$(HOST_$(1))/context.cpp
RUNTIME_S_$(1) := rt/arch/$$(HOST_$(1))/_context.S \
@ -102,9 +99,6 @@ RUNTIME_HDR_$(1) := rt/globals.h \
rt/rust_kernel.h \
rt/memory_region.h \
rt/memory.h \
rt/test/rust_test_harness.h \
rt/test/rust_test_runtime.h \
rt/test/rust_test_util.h \
rt/arch/$$(HOST_$(1))/context.h \
rt/arch/$$(HOST_$(1))/regs.h

View File

@ -294,10 +294,6 @@ extern "C" type_desc *rust_clone_type_desc(type_desc*);
#include "rust_port.h"
#include "memory.h"
#include "test/rust_test_harness.h"
#include "test/rust_test_util.h"
#include "test/rust_test_runtime.h"
//
// Local Variables:
// mode: C++

View File

@ -1,40 +0,0 @@
#include "../rust_internal.h"
bool
rust_test::run() {
return false;
}
const char *
rust_test::name() {
return "untitled";
}
rust_test_suite::rust_test_suite() {
tests.append(new rust_domain_test());
tests.append(new rust_task_test(this));
tests.append(new rust_array_list_test());
tests.append(new rust_synchronized_indexed_list_test());
}
rust_test_suite::~rust_test_suite() {
}
bool
rust_test_suite::run() {
bool pass = true;
for (size_t i = 0; i < tests.size(); i++) {
rust_test *test = tests[i];
printf("test: %s running ... \n", test->name());
timer timer;
bool result = tests[i]->run();
printf("test: %s %s %.2f ms\n", test->name(),
result ? "PASS" : "FAIL", timer.elapsed_ms());
if (result == false) {
pass = false;
}
}
return pass;
}

View File

@ -1,22 +0,0 @@
#ifndef RUST_TEST_HARNESS_H
#define RUST_TEST_HARNESS_H
#define CHECK(x) if ((x) == false) \
{ printf("condition: %s failed at file: %s, line: %d\n", #x, \
__FILE__, __LINE__ ); return false; }
class rust_test {
public:
virtual bool run();
virtual const char *name();
};
class rust_test_suite : public rust_test {
public:
array_list<rust_test*> tests;
rust_test_suite();
virtual ~rust_test_suite();
bool run();
};
#endif /* RUST_TEST_HARNESS_H */

View File

@ -1,69 +0,0 @@
#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() {
for (int i = 0; i < TASKS; i++) {
kernel->create_task(NULL, "child");
}
//sync::sleep(rand(&handle->rctx) % 1000);
}
bool
rust_domain_test::run() {
rust_env env;
rust_srv srv(&env);
rust_kernel kernel(&srv, 1);
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(void *, rust_opaque_box*, void *) {
printf("task entry\n");
}
void
rust_task_test::worker::run() {
rust_task_id root_id = kernel->create_task(NULL, "main");
rust_task *root_task = kernel->get_task_by_id(root_id);
root_task->start(&task_entry, NULL, NULL);
root_task->sched->start_main_loop();
}
bool
rust_task_test::run() {
rust_env env;
rust_srv srv(&env);
rust_kernel kernel(&srv, 1);
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::sleep(rand(&kernel.sched->rctx) % 1000);
return true;
}

View File

@ -1,48 +0,0 @@
#include "../rust_internal.h"
#ifndef RUST_TEST_RUNTIME_H
#define RUST_TEST_RUNTIME_H
class rust_test_runtime {
public:
rust_test_runtime();
virtual ~rust_test_runtime();
};
class rust_domain_test : public rust_test {
public:
class worker : public rust_thread {
public:
rust_kernel *kernel;
worker(rust_kernel *kernel) : kernel(kernel) {
}
void run();
};
bool run();
const char *name() {
return "rust_domain_test";
}
};
class rust_task_test : public rust_test {
public:
rust_test_suite *suite;
rust_task_test(rust_test_suite *suite) : suite(suite) {
}
class worker : public rust_thread {
public:
rust_kernel *kernel;
rust_task_test *parent;
worker(rust_kernel *kernel, rust_task_test *parent) :
kernel(kernel), parent(parent) {
}
void run();
};
bool run();
const char *name() {
return "rust_task_test";
}
};
#endif /* RUST_TEST_RUNTIME_H */

View File

@ -1,78 +0,0 @@
#include "../rust_internal.h"
#define COUNT 1000
#define LARGE_COUNT 10000
#define THREADS 10
bool
rust_array_list_test::run() {
array_list<int> list;
for (int i = 0; i < COUNT; i++) {
list.append(i);
}
for (int i = 0; i < COUNT; i++) {
CHECK (list[i] == i);
}
for (int i = 0; i < COUNT; i++) {
CHECK (list.index_of(i) == i);
}
for (int i = 0; i < COUNT; i++) {
CHECK (list.replace(i, -i));
CHECK (list.replace(-i, i));
CHECK (list.index_of(i) == i);
}
for (int i = COUNT - 1; i >= 0; i--) {
CHECK (list.pop(NULL));
}
return true;
}
bool
rust_synchronized_indexed_list_test::run() {
array_list<worker*> workers;
for (int i = 0; i < THREADS; i++) {
worker *worker =
new rust_synchronized_indexed_list_test::worker(this);
workers.append(worker);
}
for (uint32_t i = 0; i < workers.size(); i++) {
workers[i]->start();
}
while(workers.is_empty() == false) {
worker *worker;
workers.pop(&worker);
worker->join();
delete worker;
}
size_t expected_items = LARGE_COUNT * THREADS;
CHECK(list.length() == expected_items);
long long sum = 0;
for (size_t i = 0; i < list.length(); i++) {
sum += list[i]->value;
}
long long expected_sum = LARGE_COUNT;
expected_sum = expected_sum * (expected_sum - 1) / 2 * THREADS;
CHECK (sum == expected_sum);
return true;
}
void
rust_synchronized_indexed_list_test::worker::run() {
for (int i = 0; i < LARGE_COUNT; i++) {
parent->list.append(new indexed_list_element<int>(i));
}
return;
}

View File

@ -1,42 +0,0 @@
#ifndef RUST_TEST_UTIL_H
#define RUST_TEST_UTIL_H
class rust_test_util : public rust_test {
public:
};
class rust_array_list_test : public rust_test {
public:
bool run();
const char *name() {
return "rust_array_list_test";
}
};
class rust_synchronized_indexed_list_test : public rust_test {
public:
rust_env env;
rust_srv srv;
synchronized_indexed_list<indexed_list_element<int> > list;
rust_synchronized_indexed_list_test() :
srv(&env)
{
}
class worker : public rust_thread {
public:
rust_synchronized_indexed_list_test *parent;
worker(rust_synchronized_indexed_list_test *parent) : parent(parent) {
}
void run();
};
bool run();
const char *name() {
return "rust_synchronized_indexed_list_test";
}
};
#endif /* RUST_TEST_UTIL_H */