summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorJoakim Hulthe <joakim@hulthe.net>2024-07-05 16:25:03 +0200
committerJoakim Hulthe <joakim@hulthe.net>2024-07-16 15:38:54 +0200
commit28a3776b3a7a35c4e1f964e9dcb9c4698afd7a68 (patch)
treeaf1603682af4658fa85962a804d7bcd289b64ffc /test
parent49ff1b46da6b79df5ed429fa23d40402069662b0 (diff)
downloadmullvadvpn-28a3776b3a7a35c4e1f964e9dcb9c4698afd7a68.tar.xz
mullvadvpn-28a3776b3a7a35c4e1f964e9dcb9c4698afd7a68.zip
Account for CARGO_TARGET_DIR in e2e test-manager
Diffstat (limited to 'test')
-rw-r--r--test/test-manager/src/config.rs35
-rw-r--r--test/test-manager/src/vm/provision.rs10
2 files changed, 29 insertions, 16 deletions
diff --git a/test/test-manager/src/config.rs b/test/test-manager/src/config.rs
index 63631be840..1d7c33021c 100644
--- a/test/test-manager/src/config.rs
+++ b/test/test-manager/src/config.rs
@@ -3,7 +3,7 @@
use serde::{Deserialize, Serialize};
use std::{
collections::BTreeMap,
- io,
+ env, io,
ops::Deref,
path::{Path, PathBuf},
};
@@ -157,17 +157,20 @@ impl VmConfig {
Some((self.ssh_user.as_ref()?, self.ssh_password.as_ref()?))
}
- pub fn get_runner_dir(&self) -> &Path {
- match self.architecture {
- None | Some(Architecture::X64) => self.get_x64_runner_dir(),
- Some(Architecture::Aarch64) => self.get_aarch64_runner_dir(),
- }
+ pub fn get_runner_dir(&self) -> PathBuf {
+ let target_dir = self.get_target_dir();
+ let subdir = match self.architecture {
+ None | Some(Architecture::X64) => self.get_x64_runner_subdir(),
+ Some(Architecture::Aarch64) => self.get_aarch64_runner_subdir(),
+ };
+
+ target_dir.join(subdir)
}
- fn get_x64_runner_dir(&self) -> &Path {
- pub const X64_LINUX_TARGET_DIR: &str = "./target/x86_64-unknown-linux-gnu/release";
- pub const X64_WINDOWS_TARGET_DIR: &str = "./target/x86_64-pc-windows-gnu/release";
- pub const X64_MACOS_TARGET_DIR: &str = "./target/x86_64-apple-darwin/release";
+ fn get_x64_runner_subdir(&self) -> &Path {
+ pub const X64_LINUX_TARGET_DIR: &str = "x86_64-unknown-linux-gnu/release";
+ pub const X64_WINDOWS_TARGET_DIR: &str = "x86_64-pc-windows-gnu/release";
+ pub const X64_MACOS_TARGET_DIR: &str = "x86_64-apple-darwin/release";
match self.os_type {
OsType::Linux => Path::new(X64_LINUX_TARGET_DIR),
@@ -176,9 +179,9 @@ impl VmConfig {
}
}
- fn get_aarch64_runner_dir(&self) -> &Path {
- pub const AARCH64_LINUX_TARGET_DIR: &str = "./target/aarch64-unknown-linux-gnu/release";
- pub const AARCH64_MACOS_TARGET_DIR: &str = "./target/aarch64-apple-darwin/release";
+ fn get_aarch64_runner_subdir(&self) -> &Path {
+ pub const AARCH64_LINUX_TARGET_DIR: &str = "aarch64-unknown-linux-gnu/release";
+ pub const AARCH64_MACOS_TARGET_DIR: &str = "aarch64-apple-darwin/release";
match self.os_type {
OsType::Linux => Path::new(AARCH64_LINUX_TARGET_DIR),
@@ -186,6 +189,12 @@ impl VmConfig {
_ => unimplemented!(),
}
}
+
+ fn get_target_dir(&self) -> PathBuf {
+ env::var("CARGO_TARGET_DIR")
+ .unwrap_or_else(|_| "./target".into())
+ .into()
+ }
}
#[derive(clap::ValueEnum, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
diff --git a/test/test-manager/src/vm/provision.rs b/test/test-manager/src/vm/provision.rs
index aa8949d54f..dfdfd30a39 100644
--- a/test/test-manager/src/vm/provision.rs
+++ b/test/test-manager/src/vm/provision.rs
@@ -24,7 +24,7 @@ pub async fn provision(
ssh(
instance,
config.os_type,
- config.get_runner_dir(),
+ &config.get_runner_dir(),
app_manifest,
user,
password,
@@ -182,8 +182,12 @@ fn ssh_send_file_path(session: &Session, source: &Path, dest_dir: &Path) -> Resu
dest.display(),
);
- let mut file = File::open(source).context("Failed to open file")?;
- let file_len = file.metadata().context("Failed to get file size")?.len();
+ let mut file =
+ File::open(source).with_context(|| format!("Failed to open file at {source:?}"))?;
+ let file_len = file
+ .metadata()
+ .with_context(|| format!("Failed to get file size of {source:?}"))?
+ .len();
ssh_send_file(session, &mut file, file_len, &dest)
}