Re-connect adb while cleaning up VM.
For reasons I don't entirely understand our adb session gets
unexpectedly closed. Run some spurious commands to ensure we detect
this & recover before proceeding.
Bug: 194219111
Test: atest CompOsTestCases, adb shell getenforce -> Enforcing
Test: atest CompOsTestCases then atest keystore2_selinux_test
Change-Id: I6841c6c71dc76f8dc3753ede5a2a76c18fca3e5a
diff --git a/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java b/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
index 40debba..a9e5040 100644
--- a/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
+++ b/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
@@ -70,6 +70,14 @@
// disconnect from microdroid
tryRunOnHost("adb", "disconnect", MICRODROID_SERIAL);
+ // Make sure we're connected to the host adb again (b/194219111)
+ for (int retry = 0; retry < 3; ++retry) {
+ if (android.tryRun("true") != null) {
+ break;
+ }
+ androidDevice.waitForDeviceOnline(1000);
+ }
+
// kill stale VMs and directories
android.tryRun("killall", "crosvm");
android.tryRun("rm", "-rf", "/data/misc/virtualizationservice/*");