summaryrefslogtreecommitdiffhomepage
path: root/test/test-runner/src/main.rs
diff options
context:
space:
mode:
authorMarkus Pettersson <markus.pettersson@mullvad.net>2023-11-17 15:37:13 +0100
committerMarkus Pettersson <markus.pettersson@mullvad.net>2023-12-06 14:37:06 +0100
commit1b930b893fa3fcb06f5fee4affbfb62887d0e68a (patch)
tree21b0836c5b5730f844950a2764aa652832f13849 /test/test-runner/src/main.rs
parentac3e222d031b0f599561c4c30504de5cd3f871a2 (diff)
downloadmullvadvpn-1b930b893fa3fcb06f5fee4affbfb62887d0e68a.tar.xz
mullvadvpn-1b930b893fa3fcb06f5fee4affbfb62887d0e68a.zip
Implement RPC for reading & writing to app cache file
- Implement RPC for writing to a file in a test runner / guest VM. - Implement RPC for getting app cache directory - Implement RPC for restarting the app in a test runner / guest vm - Implement RPC for starting the app in a test runner / guest vm - Implement RPC for stopping the app in a test runner / guest vm - Implement `find_cache_traces` on Window & macOS
Diffstat (limited to 'test/test-runner/src/main.rs')
-rw-r--r--test/test-runner/src/main.rs44
1 files changed, 42 insertions, 2 deletions
diff --git a/test/test-runner/src/main.rs b/test/test-runner/src/main.rs
index ebf0d1e474..259ccdbab6 100644
--- a/test/test-runner/src/main.rs
+++ b/test/test-runner/src/main.rs
@@ -3,7 +3,7 @@ use logging::LOGGER;
use std::{
collections::{BTreeMap, HashMap},
net::{IpAddr, SocketAddr},
- path::Path,
+ path::{Path, PathBuf},
};
use tarpc::context;
@@ -114,6 +114,13 @@ impl Service for TestServer {
app::find_traces()
}
+ async fn get_mullvad_app_cache_dir(
+ self,
+ _: context::Context,
+ ) -> Result<PathBuf, test_rpc::Error> {
+ app::find_cache_traces()
+ }
+
async fn send_tcp(
self,
_: context::Context,
@@ -140,7 +147,7 @@ impl Service for TestServer {
interface: Option<String>,
destination: IpAddr,
) -> Result<(), test_rpc::Error> {
- net::send_ping(interface.as_ref().map(String::as_str), destination).await
+ net::send_ping(interface.as_deref(), destination).await
}
async fn geoip_lookup(
@@ -219,6 +226,20 @@ impl Service for TestServer {
logging::get_mullvad_app_logs().await
}
+ async fn restart_app(self, _: context::Context) -> Result<(), test_rpc::Error> {
+ sys::restart_app().await
+ }
+
+ /// Stop the Mullvad VPN application.
+ async fn stop_app(self, _: context::Context) -> Result<(), test_rpc::Error> {
+ sys::stop_app().await
+ }
+
+ /// Start the Mullvad VPN application.
+ async fn start_app(self, _: context::Context) -> Result<(), test_rpc::Error> {
+ sys::start_app().await
+ }
+
async fn set_daemon_log_level(
self,
_: context::Context,
@@ -248,6 +269,25 @@ impl Service for TestServer {
Ok(())
}
+ /// Write a slice as the entire contents of a file.
+ ///
+ /// See the documention of [`tokio::fs::write`] for details of the behavior.
+ async fn write_file(
+ self,
+ _: context::Context,
+ dest: PathBuf,
+ bytes: Vec<u8>,
+ ) -> Result<(), test_rpc::Error> {
+ tokio::fs::write(&dest, bytes).await.map_err(|error| {
+ log::error!(
+ "Failed to write to \"{dest}\": {error}",
+ dest = dest.display()
+ );
+ test_rpc::Error::Syscall
+ })?;
+ Ok(())
+ }
+
async fn reboot(self, _: context::Context) -> Result<(), test_rpc::Error> {
sys::reboot()
}