summaryrefslogtreecommitdiffhomepage
path: root/test/test-rpc
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2023-12-27 14:38:36 +0100
committerDavid Lönnhager <david.l@mullvad.net>2024-01-08 11:34:07 +0100
commit857febc80eaff8f5efc4239b2c625fcfbee78999 (patch)
treece29bea94421884ff91021efa8b43d21088edf3c /test/test-rpc
parentaca939c260f718e3806a67b0a0703a33d4c8157f (diff)
downloadmullvadvpn-857febc80eaff8f5efc4239b2c625fcfbee78999.tar.xz
mullvadvpn-857febc80eaff8f5efc4239b2c625fcfbee78999.zip
Add 'target_os' attribute to test macro
Diffstat (limited to 'test/test-rpc')
-rw-r--r--test/test-rpc/src/client.rs8
-rw-r--r--test/test-rpc/src/lib.rs3
-rw-r--r--test/test-rpc/src/meta.rs25
3 files changed, 15 insertions, 21 deletions
diff --git a/test/test-rpc/src/client.rs b/test/test-rpc/src/client.rs
index 29f86b9443..2c47328e00 100644
--- a/test/test-rpc/src/client.rs
+++ b/test/test-rpc/src/client.rs
@@ -109,14 +109,6 @@ impl ServiceClient {
.map_err(Error::Tarpc)
}
- /// Return the OS of the guest.
- pub async fn get_os(&self) -> Result<meta::Os, Error> {
- self.client
- .get_os(tarpc::context::current())
- .await
- .map_err(Error::Tarpc)
- }
-
/// Wait for the Mullvad service to enter a specified state. The state is inferred from the presence
/// of a named pipe or UDS, not the actual system service state.
pub async fn mullvad_daemon_wait_for_state(
diff --git a/test/test-rpc/src/lib.rs b/test/test-rpc/src/lib.rs
index 73ab467ab8..5919a894d1 100644
--- a/test/test-rpc/src/lib.rs
+++ b/test/test-rpc/src/lib.rs
@@ -111,9 +111,6 @@ mod service {
async fn get_mullvad_app_logs() -> logging::LogOutput;
- /// Return the OS of the guest.
- async fn get_os() -> meta::Os;
-
/// Return status of the system service.
async fn mullvad_daemon_get_status() -> mullvad_daemon::ServiceStatus;
diff --git a/test/test-rpc/src/meta.rs b/test/test-rpc/src/meta.rs
index 67c87738e0..958733b9be 100644
--- a/test/test-rpc/src/meta.rs
+++ b/test/test-rpc/src/meta.rs
@@ -1,12 +1,26 @@
use serde::{Deserialize, Serialize};
+use std::str::FromStr;
-#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
+#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Copy)]
pub enum Os {
Linux,
Macos,
Windows,
}
+impl FromStr for Os {
+ type Err = Box<dyn std::error::Error>;
+
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ match s {
+ "linux" => Ok(Os::Linux),
+ "macos" => Ok(Os::Macos),
+ "windows" => Ok(Os::Windows),
+ other => Err(format!("unknown os {other}").into()),
+ }
+ }
+}
+
impl std::fmt::Display for Os {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
@@ -16,12 +30,3 @@ impl std::fmt::Display for Os {
}
}
}
-
-#[cfg(target_os = "linux")]
-pub const CURRENT_OS: Os = Os::Linux;
-
-#[cfg(target_os = "windows")]
-pub const CURRENT_OS: Os = Os::Windows;
-
-#[cfg(target_os = "macos")]
-pub const CURRENT_OS: Os = Os::Macos;