Skip to content

Commit 98325eb

Browse files
committed
Grouping ABI tests (2) #62401
1 parent f036fae commit 98325eb

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// run-pass
2+
#![allow(improper_ctypes)]
3+
4+
// ignore-wasm32-bare no libc for ffi testing
5+
6+
// Test a foreign function that accepts and returns a struct
7+
// by value.
8+
9+
#[derive(Copy, Clone, PartialEq, Debug)]
10+
pub struct TwoU32s {
11+
one: u32, two: u32
12+
}
13+
14+
#[link(name = "rust_test_helpers", kind = "static")]
15+
extern {
16+
pub fn rust_dbg_extern_identity_TwoU32s(v: TwoU32s) -> TwoU32s;
17+
}
18+
19+
pub fn main() {
20+
unsafe {
21+
let x = TwoU32s {one: 22, two: 23};
22+
let y = rust_dbg_extern_identity_TwoU32s(x);
23+
assert_eq!(x, y);
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// run-pass
2+
#![allow(improper_ctypes)]
3+
4+
// ignore-wasm32-bare no libc for ffi testing
5+
6+
// Test a foreign function that accepts and returns a struct
7+
// by value.
8+
9+
#[derive(Copy, Clone, PartialEq, Debug)]
10+
pub struct TwoU64s {
11+
one: u64, two: u64
12+
}
13+
14+
#[link(name = "rust_test_helpers", kind = "static")]
15+
extern {
16+
pub fn rust_dbg_extern_identity_TwoU64s(v: TwoU64s) -> TwoU64s;
17+
}
18+
19+
pub fn main() {
20+
unsafe {
21+
let x = TwoU64s {one: 22, two: 23};
22+
let y = rust_dbg_extern_identity_TwoU64s(x);
23+
assert_eq!(x, y);
24+
}
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// run-pass
2+
// ignore-wasm32-bare no libc for ffi testing
3+
4+
// Test a function that takes/returns a u32.
5+
6+
7+
#[link(name = "rust_test_helpers", kind = "static")]
8+
extern {
9+
pub fn rust_dbg_extern_identity_u32(v: u32) -> u32;
10+
}
11+
12+
pub fn main() {
13+
unsafe {
14+
assert_eq!(22, rust_dbg_extern_identity_u32(22));
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// run-pass
2+
// ignore-wasm32-bare no libc for ffi testing
3+
4+
// Test a call to a function that takes/returns a u64.
5+
6+
7+
#[link(name = "rust_test_helpers", kind = "static")]
8+
extern {
9+
pub fn rust_dbg_extern_identity_u64(v: u64) -> u64;
10+
}
11+
12+
pub fn main() {
13+
unsafe {
14+
assert_eq!(22, rust_dbg_extern_identity_u64(22));
15+
}
16+
}

0 commit comments

Comments
 (0)