Avoid unnecessary tear down in the test
While I'm on this, rename the testing function to highlight the
assumption check.
Bug: None
Test: atest AVFHostTestCase
Test: mma under packages/modules/Virtualization
Change-Id: Ied61d0c16c1e6ebd4e84599afa16567c2aa7e536
diff --git a/compos/tests/java/android/compos/test/ComposTestCase.java b/compos/tests/java/android/compos/test/ComposTestCase.java
index 8a1b41a..eb2e072 100644
--- a/compos/tests/java/android/compos/test/ComposTestCase.java
+++ b/compos/tests/java/android/compos/test/ComposTestCase.java
@@ -80,7 +80,7 @@
@Before
public void setUp() throws Exception {
- testIfDeviceIsCapable(getDevice());
+ assumeDeviceIsCapable(getDevice());
String value = getDevice().getProperty(SYSTEM_SERVER_COMPILER_FILTER_PROP_NAME);
if (value == null) {
diff --git a/tests/benchmark_hostside/java/android/avf/test/AVFHostTestCase.java b/tests/benchmark_hostside/java/android/avf/test/AVFHostTestCase.java
index 73c3b33..59f1d80 100644
--- a/tests/benchmark_hostside/java/android/avf/test/AVFHostTestCase.java
+++ b/tests/benchmark_hostside/java/android/avf/test/AVFHostTestCase.java
@@ -89,10 +89,12 @@
@Before
public void setUp() throws Exception {
- testIfDeviceIsCapable(getDevice());
- mNeedTearDown = true;
+ mNeedTearDown = false;
mNeedToRestartPkvmStatus = false;
+ assumeDeviceIsCapable(getDevice());
+ mNeedTearDown = true;
+
getDevice().installPackage(findTestFile(APK_NAME), /* reinstall */ false);
mMetricsProcessor = new MetricsProcessor(getMetricPrefix() + "hostside/");
@@ -102,7 +104,7 @@
public void tearDown() throws Exception {
if (!mNeedTearDown) {
// If we skipped setUp, we don't need to undo it, and that avoids potential exceptions
- // incompatible hardware. (Note that tests can change what testIfDeviceIsCapable()
+ // incompatible hardware. (Note that tests can change what assumeDeviceIsCapable()
// sees, so we can't rely on that - b/268688303.)
return;
}
diff --git a/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java b/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java
index a7f7906..4807c0f 100644
--- a/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java
+++ b/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java
@@ -97,7 +97,7 @@
DeviceProperties.create(getDevice()::getProperty).getMetricsTag());
}
- public static void testIfDeviceIsCapable(ITestDevice androidDevice) throws Exception {
+ public static void assumeDeviceIsCapable(ITestDevice androidDevice) throws Exception {
assumeTrue("Need an actual TestDevice", androidDevice instanceof TestDevice);
TestDevice testDevice = (TestDevice) androidDevice;
assumeTrue(
diff --git a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
index 687756e..e41d434 100644
--- a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
+++ b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
@@ -970,7 +970,7 @@
@Before
public void setUp() throws Exception {
- testIfDeviceIsCapable(getDevice());
+ assumeDeviceIsCapable(getDevice());
mMetricPrefix = getMetricPrefix() + "microdroid/";
mMicrodroidDevice = null;
diff --git a/tests/hostside/java/com/android/microdroid/test/PvmfwDebugPolicyHostTests.java b/tests/hostside/java/com/android/microdroid/test/PvmfwDebugPolicyHostTests.java
index 18aa273..22131f1 100644
--- a/tests/hostside/java/com/android/microdroid/test/PvmfwDebugPolicyHostTests.java
+++ b/tests/hostside/java/com/android/microdroid/test/PvmfwDebugPolicyHostTests.java
@@ -112,7 +112,7 @@
getTestInformation().getDependencyFile(BCC_FILE_NAME, /* targetFirst= */ false);
// Check device capability
- testIfDeviceIsCapable(mAndroidDevice);
+ assumeDeviceIsCapable(mAndroidDevice);
assumeTrue(
"Protected VMs are not supported",
mAndroidDevice.supportsMicrodroid(/*protectedVm=*/ true));