Grouping ABI tests (2) #62401

This commit is contained in:
Kevin Per 2019-07-09 09:05:45 +02:00
parent f036faeb35
commit 98325eb592
4 changed files with 82 additions and 0 deletions

View 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);
}
}

View 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);
}
}

View 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));
}
}

View 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));
}
}