Avoid logging the CF logs when doing isolation reset
There is no need to debug the device for a reset on
purpose. We only need those logs when fixing a device
not available.
Test: unit tests
Bug: 132995404
Change-Id: Ie048c1f697c75c35a63e6a5262618fd899a3a8a7
diff --git a/src/com/android/tradefed/device/cloud/NestedRemoteDevice.java b/src/com/android/tradefed/device/cloud/NestedRemoteDevice.java
index 9b36eca..82de51c 100644
--- a/src/com/android/tradefed/device/cloud/NestedRemoteDevice.java
+++ b/src/com/android/tradefed/device/cloud/NestedRemoteDevice.java
@@ -88,7 +88,8 @@
}
/** Teardown and restore the virtual device so testing can proceed. */
- public final boolean resetVirtualDevice(ITestLogger logger, IBuildInfo info)
+ public final boolean resetVirtualDevice(
+ ITestLogger logger, IBuildInfo info, boolean resetDueToFailure)
throws DeviceNotAvailableException {
String username = IP_TO_USER.get(getSerialNumber());
// stop_cvd
@@ -103,8 +104,10 @@
}
// Synchronize this so multiple reset do not occur at the same time inside one VM.
synchronized (NestedRemoteDevice.class) {
- // Log the common files before restarting otherwise they are lost
- logDebugFiles(logger, username);
+ if (resetDueToFailure) {
+ // Log the common files before restarting otherwise they are lost
+ logDebugFiles(logger, username);
+ }
// Restart the device without re-creating the data partitions.
List<String> createCommand =
LaunchCvdHelper.createSimpleDeviceCommand(username, true, false, false);
diff --git a/src/com/android/tradefed/invoker/shard/TestsPoolPoller.java b/src/com/android/tradefed/invoker/shard/TestsPoolPoller.java
index 789c86b..b341d87 100644
--- a/src/com/android/tradefed/invoker/shard/TestsPoolPoller.java
+++ b/src/com/android/tradefed/invoker/shard/TestsPoolPoller.java
@@ -267,7 +267,8 @@
try {
if (mDevice instanceof NestedRemoteDevice) {
// If it's not the last device, reset it.
- if (((NestedRemoteDevice) mDevice).resetVirtualDevice(logger, mBuildInfo)) {
+ if (((NestedRemoteDevice) mDevice)
+ .resetVirtualDevice(logger, mBuildInfo, /* Collect the logs */ true)) {
CLog.d("Successful virtual device reset.");
return;
}
diff --git a/src/com/android/tradefed/testtype/suite/ITestSuite.java b/src/com/android/tradefed/testtype/suite/ITestSuite.java
index fd3c900..4080911 100644
--- a/src/com/android/tradefed/testtype/suite/ITestSuite.java
+++ b/src/com/android/tradefed/testtype/suite/ITestSuite.java
@@ -628,7 +628,10 @@
if (mIsolatedModule && (device instanceof NestedRemoteDevice)) {
boolean res =
((NestedRemoteDevice) device)
- .resetVirtualDevice(logger, context.getBuildInfos().get(0));
+ .resetVirtualDevice(
+ logger,
+ context.getBuildInfos().get(0),
+ /* Do not collect the logs */ false);
if (!res) {
String serial = device.getSerialNumber();
throw new DeviceNotAvailableException(
diff --git a/tests/src/com/android/tradefed/device/cloud/NestedRemoteDeviceTest.java b/tests/src/com/android/tradefed/device/cloud/NestedRemoteDeviceTest.java
index 1248d98..efe6c23 100644
--- a/tests/src/com/android/tradefed/device/cloud/NestedRemoteDeviceTest.java
+++ b/tests/src/com/android/tradefed/device/cloud/NestedRemoteDeviceTest.java
@@ -78,6 +78,6 @@
doReturn(stopCvdRes).when(mMockRunUtil).runTimedCmd(Mockito.anyLong(), Mockito.any());
doReturn(mMockIDevice).when(mMockStateMonitor).waitForDeviceAvailable();
- assertTrue(mDevice.resetVirtualDevice(mMockLogger, new BuildInfo()));
+ assertTrue(mDevice.resetVirtualDevice(mMockLogger, new BuildInfo(), true));
}
}