Skip to content

Commit

Permalink
Don't run split_tunnel test on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
hulthe committed Mar 20, 2024
1 parent 6a09062 commit 52b56e5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
7 changes: 3 additions & 4 deletions test/test-manager/src/tests/split_tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const LEAK_DESTINATION: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(1,
/// - Splitting a process shouldn't do anything if tunnel is not connected.
/// - A split process should never push traffic through the tunnel.
/// - Splitting/unsplitting should work regardless if process is running.
#[test_function]
#[test_function(target_os = "linux", target_os = "windows")]
pub async fn test_split_tunnel(
_ctx: TestContext,
rpc: ServiceClient,
Expand All @@ -39,7 +39,6 @@ pub async fn test_split_tunnel(
.with_context(|| "Test disconnected and split")?;
checker.unsplit().await?;

// TODO: Overkill?
// Test that program is behaving being split/unsplit while running and we are disconnected
let mut handle = checker.spawn().await?;
handle.split().await?;
Expand Down Expand Up @@ -186,7 +185,7 @@ impl ConnChecker {
.await?;
self.mullvad_client.set_split_tunnel_state(true).await?;
}
Os::Macos => todo!("MacOS"),
Os::Macos => unimplemented!("MacOS"),
}

Ok(())
Expand All @@ -205,7 +204,7 @@ impl ConnChecker {
.remove_split_tunnel_app(&self.executable_path)
.await?;
}
Os::Macos => todo!("MacOS"),
Os::Macos => unimplemented!("MacOS"),
}

Ok(())
Expand Down
6 changes: 2 additions & 4 deletions test/test-manager/src/tests/test_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use test_rpc::mullvad_daemon::MullvadClientVersion;
pub struct TestMetadata {
pub name: &'static str,
pub command: &'static str,
pub target_os: Option<Os>,
pub targets: &'static [Os],
pub mullvad_client_version: MullvadClientVersion,
pub func: TestWrapperFunction,
pub priority: Option<i32>,
Expand All @@ -16,9 +16,7 @@ pub struct TestMetadata {

impl TestMetadata {
pub fn should_run_on_os(&self, os: Os) -> bool {
self.target_os
.map(|target_os| target_os == os)
.unwrap_or(true)
self.targets.is_empty() || self.targets.contains(&os)
}
}

Expand Down
36 changes: 20 additions & 16 deletions test/test-manager/test_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn get_test_macro_parameters(attributes: &syn::AttributeArgs) -> Result<MacroPar
let mut cleanup = true;
let mut always_run = false;
let mut must_succeed = false;
let mut target_os = None;
let mut targets = vec![];

for attribute in attributes {
// we only use name-value attributes
Expand Down Expand Up @@ -155,14 +155,16 @@ fn get_test_macro_parameters(attributes: &syn::AttributeArgs) -> Result<MacroPar
bail!(nv, "'target_os' should have a string value");
};

if target_os.is_some() {
bail!(nv, "can't specify multiple targets");
}

target_os = match lit_str.value().parse() {
Ok(os) => Some(os),
let target = match lit_str.value().parse() {
Ok(os) => os,
Err(e) => bail!(lit_str, "{e}"),
};

if targets.contains(&target) {
bail!(nv, "Duplicate target");
}

targets.push(target);
} else {
bail!(nv, "unknown attribute");
}
Expand All @@ -173,7 +175,7 @@ fn get_test_macro_parameters(attributes: &syn::AttributeArgs) -> Result<MacroPar
cleanup,
always_run,
must_succeed,
target_os,
targets,
})
}

Expand All @@ -182,12 +184,14 @@ fn create_test(test_function: TestFunction) -> proc_macro2::TokenStream {
Some(priority) => quote! { Some(#priority) },
None => quote! { None },
};
let target_os = match test_function.macro_parameters.target_os {
Some(Os::Linux) => quote! { Some(::test_rpc::meta::Os::Linux) },
Some(Os::Macos) => quote! { Some(::test_rpc::meta::Os::Macos) },
Some(Os::Windows) => quote! { Some(::test_rpc::meta::Os::Windows) },
None => quote! { None },
};
let targets: proc_macro2::TokenStream = (test_function.macro_parameters.targets.iter())
.map(|&os| match os {
Os::Linux => quote! { ::test_rpc::meta::Os::Linux, },
Os::Macos => quote! { ::test_rpc::meta::Os::Macos, },
Os::Windows => quote! { ::test_rpc::meta::Os::Windows, },
})
.collect();

let should_cleanup = test_function.macro_parameters.cleanup;
let always_run = test_function.macro_parameters.always_run;
let must_succeed = test_function.macro_parameters.must_succeed;
Expand Down Expand Up @@ -230,7 +234,7 @@ fn create_test(test_function: TestFunction) -> proc_macro2::TokenStream {
inventory::submit!(crate::tests::test_metadata::TestMetadata {
name: stringify!(#func_name),
command: stringify!(#func_name),
target_os: #target_os,
targets: &[#targets],
mullvad_client_version: #function_mullvad_version,
func: #wrapper_closure,
priority: #test_function_priority,
Expand All @@ -252,7 +256,7 @@ struct MacroParameters {
cleanup: bool,
always_run: bool,
must_succeed: bool,
target_os: Option<Os>,
targets: Vec<Os>,
}

enum MullvadClient {
Expand Down

0 comments on commit 52b56e5

Please sign in to comment.