diff --git a/.valgrindrc b/.valgrindrc index eb0530f9f..2c5343094 100644 --- a/.valgrindrc +++ b/.valgrindrc @@ -1 +1 @@ ---suppressions=./valgrind_suppressions.txt --trace-children=no --leak-check=full --trace-children-skip=*/rustc,*/ld,*/dssim \ No newline at end of file +--suppressions=./valgrind_suppressions.txt --trace-children=yes --leak-check=full --trace-children-skip=*/rustc,*/ld,*/dssim \ No newline at end of file diff --git a/imageflow_server/tests/test_ir4.rs b/imageflow_server/tests/test_ir4.rs index fb634107e..10fd0ea18 100644 --- a/imageflow_server/tests/test_ir4.rs +++ b/imageflow_server/tests/test_ir4.rs @@ -313,7 +313,7 @@ fn test_https(context: ProcTestContext){} #[test] fn run_server_test_ir4_heavy(){ - let context = ProcTestContext::create_timestamp_subdir_within("server_tests_heavy", Some(server_path())); + let context = ProcTestContext::create_timestamp_subdir_within(std::env::current_dir().unwrap().join("server_tests_heavy"), Some(server_path())); { let c = context.subfolder_context("mount_local_test"); //stuck on port 39876 c.exec("diagnose --show-compilation-info").expect_status_code(Some(0)); diff --git a/imageflow_tool/src/self_test.rs b/imageflow_tool/src/self_test.rs index 4cdc73069..2143c29ca 100644 --- a/imageflow_tool/src/self_test.rs +++ b/imageflow_tool/src/self_test.rs @@ -320,7 +320,7 @@ pub fn run_examples(tool_location: Option){ pub fn run(tool_location: Option) -> i32 { - let c = ProcTestContext::create_timestamp_subdir_within("self_tests", tool_location); + let c = ProcTestContext::create_timestamp_subdir_within(std::env::current_dir().unwrap().join("self_tests"), tool_location); // encapsulate scenario/example for reuse for example in scenarios() { example.prepare_scenario(&c); @@ -525,7 +525,7 @@ pub fn run(tool_location: Option) -> i32 { } pub fn test_capture(tool_location: Option) -> i32 { - let c = ProcTestContext::create_timestamp_subdir_within("self_tests", tool_location); + let c = ProcTestContext::create_timestamp_subdir_within(std::env::current_dir().unwrap().join("self_tests"), tool_location); // encapsulate scenario/example for reuse { let recipe = s::Build001::example_with_steps(); diff --git a/imageflow_tool/tests/test_tool.rs b/imageflow_tool/tests/test_tool.rs index 595942451..983a35030 100644 --- a/imageflow_tool/tests/test_tool.rs +++ b/imageflow_tool/tests/test_tool.rs @@ -1,11 +1,55 @@ extern crate imageflow_tool_lib; +extern crate imageflow_types as s; use std::io::Write; +use std::path::{Path,PathBuf}; + + +fn build_dirs() -> Vec{ + let target_triple = ::s::version::get_build_env_value("TARGET").expect("TARGET triple required"); + let profile = ::s::version::get_build_env_value("PROFILE").expect("PROFILE (debug/release) required"); + + + let target_dir = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().join("target"); + + let a = target_dir.join(target_triple).join(profile); + let b = target_dir.join(profile); + vec![a,b] +} +#[cfg(windows)] +fn binary_ext() -> &'static str{ + "exe" +} +#[cfg(not(windows))] +fn binary_ext() -> &'static str{ + "" +} + +fn locate_binary(name: &str) -> Option { + for dir in build_dirs() { + let file_path = dir.join(name).with_extension(binary_ext()); + + if file_path.exists() { + return Some(dir.join(name)) + } + } + None +} + + +fn tool_path() -> PathBuf { + match locate_binary("imageflow_tool"){ + Some(v) => v, + None => { + panic!("Failed to locate imageflow_tool binary in {:?}", build_dirs()); + } + } +} + #[test] fn run_imageflow_tool_self_test(){ - let self_path = std::env::current_exe().expect("For --self-test to work, we need to know the binary's location. env::current_exe failed"); - // back out of the 'deps' directory as well - let tool = self_path.parent().unwrap().parent().unwrap().join("imageflow_tool"); + + let tool = tool_path(); let _ = writeln!(std::io::stdout(), "Testing binary {:?}", &tool); imageflow_tool_lib::self_test::run(Some(tool.clone())); imageflow_tool_lib::self_test::test_capture(Some(tool));