Merge "pvmfw: debug policy application failure is recoverable"
diff --git a/authfs/tests/benchmarks/Android.bp b/authfs/tests/benchmarks/Android.bp
index 38ece79..b30ecdd 100644
--- a/authfs/tests/benchmarks/Android.bp
+++ b/authfs/tests/benchmarks/Android.bp
@@ -24,6 +24,7 @@
":CtsApkVerityTestPrebuiltFiles",
":MicrodroidTestApp",
],
+ required: ["MicrodroidTestPreparer"],
}
cc_binary {
diff --git a/compos/benchmark/Android.bp b/compos/benchmark/Android.bp
index 12b3ae8..dc0c01c 100644
--- a/compos/benchmark/Android.bp
+++ b/compos/benchmark/Android.bp
@@ -18,4 +18,6 @@
sdk_version: "test_current",
use_embedded_native_libs: true,
compile_multilib: "64",
+
+ host_required: ["MicrodroidTestPreparer"],
}
diff --git a/tests/benchmark/Android.bp b/tests/benchmark/Android.bp
index dac4993..9c512bf 100644
--- a/tests/benchmark/Android.bp
+++ b/tests/benchmark/Android.bp
@@ -26,6 +26,7 @@
sdk_version: "test_current",
use_embedded_native_libs: true,
compile_multilib: "64",
+ host_required: ["MicrodroidTestPreparer"],
}
cc_library_shared {
diff --git a/tests/hostside/Android.bp b/tests/hostside/Android.bp
index 248755f..c71a8ec 100644
--- a/tests/hostside/Android.bp
+++ b/tests/hostside/Android.bp
@@ -75,4 +75,5 @@
"libsparse",
"libz",
],
+ required: ["MicrodroidTestPreparer"],
}
diff --git a/tests/testapk/AndroidTest.xml b/tests/testapk/AndroidTest.xml
index 725a1e4..929dd31 100644
--- a/tests/testapk/AndroidTest.xml
+++ b/tests/testapk/AndroidTest.xml
@@ -23,7 +23,6 @@
<option name="test-file-name" value="MicrodroidTestApp.apk" />
<option name="test-file-name" value="MicrodroidVmShareApp.apk" />
</target_preparer>
- <target_preparer class="com.android.microdroid.test.preparer.DisableMicrodroidDebugPolicyPreparer" />
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="com.android.microdroid.test" />
<option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
diff --git a/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java b/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
index 13738e5..38bc485 100644
--- a/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
+++ b/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
@@ -28,13 +28,15 @@
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.TruthJUnit.assume;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
-import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import com.google.common.base.Strings;
import com.google.common.truth.BooleanSubject;
+import android.app.Instrumentation;
+import android.app.UiAutomation;
import android.content.ComponentName;
import android.content.Context;
import android.content.ContextWrapper;
@@ -54,7 +56,8 @@
import android.system.virtualmachine.VirtualMachineDescriptor;
import android.system.virtualmachine.VirtualMachineException;
import android.system.virtualmachine.VirtualMachineManager;
-import android.util.Log;
+
+import androidx.test.platform.app.InstrumentationRegistry;
import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.VsrTest;
@@ -1620,11 +1623,29 @@
assertThat(checkVmOutputIsRedirectedToLogcat(true)).isTrue();
}
+ private boolean setSystemProperties(String name, String value) {
+ Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
+ UiAutomation uiAutomation = instrumentation.getUiAutomation();
+ String cmd = "setprop " + name + " " + (value.isEmpty() ? "\"\"" : value);
+ return runInShellWithStderr(TAG, uiAutomation, cmd).trim().isEmpty();
+ }
+
@Test
public void outputIsNotRedirectedToLogcatIfNotDebuggable() throws Exception {
assumeSupportedDevice();
- assertThat(checkVmOutputIsRedirectedToLogcat(false)).isFalse();
+ // Disable debug policy to ensure no log output.
+ String sysprop = "hypervisor.virtualizationmanager.debug_policy.path";
+ String old = SystemProperties.get(sysprop);
+ assumeTrue(
+ "Can't disable debug policy. Perhapse user build?",
+ setSystemProperties(sysprop, ""));
+
+ try {
+ assertThat(checkVmOutputIsRedirectedToLogcat(false)).isFalse();
+ } finally {
+ assertThat(setSystemProperties(sysprop, old)).isTrue();
+ }
}
@Test