summaryrefslogtreecommitdiffhomepage
path: root/test/test-runner/src
diff options
context:
space:
mode:
authorSebastian Holmin <sebastian.holmin@mullvad.net>2025-07-11 10:15:48 +0200
committerSebastian Holmin <sebastian.holmin@mullvad.net>2025-07-11 10:15:48 +0200
commit04e07b831e66e8461d9d6dcd6217a90f6db1d3e2 (patch)
tree45566123976ffba5101d68a1e003c93e9bfe0ac6 /test/test-runner/src
parent62ad63a99a450a31c484316d0ddd424d9ff7192d (diff)
parent2985cf50fc64a715767e4d3e3617933804e42af0 (diff)
downloadmullvadvpn-04e07b831e66e8461d9d6dcd6217a90f6db1d3e2.tar.xz
mullvadvpn-04e07b831e66e8461d9d6dcd6217a90f6db1d3e2.zip
Merge branch 'e2e-failed-upgrades-only-softlock'
Diffstat (limited to 'test/test-runner/src')
-rw-r--r--test/test-runner/src/main.rs25
-rw-r--r--test/test-runner/src/sys.rs45
2 files changed, 70 insertions, 0 deletions
diff --git a/test/test-runner/src/main.rs b/test/test-runner/src/main.rs
index 95392dc93f..51a357543e 100644
--- a/test/test-runner/src/main.rs
+++ b/test/test-runner/src/main.rs
@@ -318,6 +318,31 @@ impl Service for TestServer {
sys::start_app().await
}
+ /// Disable the Mullvad VPN system service.
+ async fn disable_mullvad_daemon(self, _: context::Context) -> Result<(), test_rpc::Error> {
+ #[cfg(not(target_os = "windows"))]
+ {
+ log::warn!("disable_mullvad_daemon is only implemented on Windows");
+ return Err(test_rpc::Error::Syscall);
+ }
+ #[cfg(target_os = "windows")]
+ {
+ sys::disable_system_service_startup().await
+ }
+ }
+
+ async fn enable_mullvad_daemon(self, _: context::Context) -> Result<(), test_rpc::Error> {
+ #[cfg(not(target_os = "windows"))]
+ {
+ log::warn!("enable_mullvad_daemon is only implemented on Windows");
+ return Err(test_rpc::Error::Syscall);
+ }
+ #[cfg(target_os = "windows")]
+ {
+ sys::enable_system_service_startup().await
+ }
+ }
+
async fn set_daemon_log_level(
self,
_: context::Context,
diff --git a/test/test-runner/src/sys.rs b/test/test-runner/src/sys.rs
index a20a84cbaa..3490353b55 100644
--- a/test/test-runner/src/sys.rs
+++ b/test/test-runner/src/sys.rs
@@ -284,6 +284,51 @@ pub async fn start_app() -> Result<(), test_rpc::Error> {
Ok(())
}
+/// Disable the Mullvad VPN system service startup. This will not trigger the service to stop
+/// immediately, but it will prevent it from starting on the next system boot.
+#[cfg(target_os = "windows")]
+pub async fn disable_system_service_startup() -> Result<(), test_rpc::Error> {
+ let status = tokio::process::Command::new("powershell")
+ .args([
+ "-NoProfile",
+ "-Command",
+ "Set-Service -Name MullvadVPN -StartupType Disabled",
+ ])
+ .status()
+ .await
+ .map_err(|e| test_rpc::Error::ServiceChange(e.to_string()))?;
+
+ if !status.success() {
+ return Err(test_rpc::Error::ServiceChange(
+ "Failed to disable MullvadVPN service".to_string(),
+ ));
+ }
+
+ Ok(())
+}
+
+/// Enable the Mullvad VPN system service startup. This will configure the service to start automatically on system boot.
+#[cfg(target_os = "windows")]
+pub async fn enable_system_service_startup() -> Result<(), test_rpc::Error> {
+ let status = tokio::process::Command::new("powershell")
+ .args([
+ "-NoProfile",
+ "-Command",
+ "Set-Service -Name MullvadVPN -StartupType Automatic",
+ ])
+ .status()
+ .await
+ .map_err(|e| test_rpc::Error::ServiceChange(e.to_string()))?;
+
+ if !status.success() {
+ return Err(test_rpc::Error::ServiceChange(
+ "Failed to enable MullvadVPN service".to_string(),
+ ));
+ }
+
+ Ok(())
+}
+
/// Restart the Mullvad VPN application.
///
/// This function waits for the app to successfully start again.