Skip to content

Commit

Permalink
TEMP: Implement get_os_version
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Apr 8, 2024
1 parent d39dbc3 commit 51c54a0
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions test/test-runner/src/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::HashMap;
#[cfg(target_os = "windows")]
use std::io;
use test_rpc::mullvad_daemon::Verbosity;
use test_rpc::meta::OsVersion;

#[cfg(target_os = "windows")]
use std::ffi::OsString;
Expand Down Expand Up @@ -584,6 +585,47 @@ async fn wait_for_service_state(awaited_state: ServiceState) -> Result<(), test_
Ok(())
}

pub fn get_os_version() -> Result<test_rpc::meta::OsVersion, test_rpc::Error> {
todo!()
#[cfg(target_os = "macos")]
pub fn get_os_version() -> Result<OsVersion, test_rpc::Error> {
use test_rpc::meta::MacosVersion;

let version = talpid_platform_metadata::MacosVersion::new()
.inspect_err(|error| {
log::error!("Failed to obtain OS version: {error}");
})
.map_err(|_| test_rpc::Error::Syscall)?;

Ok(OsVersion::Macos(MacosVersion {
major: version.major_version(),
}))
}

#[cfg(target_os = "windows")]
pub fn get_os_version() -> Result<OsVersion, test_rpc::Error> {
use test_rpc::meta::WindowsVersion;

let version = talpid_platform_metadata::WindowsVersion::new()
.inspect_err(|error| {
log::error!("Failed to obtain OS version: {error}");
})
.map_err(|_| test_rpc::Error::Syscall)?;

Ok(OsVersion::Windows(WindowsVersion {
major: version.release_version().0,
}))
}

#[cfg(target_os = "linux")]
pub fn get_os_version() -> Result<OsVersion, test_rpc::Error> {
use test_rpc::meta::LinuxVersion;

let version = talpid_platform_metadata::LinuxVersion::new()
.inspect_err(|error| {
log::error!("Failed to obtain OS version: {error}");
})
.map_err(|_| test_rpc::Error::Syscall)?;

Ok(OsVersion::Linux(LinuxVersion {
// TODO
}))
}

0 comments on commit 51c54a0

Please sign in to comment.