Derive Eq for error types.
This makes it easier to check for them.
Bug: 223166344
Test: m libcompos_common
Change-Id: I719d3b0b8fcad4030d57bf3cbe9b3af7367cb688
diff --git a/compos/common/compos_client.rs b/compos/common/compos_client.rs
index 9314fe1..30c55b3 100644
--- a/compos/common/compos_client.rs
+++ b/compos/common/compos_client.rs
@@ -129,15 +129,13 @@
instance.start()?;
let ready = instance.wait_until_ready(TIMEOUTS.vm_max_time_to_ready);
- if let Err(VmWaitError::Finished) = ready {
- if debug_level != DebugLevel::NONE {
- // The payload has (unexpectedly) finished, but the VM is still running. Give it
- // some time to shutdown to maximize our chances of getting useful logs.
- if let Some(death_reason) =
- instance.wait_for_death_with_timeout(TIMEOUTS.vm_max_time_to_exit)
- {
- bail!("VM died during startup - reason {:?}", death_reason);
- }
+ if ready == Err(VmWaitError::Finished) && debug_level != DebugLevel::NONE {
+ // The payload has (unexpectedly) finished, but the VM is still running. Give it
+ // some time to shutdown to maximize our chances of getting useful logs.
+ if let Some(death_reason) =
+ instance.wait_for_death_with_timeout(TIMEOUTS.vm_max_time_to_exit)
+ {
+ bail!("VM died during startup - reason {:?}", death_reason);
}
}
ready?;
diff --git a/vmclient/src/errors.rs b/vmclient/src/errors.rs
index 994d0ef..43db7f9 100644
--- a/vmclient/src/errors.rs
+++ b/vmclient/src/errors.rs
@@ -17,7 +17,7 @@
use thiserror::Error;
/// An error while waiting for a VM to do something.
-#[derive(Clone, Debug, Error)]
+#[derive(Clone, Debug, Eq, Error, PartialEq)]
pub enum VmWaitError {
/// Timed out waiting for the VM.
#[error("Timed out waiting for VM.")]
@@ -34,7 +34,7 @@
}
/// An error connecting to a VM RPC Binder service.
-#[derive(Clone, Debug, Error)]
+#[derive(Clone, Debug, Eq, Error, PartialEq)]
pub enum ConnectServiceError {
/// The RPC binder connection failed.
#[error("Vsock connection to RPC binder failed.")]