Grouping ABI tests (2) #62401
This commit is contained in:
parent
f036faeb35
commit
98325eb592
4 changed files with 82 additions and 0 deletions
25
src/test/run-pass/abi/extern/extern-pass-TwoU32s.rs
vendored
Normal file
25
src/test/run-pass/abi/extern/extern-pass-TwoU32s.rs
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
// run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
// ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
// Test a foreign function that accepts and returns a struct
|
||||
// by value.
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub struct TwoU32s {
|
||||
one: u32, two: u32
|
||||
}
|
||||
|
||||
#[link(name = "rust_test_helpers", kind = "static")]
|
||||
extern {
|
||||
pub fn rust_dbg_extern_identity_TwoU32s(v: TwoU32s) -> TwoU32s;
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
let x = TwoU32s {one: 22, two: 23};
|
||||
let y = rust_dbg_extern_identity_TwoU32s(x);
|
||||
assert_eq!(x, y);
|
||||
}
|
||||
}
|
25
src/test/run-pass/abi/extern/extern-pass-TwoU64s.rs
vendored
Normal file
25
src/test/run-pass/abi/extern/extern-pass-TwoU64s.rs
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
// run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
// ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
// Test a foreign function that accepts and returns a struct
|
||||
// by value.
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub struct TwoU64s {
|
||||
one: u64, two: u64
|
||||
}
|
||||
|
||||
#[link(name = "rust_test_helpers", kind = "static")]
|
||||
extern {
|
||||
pub fn rust_dbg_extern_identity_TwoU64s(v: TwoU64s) -> TwoU64s;
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
let x = TwoU64s {one: 22, two: 23};
|
||||
let y = rust_dbg_extern_identity_TwoU64s(x);
|
||||
assert_eq!(x, y);
|
||||
}
|
||||
}
|
16
src/test/run-pass/abi/extern/extern-pass-u32.rs
vendored
Normal file
16
src/test/run-pass/abi/extern/extern-pass-u32.rs
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// run-pass
|
||||
// ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
// Test a function that takes/returns a u32.
|
||||
|
||||
|
||||
#[link(name = "rust_test_helpers", kind = "static")]
|
||||
extern {
|
||||
pub fn rust_dbg_extern_identity_u32(v: u32) -> u32;
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
assert_eq!(22, rust_dbg_extern_identity_u32(22));
|
||||
}
|
||||
}
|
16
src/test/run-pass/abi/extern/extern-pass-u64.rs
vendored
Normal file
16
src/test/run-pass/abi/extern/extern-pass-u64.rs
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// run-pass
|
||||
// ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
// Test a call to a function that takes/returns a u64.
|
||||
|
||||
|
||||
#[link(name = "rust_test_helpers", kind = "static")]
|
||||
extern {
|
||||
pub fn rust_dbg_extern_identity_u64(v: u64) -> u64;
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
assert_eq!(22, rust_dbg_extern_identity_u64(22));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue