Move test_harness from source directory to OUT_DIR (#2694)
* remove test_harness from source directory * fmt
This commit is contained in:
parent
8f320d4314
commit
8df9e68677
@ -1,7 +1,11 @@
|
|||||||
// build.rs
|
// build.rs
|
||||||
#![forbid(unexpected_cfgs)]
|
#![forbid(unexpected_cfgs)]
|
||||||
|
|
||||||
|
use std::{env, path::Path};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||||
|
let out_dir = out_dir.to_string_lossy().to_string();
|
||||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||||
if target_os != "ios" {
|
if target_os != "ios" {
|
||||||
cc::Build::new().file("src/gettls.c").compile("libgettls.a");
|
cc::Build::new().file("src/gettls.c").compile("libgettls.a");
|
||||||
@ -46,7 +50,13 @@ fn main() {
|
|||||||
"/libpath:{}/.cache/cargo-xwin/xwin/sdk/lib/um/x86_64/",
|
"/libpath:{}/.cache/cargo-xwin/xwin/sdk/lib/um/x86_64/",
|
||||||
std::env::var("HOME").unwrap()
|
std::env::var("HOME").unwrap()
|
||||||
));
|
));
|
||||||
cmd.arg("/dll").arg("/OUT:test_harness.dll");
|
cmd.arg("/dll").arg(format!(
|
||||||
|
"/OUT:{}",
|
||||||
|
Path::new(&out_dir)
|
||||||
|
.join("test_harness.so")
|
||||||
|
.to_str()
|
||||||
|
.unwrap()
|
||||||
|
));
|
||||||
let output = cmd.output().expect("Failed to link test_harness.dll");
|
let output = cmd.output().expect("Failed to link test_harness.dll");
|
||||||
let output_str = format!(
|
let output_str = format!(
|
||||||
"{:?}\nstatus: {}\nstdout: {}\nstderr: {}",
|
"{:?}\nstatus: {}\nstdout: {}\nstderr: {}",
|
||||||
@ -73,7 +83,7 @@ fn main() {
|
|||||||
cmd.args(compiler.args())
|
cmd.args(compiler.args())
|
||||||
.arg("test_harness.cpp")
|
.arg("test_harness.cpp")
|
||||||
.arg("-o")
|
.arg("-o")
|
||||||
.arg("test_harness.so")
|
.arg(Path::new(&out_dir).join("test_harness.so"))
|
||||||
.status()
|
.status()
|
||||||
.expect("Failed to link test_harness");
|
.expect("Failed to link test_harness");
|
||||||
}
|
}
|
||||||
|
@ -549,14 +549,20 @@ mod tests {
|
|||||||
|
|
||||||
SimpleStdoutLogger::set_logger().unwrap();
|
SimpleStdoutLogger::set_logger().unwrap();
|
||||||
|
|
||||||
|
let out_dir = std::env::var_os("OUT_DIR").unwrap();
|
||||||
|
let out_dir = out_dir.to_string_lossy().to_string();
|
||||||
// Check if the harness dynamic library is present, if not - skip the test
|
// Check if the harness dynamic library is present, if not - skip the test
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
let test_harness = "./test_harness.so";
|
let test_harness_name = "test_harness.so";
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let test_harness = ".\\test_harness.dll";
|
let test_harness_name = "test_harness.dll";
|
||||||
|
|
||||||
|
let test_harness = std::path::Path::new(&out_dir).join(test_harness_name);
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
std::path::Path::new(test_harness).exists(),
|
test_harness.exists(),
|
||||||
"Skipping test, {test_harness} not found"
|
"Skipping test, {} not found",
|
||||||
|
test_harness.to_str().unwrap()
|
||||||
);
|
);
|
||||||
|
|
||||||
GUM.set(Gum::obtain())
|
GUM.set(Gum::obtain())
|
||||||
@ -567,7 +573,7 @@ mod tests {
|
|||||||
"--disable-excludes",
|
"--disable-excludes",
|
||||||
"--continue-on-error",
|
"--continue-on-error",
|
||||||
"-H",
|
"-H",
|
||||||
test_harness,
|
test_harness.to_str().unwrap(),
|
||||||
];
|
];
|
||||||
let options: FuzzerOptions = FuzzerOptions::try_parse_from(simulated_args).unwrap();
|
let options: FuzzerOptions = FuzzerOptions::try_parse_from(simulated_args).unwrap();
|
||||||
unsafe { test_asan(&options) }
|
unsafe { test_asan(&options) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user