Move isCuttlefish() to helper classes
We skip some tests when running on Cuttlefish, typically because nested
virtualization is too slow and the tests time out, but logic has been
duplicated across multiple test files. Clean things up by adding a new
common host/device helper VirtualizationTestHelper and make both the
MicrodroidHostTestCaseBase and MicrodroidDeviceTestBase share the same
logic.
Test: m MicrodroidTestApp ComposBenchmarkApp MicrodroidHostTestCases
Change-Id: Ibb9d25fc40818ffeb971d366dea409f8ee55ef48
diff --git a/tests/hostside/helper/Android.bp b/tests/hostside/helper/Android.bp
index f7caca2..af88bb6 100644
--- a/tests/hostside/helper/Android.bp
+++ b/tests/hostside/helper/Android.bp
@@ -10,4 +10,7 @@
"tradefed",
"truth-prebuilt",
],
+ static_libs: [
+ "VirtualizationTestHelper",
+ ],
}
diff --git a/tests/hostside/helper/java/com/android/microdroid/test/MicrodroidHostTestCaseBase.java b/tests/hostside/helper/java/com/android/microdroid/test/MicrodroidHostTestCaseBase.java
index 635d54e..0712323 100644
--- a/tests/hostside/helper/java/com/android/microdroid/test/MicrodroidHostTestCaseBase.java
+++ b/tests/hostside/helper/java/com/android/microdroid/test/MicrodroidHostTestCaseBase.java
@@ -34,6 +34,7 @@
import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
import com.android.tradefed.util.CommandResult;
import com.android.tradefed.util.RunUtil;
+import com.android.virt.VirtualizationTestHelper;
import java.io.File;
import java.io.FileNotFoundException;
@@ -91,6 +92,10 @@
android.tryRun("rm", "-rf", "/data/misc/virtualizationservice/*");
}
+ protected boolean isCuttlefish() throws Exception {
+ return VirtualizationTestHelper.isCuttlefish(getDevice().getProperty("ro.product.name"));
+ }
+
public static void testIfDeviceIsCapable(ITestDevice androidDevice) throws Exception {
assumeTrue("Need an actual TestDevice", androidDevice instanceof TestDevice);
TestDevice testDevice = (TestDevice) androidDevice;
diff --git a/tests/hostside/java/com/android/microdroid/test/MicrodroidTestCase.java b/tests/hostside/java/com/android/microdroid/test/MicrodroidTestCase.java
index f3062c6..78fb53b 100644
--- a/tests/hostside/java/com/android/microdroid/test/MicrodroidTestCase.java
+++ b/tests/hostside/java/com/android/microdroid/test/MicrodroidTestCase.java
@@ -77,16 +77,6 @@
@Rule public TestLogData mTestLogs = new TestLogData();
@Rule public TestName mTestName = new TestName();
- // TODO(b/176805428): remove this
- private boolean isCuttlefish() throws Exception {
- String productName = getDevice().getProperty("ro.product.name");
- return (null != productName)
- && (productName.startsWith("aosp_cf_x86")
- || productName.startsWith("aosp_cf_arm")
- || productName.startsWith("cf_x86")
- || productName.startsWith("cf_arm"));
- }
-
private int minMemorySize() throws DeviceNotAvailableException {
CommandRunner android = new CommandRunner(getDevice());
String abi = android.run("getprop", "ro.product.cpu.abi");