Add integration test for lib injection
This commit is contained in:
14
tests/mybin/Cargo.lock
generated
Normal file
14
tests/mybin/Cargo.lock
generated
Normal file
@ -0,0 +1,14 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "mybin"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"mylib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mylib"
|
||||
version = "0.1.0"
|
7
tests/mybin/Cargo.toml
Normal file
7
tests/mybin/Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "mybin"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
mylib = { path = "../mylib" }
|
12
tests/mybin/src/main.rs
Normal file
12
tests/mybin/src/main.rs
Normal file
@ -0,0 +1,12 @@
|
||||
#[link(name = "mylib", kind = "dylib")]
|
||||
extern {
|
||||
fn mylib_foo() -> u8;
|
||||
fn mylib_bar() -> u8;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
|
||||
assert_eq!(unsafe { mylib_bar() }, 100);
|
||||
std::process::exit(unsafe { mylib_foo() } as i32);
|
||||
}
|
@ -2,3 +2,8 @@
|
||||
pub extern "C" fn mylib_foo() -> u8 {
|
||||
10
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn mylib_bar() -> u8 {
|
||||
100
|
||||
}
|
||||
|
Reference in New Issue
Block a user