Close adb connection before shutting down VM
Bug: 192660485
Test: atest AuthFsHostTest on aosp_cf_x86_phone
Change-Id: I810fe2e8eb566c09b7bb4a23d33c9af7a51cc379
diff --git a/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java b/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
index 6d43760..451f9ba 100644
--- a/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
+++ b/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
@@ -234,17 +234,13 @@
}
public void shutdownMicrodroid(String cid) throws DeviceNotAvailableException {
- // Shutdown microdroid
- runOnAndroid(VIRT_APEX + "bin/vm", "stop", cid);
+ // Close the connection before shutting the VM down. Otherwise, b/192660485.
+ tryRunOnHost("adb", "disconnect", MICRODROID_SERIAL);
+ final String serial = getDevice().getSerialNumber();
+ tryRunOnHost("adb", "-s", serial, "forward", "--remove", "tcp:" + TEST_VM_ADB_PORT);
- // TODO(192660485): Figure out why shutting down the VM disconnects adb on cuttlefish
- // temporarily. Without this wait, the rest of `runOnAndroid/skipIfFail` fails due to the
- // connection loss, and results in assumption error exception for the rest of the tests.
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
+ // Shutdown the VM
+ runOnAndroid(VIRT_APEX + "bin/vm", "stop", cid);
}
public void rootMicrodroid() throws DeviceNotAvailableException {