Add integration test for lib injection

This commit is contained in:
Dimitris Zervas
2023-06-03 18:02:46 +03:00
parent 9180d62d67
commit 141bf26048
9 changed files with 109 additions and 21 deletions

14
tests/mybin/Cargo.lock generated Normal file
View 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
View 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
View 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);
}