Merge "[API] Add vm_payload API to get APK contents path"
diff --git a/authfs/tests/benchmarks/src/java/com/android/fs/benchmarks/AuthFsBenchmarks.java b/authfs/tests/benchmarks/src/java/com/android/fs/benchmarks/AuthFsBenchmarks.java
index 5e9073a..641b566 100644
--- a/authfs/tests/benchmarks/src/java/com/android/fs/benchmarks/AuthFsBenchmarks.java
+++ b/authfs/tests/benchmarks/src/java/com/android/fs/benchmarks/AuthFsBenchmarks.java
@@ -20,6 +20,8 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assume.assumeTrue;
+
import android.platform.test.annotations.RootPermissionTest;
import com.android.fs.common.AuthFsTestRule;
@@ -71,11 +73,13 @@
@Before
public void setUp() throws Exception {
+ assumeTrue(AuthFsTestRule.getDevice().supportsMicrodroid(/*protectedVm=*/ true));
String metricsPrefix =
MetricsProcessor.getMetricPrefix(
getDevice().getProperty("debug.hypervisor.metrics_tag"));
mMetricsProcessor = new MetricsProcessor(metricsPrefix + "authfs/");
- AuthFsTestRule.startMicrodroid();
+ // TODO(b/236123069): Run benchmark tests in both protected and unprotected VMs.
+ AuthFsTestRule.startMicrodroid(/*protectedVm=*/ true);
}
@After
diff --git a/authfs/tests/common/src/java/com/android/fs/common/AuthFsTestRule.java b/authfs/tests/common/src/java/com/android/fs/common/AuthFsTestRule.java
index 994f23b..2220169 100644
--- a/authfs/tests/common/src/java/com/android/fs/common/AuthFsTestRule.java
+++ b/authfs/tests/common/src/java/com/android/fs/common/AuthFsTestRule.java
@@ -24,7 +24,6 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.util.PollingCheck;
@@ -131,7 +130,7 @@
return sMicrodroidDevice;
}
- public static void startMicrodroid() throws DeviceNotAvailableException {
+ public static void startMicrodroid(boolean protectedVm) throws DeviceNotAvailableException {
CLog.i("Starting the shared VM");
assertThat(sMicrodroidDevice).isNull();
sMicrodroidDevice =
@@ -139,6 +138,7 @@
findTestFile(sTestInfo.getBuildInfo(), TEST_APK_NAME),
VM_CONFIG_PATH_IN_APK)
.debugLevel("full")
+ .protectedVm(protectedVm)
.build(getDevice());
// From this point on, we need to tear down the Microdroid instance
@@ -152,10 +152,11 @@
}
public static void shutdownMicrodroid() throws DeviceNotAvailableException {
- assertNotNull(sMicrodroidDevice);
- getDevice().shutdownMicrodroid(sMicrodroidDevice);
- sMicrodroidDevice = null;
- sMicrodroid = null;
+ if (sMicrodroidDevice != null) {
+ getDevice().shutdownMicrodroid(sMicrodroidDevice);
+ sMicrodroidDevice = null;
+ sMicrodroid = null;
+ }
}
@Override
@@ -224,7 +225,7 @@
}
}
- private static TestDevice getDevice() {
+ public static TestDevice getDevice() {
return (TestDevice) sTestInfo.getDevice();
}
@@ -245,7 +246,6 @@
}
private void setUpTest() throws Exception {
- assumeTrue(getDevice().supportsMicrodroid());
sAndroid.run("mkdir -p " + TEST_OUTPUT_DIR);
}
diff --git a/authfs/tests/hosttests/java/src/com/android/fs/AuthFsHostTest.java b/authfs/tests/hosttests/java/src/com/android/fs/AuthFsHostTest.java
index 3157dfd..967d104 100644
--- a/authfs/tests/hosttests/java/src/com/android/fs/AuthFsHostTest.java
+++ b/authfs/tests/hosttests/java/src/com/android/fs/AuthFsHostTest.java
@@ -21,6 +21,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeTrue;
import android.platform.test.annotations.RootPermissionTest;
@@ -74,7 +75,8 @@
@BeforeClassWithInfo
public static void beforeClassWithDevice(TestInformation testInfo) throws Exception {
AuthFsTestRule.setUpAndroid(testInfo);
- AuthFsTestRule.startMicrodroid();
+ assumeTrue(AuthFsTestRule.getDevice().supportsMicrodroid(/*protectedVm=*/ true));
+ AuthFsTestRule.startMicrodroid(/*protectedVm=*/ true);
sAndroid = AuthFsTestRule.getAndroid();
sMicrodroid = AuthFsTestRule.getMicrodroid();
}
diff --git a/tests/benchmark/Android.bp b/tests/benchmark/Android.bp
index 88e4d41..2ba3881 100644
--- a/tests/benchmark/Android.bp
+++ b/tests/benchmark/Android.bp
@@ -45,7 +45,6 @@
"com.android.microdroid.testservice-ndk",
"libbase",
"libbinder_ndk",
- "libbinder_rpc_unstable",
"liblog",
"libvm_payload",
],
diff --git a/tests/benchmark/src/native/benchmarkbinary.cpp b/tests/benchmark/src/native/benchmarkbinary.cpp
index c394756..24712b1 100644
--- a/tests/benchmark/src/native/benchmarkbinary.cpp
+++ b/tests/benchmark/src/native/benchmarkbinary.cpp
@@ -29,7 +29,6 @@
#include <vm_main.h>
#include <vm_payload.h>
-#include <binder_rpc_unstable.hpp>
#include <fstream>
#include <random>
#include <string>
@@ -164,9 +163,8 @@
abort();
}
};
-
- if (!RunVsockRpcServerCallback(test_service->asBinder().get(), test_service->SERVICE_PORT,
- callback, nullptr)) {
+ if (!AVmPayload_runVsockRpcServer(test_service->asBinder().get(), test_service->SERVICE_PORT,
+ callback, nullptr)) {
return Error() << "RPC Server failed to run";
}
return {};
diff --git a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
index c9df624..33788ed 100644
--- a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
+++ b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
@@ -485,7 +485,7 @@
}
@Test
- public void testTelemetryPushedAtoms() throws Exception {
+ public void testTelemetryPushedAtomsOfEventMetrics() throws Exception {
// Reset statsd config and report before the test
ConfigUtils.removeConfig(getDevice());
ReportUtils.clearReports(getDevice());
@@ -566,6 +566,49 @@
}
@Test
+ public void testTelemetryPushedAtomsOfValueMetrics() throws Exception {
+ // Reset statsd config and report before the test
+ ConfigUtils.removeConfig(getDevice());
+ ReportUtils.clearReports(getDevice());
+
+ // Setup statsd config
+ int[] atomIds = {
+ AtomsProto.Atom.VM_CPU_STATUS_REPORTED_FIELD_NUMBER,
+ AtomsProto.Atom.VM_MEM_STATUS_REPORTED_FIELD_NUMBER,
+ };
+ ConfigUtils.uploadConfigForPushedAtoms(getDevice(), PACKAGE_NAME, atomIds);
+
+ // Create VM with microdroid
+ final String configPath = "assets/vm_config_apex.json"; // path inside the APK
+ final String cid =
+ startMicrodroid(
+ getDevice(),
+ getBuild(),
+ APK_NAME,
+ PACKAGE_NAME,
+ configPath,
+ /* debug */ true,
+ minMemorySize(),
+ Optional.of(NUM_VCPUS));
+
+ // Boot VM with microdroid
+ adbConnectToMicrodroid(getDevice(), cid);
+ waitForBootComplete();
+
+ // Check VmCpuStatusReported and VmMemStatusReported atoms and clear the statsd report
+ List<StatsLog.EventMetricData> data;
+ data = ReportUtils.getEventMetricDataList(getDevice());
+ assertThat(data.size() >= 2).isTrue();
+ assertThat(data.get(0).getAtom().getPushedCase().getNumber())
+ .isEqualTo(AtomsProto.Atom.VM_CPU_STATUS_REPORTED_FIELD_NUMBER);
+ assertThat(data.get(1).getAtom().getPushedCase().getNumber())
+ .isEqualTo(AtomsProto.Atom.VM_MEM_STATUS_REPORTED_FIELD_NUMBER);
+
+ // Shutdown VM with microdroid
+ shutdownMicrodroid(getDevice(), cid);
+ }
+
+ @Test
@CddTest(requirements = {"9.17/C-1-1", "9.17/C-1-2", "9.17/C/1-3"})
public void testMicrodroidBoots() throws Exception {
final String configPath = "assets/vm_config.json"; // path inside the APK