From a1422e6bcab81492d20ae312c92cdc2491705876 Mon Sep 17 00:00:00 2001 From: Zach Reizner Date: Thu, 20 Sep 2018 14:41:40 -0700 Subject: fix warning and bit rotted tests uncovered by kokoro TEST=run kokoro presubmit BUG=None Change-Id: I301551f8f58263f1a8b7a8276867881cb17517ab Reviewed-on: https://chromium-review.googlesource.com/1236889 Commit-Ready: Zach Reizner Tested-by: Zach Reizner Reviewed-by: Stephen Barber --- tests/plugins.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/plugins.rs b/tests/plugins.rs index 987b033..67e68e6 100644 --- a/tests/plugins.rs +++ b/tests/plugins.rs @@ -31,6 +31,16 @@ impl Drop for RemovePath { } fn get_target_path() -> PathBuf { + current_exe() + .ok() + .map(|mut path| { + path.pop(); + path + }) + .expect("failed to get crosvm binary directory") +} + +fn get_crosvm_path() -> PathBuf { current_exe() .ok() .map(|mut path| { @@ -44,8 +54,8 @@ fn get_target_path() -> PathBuf { } fn build_plugin(src: &str) -> RemovePath { - let mut out_bin = PathBuf::from("target"); let libcrosvm_plugin_dir = get_target_path(); + let mut out_bin = libcrosvm_plugin_dir.clone(); out_bin.push(thread_rng() .gen_ascii_chars() .take(10) @@ -77,7 +87,7 @@ fn build_plugin(src: &str) -> RemovePath { } fn run_plugin(bin_path: &Path, with_sandbox: bool) { - let mut crosvm_path = get_target_path(); + let mut crosvm_path = get_crosvm_path(); crosvm_path.push("crosvm"); let mut cmd = Command::new(crosvm_path); cmd.args(&["run", -- cgit 1.4.1