rialto: Apply timeout to VM exit in test
Now that we have wait_for_death_with_timeout, use it.
Test: Hack VM to not exit, see timeout error
Change-Id: I4f9d03f6de6d441277c949d148c8fd3b30c8f88e
diff --git a/rialto/tests/test.rs b/rialto/tests/test.rs
index 6cd3f2f..b6ccd9e 100644
--- a/rialto/tests/test.rs
+++ b/rialto/tests/test.rs
@@ -21,13 +21,14 @@
},
binder::{ParcelFileDescriptor, ProcessState},
};
-use anyhow::{Context, Error};
+use anyhow::{anyhow, Context, Error};
use log::info;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::os::unix::io::FromRawFd;
use std::panic;
use std::thread;
+use std::time::Duration;
use vmclient::{DeathReason, VmInstance};
const RIALTO_PATH: &str = "/data/local/tmp/rialto_test/arm64/rialto.bin";
@@ -71,7 +72,9 @@
vm.start().context("Failed to start VM")?;
// Wait for VM to finish, and check that it shut down cleanly.
- let death_reason = vm.wait_for_death();
+ let death_reason = vm
+ .wait_for_death_with_timeout(Duration::from_secs(10))
+ .ok_or_else(|| anyhow!("Timed out waiting for VM exit"))?;
assert_eq!(death_reason, DeathReason::Shutdown);
Ok(())