提交 c17447f8 编写于 作者: B Brian Anderson

rt: Move some test functions to rust_test_helpers

上级 4541c6cf
......@@ -99,53 +99,6 @@ rand_free(rust_rng *rng) {
free(rng);
}
/* Debug helpers strictly to verify ABI conformance.
*
* FIXME (#2665): move these into a testcase when the testsuite
* understands how to have explicit C files included.
*/
struct quad {
uint64_t a;
uint64_t b;
uint64_t c;
uint64_t d;
};
struct floats {
double a;
uint8_t b;
double c;
};
extern "C" quad
debug_abi_1(quad q) {
quad qq = { q.c + 1,
q.d - 1,
q.a + 1,
q.b - 1 };
return qq;
}
extern "C" floats
debug_abi_2(floats f) {
floats ff = { f.c + 1.0,
0xff,
f.a - 1.0 };
return ff;
}
extern "C" int
debug_static_mut;
int debug_static_mut = 3;
extern "C" void
debug_static_mut_check_four() {
assert(debug_static_mut == 4);
}
extern "C" CDECL char*
#if defined(__WIN32__)
rust_list_dir_val(WIN32_FIND_DATA* entry_ptr) {
......
......@@ -178,3 +178,49 @@ extern "C" CDECL intptr_t
rust_get_test_int() {
return 1;
}
/* Debug helpers strictly to verify ABI conformance.
*
* FIXME (#2665): move these into a testcase when the testsuite
* understands how to have explicit C files included.
*/
struct quad {
uint64_t a;
uint64_t b;
uint64_t c;
uint64_t d;
};
struct floats {
double a;
uint8_t b;
double c;
};
extern "C" quad
rust_dbg_abi_1(quad q) {
quad qq = { q.c + 1,
q.d - 1,
q.a + 1,
q.b - 1 };
return qq;
}
extern "C" floats
rust_dbg_abi_2(floats f) {
floats ff = { f.c + 1.0,
0xff,
f.a - 1.0 };
return ff;
}
extern "C" int
rust_dbg_static_mut;
int rust_dbg_static_mut = 3;
extern "C" void
rust_dbg_static_mut_check_four() {
assert(rust_dbg_static_mut == 4);
}
debug_abi_1
debug_abi_2
debug_static_mut
debug_static_mut_check_four
rust_dbg_abi_1
rust_dbg_abi_2
rust_dbg_static_mut
rust_dbg_static_mut_check_four
get_time
rust_tzset
rust_gmtime
......
......@@ -16,8 +16,8 @@
#[nolink]
extern {
static mut debug_static_mut: libc::c_int;
pub fn debug_static_mut_check_four();
static mut rust_dbg_static_mut: libc::c_int;
pub fn rust_dbg_static_mut_check_four();
#[cfg(stage37)] //~ ERROR expected item after attributes
}
......
......@@ -16,8 +16,8 @@
#[nolink]
extern {
static mut debug_static_mut: libc::c_int;
pub fn debug_static_mut_check_four();
static mut rust_dbg_static_mut: libc::c_int;
pub fn rust_dbg_static_mut_check_four();
}
unsafe fn static_bound(_: &'static libc::c_int) {}
......@@ -28,18 +28,18 @@ fn static_bound_set(a: &'static mut libc::c_int) {
#[fixed_stack_segment] #[inline(never)]
unsafe fn run() {
assert!(debug_static_mut == 3);
debug_static_mut = 4;
assert!(debug_static_mut == 4);
debug_static_mut_check_four();
debug_static_mut += 1;
assert!(debug_static_mut == 5);
debug_static_mut *= 3;
assert!(debug_static_mut == 15);
debug_static_mut = -3;
assert!(debug_static_mut == -3);
static_bound(&debug_static_mut);
static_bound_set(&mut debug_static_mut);
assert!(rust_dbg_static_mut == 3);
rust_dbg_static_mut = 4;
assert!(rust_dbg_static_mut == 4);
rust_dbg_static_mut_check_four();
rust_dbg_static_mut += 1;
assert!(rust_dbg_static_mut == 5);
rust_dbg_static_mut *= 3;
assert!(rust_dbg_static_mut == 15);
rust_dbg_static_mut = -3;
assert!(rust_dbg_static_mut == -3);
static_bound(&rust_dbg_static_mut);
static_bound_set(&mut rust_dbg_static_mut);
}
pub fn main() {
......
......@@ -16,8 +16,8 @@ mod rustrt {
#[nolink]
extern {
pub fn debug_abi_1(q: Quad) -> Quad;
pub fn debug_abi_2(f: Floats) -> Floats;
pub fn rust_dbg_abi_1(q: Quad) -> Quad;
pub fn rust_dbg_abi_2(f: Floats) -> Floats;
}
}
......@@ -28,7 +28,7 @@ fn test1() {
b: 0xbbbb_bbbb_bbbb_bbbb_u64,
c: 0xcccc_cccc_cccc_cccc_u64,
d: 0xdddd_dddd_dddd_dddd_u64 };
let qq = rustrt::debug_abi_1(q);
let qq = rustrt::rust_dbg_abi_1(q);
error!("a: %x", qq.a as uint);
error!("b: %x", qq.b as uint);
error!("c: %x", qq.c as uint);
......@@ -48,7 +48,7 @@ fn test2() {
let f = Floats { a: 1.234567890e-15_f64,
b: 0b_1010_1010_u8,
c: 1.0987654321e-15_f64 };
let ff = rustrt::debug_abi_2(f);
let ff = rustrt::rust_dbg_abi_2(f);
error!("a: %f", ff.a as float);
error!("b: %u", ff.b as uint);
error!("c: %f", ff.c as float);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册