Skip to content

Commit c17447f

Browse files
committed
rt: Move some test functions to rust_test_helpers
1 parent 4541c6c commit c17447f

File tree

6 files changed

+70
-71
lines changed

6 files changed

+70
-71
lines changed

src/rt/rust_builtin.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -99,53 +99,6 @@ rand_free(rust_rng *rng) {
9999
free(rng);
100100
}
101101

102-
103-
/* Debug helpers strictly to verify ABI conformance.
104-
*
105-
* FIXME (#2665): move these into a testcase when the testsuite
106-
* understands how to have explicit C files included.
107-
*/
108-
109-
struct quad {
110-
uint64_t a;
111-
uint64_t b;
112-
uint64_t c;
113-
uint64_t d;
114-
};
115-
116-
struct floats {
117-
double a;
118-
uint8_t b;
119-
double c;
120-
};
121-
122-
extern "C" quad
123-
debug_abi_1(quad q) {
124-
quad qq = { q.c + 1,
125-
q.d - 1,
126-
q.a + 1,
127-
q.b - 1 };
128-
return qq;
129-
}
130-
131-
extern "C" floats
132-
debug_abi_2(floats f) {
133-
floats ff = { f.c + 1.0,
134-
0xff,
135-
f.a - 1.0 };
136-
return ff;
137-
}
138-
139-
extern "C" int
140-
debug_static_mut;
141-
142-
int debug_static_mut = 3;
143-
144-
extern "C" void
145-
debug_static_mut_check_four() {
146-
assert(debug_static_mut == 4);
147-
}
148-
149102
extern "C" CDECL char*
150103
#if defined(__WIN32__)
151104
rust_list_dir_val(WIN32_FIND_DATA* entry_ptr) {

src/rt/rust_test_helpers.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,49 @@ extern "C" CDECL intptr_t
178178
rust_get_test_int() {
179179
return 1;
180180
}
181+
182+
/* Debug helpers strictly to verify ABI conformance.
183+
*
184+
* FIXME (#2665): move these into a testcase when the testsuite
185+
* understands how to have explicit C files included.
186+
*/
187+
188+
struct quad {
189+
uint64_t a;
190+
uint64_t b;
191+
uint64_t c;
192+
uint64_t d;
193+
};
194+
195+
struct floats {
196+
double a;
197+
uint8_t b;
198+
double c;
199+
};
200+
201+
extern "C" quad
202+
rust_dbg_abi_1(quad q) {
203+
quad qq = { q.c + 1,
204+
q.d - 1,
205+
q.a + 1,
206+
q.b - 1 };
207+
return qq;
208+
}
209+
210+
extern "C" floats
211+
rust_dbg_abi_2(floats f) {
212+
floats ff = { f.c + 1.0,
213+
0xff,
214+
f.a - 1.0 };
215+
return ff;
216+
}
217+
218+
extern "C" int
219+
rust_dbg_static_mut;
220+
221+
int rust_dbg_static_mut = 3;
222+
223+
extern "C" void
224+
rust_dbg_static_mut_check_four() {
225+
assert(rust_dbg_static_mut == 4);
226+
}

src/rt/rustrt.def.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
debug_abi_1
2-
debug_abi_2
3-
debug_static_mut
4-
debug_static_mut_check_four
1+
rust_dbg_abi_1
2+
rust_dbg_abi_2
3+
rust_dbg_static_mut
4+
rust_dbg_static_mut_check_four
55
get_time
66
rust_tzset
77
rust_gmtime

src/test/compile-fail/attrs-after-extern-mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use std::libc;
1616

1717
#[nolink]
1818
extern {
19-
static mut debug_static_mut: libc::c_int;
20-
pub fn debug_static_mut_check_four();
19+
static mut rust_dbg_static_mut: libc::c_int;
20+
pub fn rust_dbg_static_mut_check_four();
2121
#[cfg(stage37)] //~ ERROR expected item after attributes
2222
}
2323

src/test/run-pass/static-mut-foreign.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use std::libc;
1616

1717
#[nolink]
1818
extern {
19-
static mut debug_static_mut: libc::c_int;
20-
pub fn debug_static_mut_check_four();
19+
static mut rust_dbg_static_mut: libc::c_int;
20+
pub fn rust_dbg_static_mut_check_four();
2121
}
2222

2323
unsafe fn static_bound(_: &'static libc::c_int) {}
@@ -28,18 +28,18 @@ fn static_bound_set(a: &'static mut libc::c_int) {
2828

2929
#[fixed_stack_segment] #[inline(never)]
3030
unsafe fn run() {
31-
assert!(debug_static_mut == 3);
32-
debug_static_mut = 4;
33-
assert!(debug_static_mut == 4);
34-
debug_static_mut_check_four();
35-
debug_static_mut += 1;
36-
assert!(debug_static_mut == 5);
37-
debug_static_mut *= 3;
38-
assert!(debug_static_mut == 15);
39-
debug_static_mut = -3;
40-
assert!(debug_static_mut == -3);
41-
static_bound(&debug_static_mut);
42-
static_bound_set(&mut debug_static_mut);
31+
assert!(rust_dbg_static_mut == 3);
32+
rust_dbg_static_mut = 4;
33+
assert!(rust_dbg_static_mut == 4);
34+
rust_dbg_static_mut_check_four();
35+
rust_dbg_static_mut += 1;
36+
assert!(rust_dbg_static_mut == 5);
37+
rust_dbg_static_mut *= 3;
38+
assert!(rust_dbg_static_mut == 15);
39+
rust_dbg_static_mut = -3;
40+
assert!(rust_dbg_static_mut == -3);
41+
static_bound(&rust_dbg_static_mut);
42+
static_bound_set(&mut rust_dbg_static_mut);
4343
}
4444

4545
pub fn main() {

src/test/run-pass/struct-return.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ mod rustrt {
1616

1717
#[nolink]
1818
extern {
19-
pub fn debug_abi_1(q: Quad) -> Quad;
20-
pub fn debug_abi_2(f: Floats) -> Floats;
19+
pub fn rust_dbg_abi_1(q: Quad) -> Quad;
20+
pub fn rust_dbg_abi_2(f: Floats) -> Floats;
2121
}
2222
}
2323

@@ -28,7 +28,7 @@ fn test1() {
2828
b: 0xbbbb_bbbb_bbbb_bbbb_u64,
2929
c: 0xcccc_cccc_cccc_cccc_u64,
3030
d: 0xdddd_dddd_dddd_dddd_u64 };
31-
let qq = rustrt::debug_abi_1(q);
31+
let qq = rustrt::rust_dbg_abi_1(q);
3232
error!("a: %x", qq.a as uint);
3333
error!("b: %x", qq.b as uint);
3434
error!("c: %x", qq.c as uint);
@@ -48,7 +48,7 @@ fn test2() {
4848
let f = Floats { a: 1.234567890e-15_f64,
4949
b: 0b_1010_1010_u8,
5050
c: 1.0987654321e-15_f64 };
51-
let ff = rustrt::debug_abi_2(f);
51+
let ff = rustrt::rust_dbg_abi_2(f);
5252
error!("a: %f", ff.a as float);
5353
error!("b: %u", ff.b as uint);
5454
error!("c: %f", ff.c as float);

0 commit comments

Comments
 (0)