Skip to content

Commit

Permalink
Update path logic in test_tool, too - and trace children in valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Feb 15, 2017
1 parent de08a40 commit a5462dd
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .valgrindrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--suppressions=./valgrind_suppressions.txt --trace-children=no --leak-check=full --trace-children-skip=*/rustc,*/ld,*/dssim
--suppressions=./valgrind_suppressions.txt --trace-children=yes --leak-check=full --trace-children-skip=*/rustc,*/ld,*/dssim
2 changes: 1 addition & 1 deletion imageflow_server/tests/test_ir4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions imageflow_tool/src/self_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ pub fn run_examples(tool_location: Option<PathBuf>){

pub fn run(tool_location: Option<PathBuf>) -> 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);
Expand Down Expand Up @@ -525,7 +525,7 @@ pub fn run(tool_location: Option<PathBuf>) -> i32 {
}

pub fn test_capture(tool_location: Option<PathBuf>) -> 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();
Expand Down
50 changes: 47 additions & 3 deletions imageflow_tool/tests/test_tool.rs
Original file line number Diff line number Diff line change
@@ -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<PathBuf>{
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<PathBuf> {
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));
Expand Down

0 comments on commit a5462dd

Please sign in to comment.