
* First draft of a Asan tests. As of now, unix-only. This is a WIP, as 1) destroying Gum causes segmentation fault and thus a single test is supported by using a static Gum object. Ideally, this should be fixed and a new Gum instance would be created for each test. 2) 70 identical errors are reported by Asan instead of a a single one. Apart from that, the draft fixes a number of errors found in Asan * Fmt fixes * PR comments addressed * Not crashing upon Asan errors while testing * More PR comments: removing env_logger, renaming harness to test_harness * Revert "More PR comments: removing env_logger, renaming harness to test_harness" This reverts commit 2d3494b3f56e0a5ef23566cb9a884e8c57867b57. * More PR comments: removing env_logger, renaming harness to test_harness * Checking for clang presence and failing the test if harness not found * Fmt * Running multiple Asan tests * Cpp Fmt * clang-format * More clippy complaints and Apple compilation * Last clippy complaints (ran scripts/clippy.sh) * Fixing unused MacOS function * Fixing unused MacOS imports
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
// build.rs
|
|
|
|
fn main() {
|
|
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
|
if target_os != "ios" {
|
|
cc::Build::new().file("src/gettls.c").compile("libgettls.a");
|
|
}
|
|
|
|
// Force linking against libc++
|
|
#[cfg(unix)]
|
|
println!("cargo:rustc-link-lib=dylib=c++");
|
|
|
|
// Build the test harness
|
|
// clang++ -shared -fPIC -O0 -o test_harness.so test_harness.cpp
|
|
#[cfg(unix)]
|
|
{
|
|
// Check if we have clang++ installed
|
|
let clangpp = std::process::Command::new("clang++")
|
|
.arg("--version")
|
|
.output();
|
|
|
|
match clangpp {
|
|
Ok(_) => {
|
|
std::process::Command::new("clang++")
|
|
.arg("-shared")
|
|
.arg("-fPIC")
|
|
.arg("-O0")
|
|
.arg("-o")
|
|
.arg("test_harness.so")
|
|
.arg("test_harness.cpp")
|
|
.status()
|
|
.expect("Failed to build test harness");
|
|
}
|
|
Err(_) => {
|
|
println!("cargo:warning=clang++ not found, skipping test harness build");
|
|
}
|
|
}
|
|
}
|
|
}
|