Add a test for the debug mode
Bug: 185211964
Test: atest MicrodroidHostTestCases
Change-Id: I5eca4f761497ce970ef8de914e3d25d9c4a4c4b0
diff --git a/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java b/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
index 5821309..851aa30 100644
--- a/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
+++ b/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
@@ -143,8 +143,8 @@
return (new CompatibilityBuildHelper(getBuild())).getTestFile(name);
}
- public String startMicrodroid(String apkName, String packageName, String configPath)
- throws Exception {
+ public String startMicrodroid(
+ String apkName, String packageName, String configPath, boolean debug) throws Exception {
// Install APK
File apkFile = findTestFile(apkName);
getDevice().installPackage(apkFile, /* reinstall */ true);
@@ -162,6 +162,7 @@
getDevice().pushFile(idsigOnHost, apkIdsigPath);
final String logPath = TEST_ROOT + "log.txt";
+ final String debugFlag = debug ? "--debug " : "";
// Run the VM
runOnAndroid("start", "virtualizationservice");
@@ -171,6 +172,7 @@
"run-app",
"--daemonize",
"--log " + logPath,
+ debugFlag,
apkPath,
apkIdsigPath,
configPath);
diff --git a/tests/hostside/java/android/virt/test/MicrodroidTestCase.java b/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
index 0b82d43..0774503 100644
--- a/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
+++ b/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
@@ -36,7 +36,7 @@
@Test
public void testMicrodroidBoots() throws Exception {
final String configPath = "assets/vm_config.json"; // path inside the APK
- final String cid = startMicrodroid(APK_NAME, PACKAGE_NAME, configPath);
+ final String cid = startMicrodroid(APK_NAME, PACKAGE_NAME, configPath, /* debug */ false);
adbConnectToMicrodroid(cid, MICRODROID_ADB_CONNECT_TIMEOUT_MINUTES);
// Test writing to /data partition
@@ -77,6 +77,18 @@
shutdownMicrodroid(cid);
}
+ @Test
+ public void testDebugMode() throws Exception {
+ final String configPath = "assets/vm_config.json"; // path inside the APK
+ final boolean debug = true;
+ final String cid = startMicrodroid(APK_NAME, PACKAGE_NAME, configPath, debug);
+ adbConnectToMicrodroid(cid, MICRODROID_ADB_CONNECT_TIMEOUT_MINUTES);
+
+ assertThat(runOnMicrodroid("getenforce"), is("Permissive"));
+
+ shutdownMicrodroid(cid);
+ }
+
@Before
public void setUp() throws Exception {
testIfDeviceIsCapable();