about summary refs log tree commit diff
path: root/src/rt/rust_test_helpers.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-03-27 14:12:40 -0700
committerBrian Anderson <banderson@mozilla.com>2013-04-15 13:39:15 -0700
commit7cd681684f96c0f59468346384f6f5c5a04a7ff5 (patch)
treee97c83b672578e67ad77a24320e38b19f9946307 /src/rt/rust_test_helpers.cpp
parent39e2ab5e8b67763ff960203a32acc24a17beeb50 (diff)
downloadrust-7cd681684f96c0f59468346384f6f5c5a04a7ff5.tar.gz
rust-7cd681684f96c0f59468346384f6f5c5a04a7ff5.zip
rt: Move test functions to rust_test_helpers.cpp
Diffstat (limited to 'src/rt/rust_test_helpers.cpp')
-rw-r--r--src/rt/rust_test_helpers.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/rt/rust_test_helpers.cpp b/src/rt/rust_test_helpers.cpp
new file mode 100644
index 00000000000..2c8026f159e
--- /dev/null
+++ b/src/rt/rust_test_helpers.cpp
@@ -0,0 +1,105 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Helper functions used only in tests
+
+#include "rust_sched_loop.h"
+#include "rust_task.h"
+#include "rust_util.h"
+#include "rust_scheduler.h"
+#include "sync/timer.h"
+#include "sync/rust_thread.h"
+#include "rust_abi.h"
+
+// These functions are used in the unit tests for C ABI calls.
+
+extern "C" CDECL uint32_t
+rust_dbg_extern_identity_u32(uint32_t u) {
+    return u;
+}
+
+extern "C" CDECL uint64_t
+rust_dbg_extern_identity_u64(uint64_t u) {
+    return u;
+}
+
+struct TwoU64s {
+    uint64_t one;
+    uint64_t two;
+};
+
+extern "C" CDECL TwoU64s
+rust_dbg_extern_identity_TwoU64s(TwoU64s u) {
+    return u;
+}
+
+struct TwoDoubles {
+    double one;
+    double two;
+};
+
+extern "C" CDECL TwoDoubles
+rust_dbg_extern_identity_TwoDoubles(TwoDoubles u) {
+    return u;
+}
+
+extern "C" CDECL double
+rust_dbg_extern_identity_double(double u) {
+    return u;
+}
+
+extern "C" CDECL char
+rust_dbg_extern_identity_u8(char u) {
+    return u;
+}
+
+extern "C" CDECL lock_and_signal *
+rust_dbg_lock_create() {
+    return new lock_and_signal();
+}
+
+extern "C" CDECL void
+rust_dbg_lock_destroy(lock_and_signal *lock) {
+    assert(lock);
+    delete lock;
+}
+
+extern "C" CDECL void
+rust_dbg_lock_lock(lock_and_signal *lock) {
+    assert(lock);
+    lock->lock();
+}
+
+extern "C" CDECL void
+rust_dbg_lock_unlock(lock_and_signal *lock) {
+    assert(lock);
+    lock->unlock();
+}
+
+extern "C" CDECL void
+rust_dbg_lock_wait(lock_and_signal *lock) {
+    assert(lock);
+    lock->wait();
+}
+
+extern "C" CDECL void
+rust_dbg_lock_signal(lock_and_signal *lock) {
+    assert(lock);
+    lock->signal();
+}
+
+typedef void *(*dbg_callback)(void*);
+
+extern "C" CDECL void *
+rust_dbg_call(dbg_callback cb, void *data) {
+    return cb(data);
+}
+
+extern "C" CDECL void rust_dbg_do_nothing() { }