Run device side tests also on microdroid GKI
.. except for the console test (as GKI has console=ttynull on its
cmdline). Also this updates host side tests as config files are moved.
Bug: 302465542
Test: atest MicrodroidTests
Change-Id: Ieba06066dc05fae7acef3b29b7de14d3b99f9e3e
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 7c85797..9c0fd72 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
@@ -52,7 +52,7 @@
public static final String FUSE_SUPER_MAGIC_HEX = "65735546";
/** VM config entry path in the test APK */
- private static final String VM_CONFIG_PATH_IN_APK = "assets/vm_config.json";
+ private static final String VM_CONFIG_PATH_IN_APK = "assets/microdroid/vm_config.json";
/** Test directory on Android where data are located */
public static final String TEST_DIR = "/data/local/tmp/authfs";
diff --git a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
index e31a55d..6314c25 100644
--- a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
+++ b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
@@ -119,7 +119,7 @@
public void setup() throws IOException {
grantPermission(VirtualMachine.MANAGE_VIRTUAL_MACHINE_PERMISSION);
grantPermission(VirtualMachine.USE_CUSTOM_VIRTUAL_MACHINE_PERMISSION);
- prepareTestSetup(mProtectedVm);
+ prepareTestSetup(mProtectedVm, null /* gki */);
setMaxPerformanceTaskProfile();
mInstrumentation = getInstrumentation();
}
diff --git a/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java b/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java
index 817bd85..c2244bc 100644
--- a/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java
+++ b/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java
@@ -48,7 +48,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.OptionalLong;
+import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -58,6 +62,9 @@
private static final String TAG = "MicrodroidDeviceTestBase";
private final String MAX_PERFORMANCE_TASK_PROFILE = "CPUSET_SP_TOP_APP";
+ protected static final Set<String> SUPPORTED_GKI_VERSIONS =
+ Collections.unmodifiableSet(new HashSet(Arrays.asList("android14-6.1")));
+
public static boolean isCuttlefish() {
return getDeviceProperties().isCuttlefish();
}
@@ -105,6 +112,7 @@
private Context mCtx;
private boolean mProtectedVm;
+ private String mOs;
protected Context getContext() {
return mCtx;
@@ -115,13 +123,17 @@
}
public VirtualMachineConfig.Builder newVmConfigBuilder() {
- return new VirtualMachineConfig.Builder(mCtx).setProtectedVm(mProtectedVm);
+ return new VirtualMachineConfig.Builder(mCtx).setProtectedVm(mProtectedVm).setOs(mOs);
}
protected final boolean isProtectedVm() {
return mProtectedVm;
}
+ protected final String os() {
+ return mOs;
+ }
+
/**
* Creates a new virtual machine, potentially removing an existing virtual machine with given
* name.
@@ -136,13 +148,14 @@
return vmm.create(name, config);
}
- public void prepareTestSetup(boolean protectedVm) {
+ public void prepareTestSetup(boolean protectedVm, String gki) {
mCtx = ApplicationProvider.getApplicationContext();
assume().withMessage("Device doesn't support AVF")
.that(mCtx.getPackageManager().hasSystemFeature(FEATURE_VIRTUALIZATION_FRAMEWORK))
.isTrue();
mProtectedVm = protectedVm;
+ mOs = gki != null ? "microdroid_gki-" + gki : "microdroid";
int capabilities = getVirtualMachineManager().getCapabilities();
if (protectedVm) {
@@ -154,6 +167,15 @@
.that(capabilities & VirtualMachineManager.CAPABILITY_NON_PROTECTED_VM)
.isNotEqualTo(0);
}
+
+ try {
+ assume().withMessage("Skip where requested OS \"" + mOs + "\" isn't supported")
+ .that(mOs)
+ .isIn(getVirtualMachineManager().getSupportedOSList());
+ } catch (VirtualMachineException e) {
+ Log.e(TAG, "Error getting supported OS list", e);
+ throw new RuntimeException("Failed to get supported OS list.", e);
+ }
}
public abstract static class VmEventListener implements VirtualMachineCallback {
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 be13196..848b43b 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
@@ -36,6 +36,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -55,7 +56,7 @@
/ MICRODROID_COMMAND_RETRY_INTERVAL_MILLIS);
protected static final Set<String> SUPPORTED_GKI_VERSIONS =
- new HashSet(Arrays.asList("android14-6.1"));
+ Collections.unmodifiableSet(new HashSet(Arrays.asList("android14-6.1")));
public static void prepareVirtualizationTestSetup(ITestDevice androidDevice)
throws DeviceNotAvailableException {
diff --git a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
index 2fa1190..21abdaa 100644
--- a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
+++ b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
@@ -90,7 +90,7 @@
private static final String SHELL_PACKAGE_NAME = "com.android.shell";
private static final String VIRT_APEX = "/apex/com.android.virt/";
- private static final int MIN_MEM_ARM64 = 145;
+ private static final int MIN_MEM_ARM64 = 160;
private static final int MIN_MEM_X86_64 = 196;
private static final int BOOT_COMPLETE_TIMEOUT = 30000; // 30 seconds
@@ -108,6 +108,7 @@
List<Object[]> ret = new ArrayList<>();
ret.add(new Object[] {true /* protectedVm */, null /* use microdroid kernel */});
ret.add(new Object[] {false /* protectedVm */, null /* use microdroid kernel */});
+ // TODO(b/302465542): run only the latest GKI on presubmit to reduce running time
for (String gki : SUPPORTED_GKI_VERSIONS) {
ret.add(new Object[] {true /* protectedVm */, gki});
ret.add(new Object[] {false /* protectedVm */, gki});
@@ -121,6 +122,8 @@
@Parameterized.Parameter(1)
public String mGki;
+ private String mOs;
+
@Rule public TestLogData mTestLogs = new TestLogData();
@Rule public TestName mTestName = new TestName();
@Rule public TestMetrics mMetrics = new TestMetrics();
@@ -149,7 +152,7 @@
throws Exception {
PayloadMetadata.write(
PayloadMetadata.metadata(
- "/mnt/apk/assets/vm_config.json",
+ "/mnt/apk/assets/" + mOs + "/vm_config.json",
PayloadMetadata.apk("microdroid-apk"),
apexes.stream()
.map(apex -> PayloadMetadata.apex(apex.name))
@@ -333,8 +336,7 @@
// - its idsig
// Load etc/microdroid.json
- String os = mGki != null ? "microdroid_gki-" + mGki : "microdroid";
- File microdroidConfigFile = new File(virtApexEtcDir, os + ".json");
+ File microdroidConfigFile = new File(virtApexEtcDir, mOs + ".json");
JSONObject config = new JSONObject(FileUtil.readStringFromFile(microdroidConfigFile));
// Replace paths so that the config uses re-signed images from TEST_ROOT
@@ -350,7 +352,7 @@
}
// Add partitions to the second disk
- final String initrdPath = TEST_ROOT + "etc/" + os + "_initrd_debuggable.img";
+ final String initrdPath = TEST_ROOT + "etc/" + mOs + "_initrd_debuggable.img";
config.put("initrd", initrdPath);
// Add instance image as a partition in disks[1]
disks.put(
@@ -409,7 +411,7 @@
public void protectedVmRunsPvmfw() throws Exception {
// Arrange
assumeProtectedVm();
- final String configPath = "assets/vm_config_apex.json";
+ final String configPath = "assets/" + mOs + "/vm_config_apex.json";
// Act
mMicrodroidDevice =
@@ -418,7 +420,6 @@
.memoryMib(minMemorySize())
.cpuTopology("match_host")
.protectedVm(true)
- .gki(mGki)
.build(getAndroidDevice());
// Assert
@@ -546,7 +547,6 @@
.memoryMib(minMemorySize())
.cpuTopology("match_host")
.protectedVm(protectedVm)
- .gki(mGki)
.build(getAndroidDevice());
mMicrodroidDevice.waitForBootComplete(BOOT_COMPLETE_TIMEOUT);
mMicrodroidDevice.enableAdbRoot();
@@ -567,7 +567,7 @@
assertThat(
isTombstoneGeneratedWithCmd(
mProtectedVm,
- "assets/vm_config.json",
+ "assets/" + mOs + "/vm_config.json",
"kill",
"-SIGSEGV",
"$(pidof microdroid_launcher)"))
@@ -581,7 +581,7 @@
assertThat(
isTombstoneGeneratedWithCmd(
mProtectedVm,
- "assets/vm_config_no_tombstone.json",
+ "assets/" + mOs + "/vm_config_no_tombstone.json",
"kill",
"-SIGSEGV",
"$(pidof microdroid_launcher)"))
@@ -595,7 +595,7 @@
assertThat(
isTombstoneGeneratedWithCmd(
mProtectedVm,
- "assets/vm_config.json",
+ "assets/" + mOs + "/vm_config.json",
"echo",
"c",
">",
@@ -659,7 +659,10 @@
private boolean isTombstoneGeneratedWithCrashConfig(boolean protectedVm, boolean debuggable)
throws Exception {
return isTombstoneGeneratedWithVmRunApp(
- protectedVm, debuggable, "--config-path", "assets/vm_config_crash.json");
+ protectedVm,
+ debuggable,
+ "--config-path",
+ "assets/" + mOs + "/vm_config_crash.json");
}
@Test
@@ -694,14 +697,13 @@
// Create VM with microdroid
TestDevice device = getAndroidDevice();
- final String configPath = "assets/vm_config_apex.json"; // path inside the APK
+ final String configPath = "assets/" + mOs + "/vm_config_apex.json"; // path inside the APK
ITestDevice microdroid =
MicrodroidBuilder.fromDevicePath(getPathForPackage(PACKAGE_NAME), configPath)
.debugLevel("full")
.memoryMib(minMemorySize())
.cpuTopology("match_host")
.protectedVm(mProtectedVm)
- .gki(mGki)
.build(device);
microdroid.waitForBootComplete(BOOT_COMPLETE_TIMEOUT);
device.shutdownMicrodroid(microdroid);
@@ -824,26 +826,24 @@
@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
+ final String configPath = "assets/" + mOs + "/vm_config.json"; // path inside the APK
testMicrodroidBootsWithBuilder(
MicrodroidBuilder.fromDevicePath(getPathForPackage(PACKAGE_NAME), configPath)
.debugLevel("full")
.memoryMib(minMemorySize())
.cpuTopology("match_host")
- .protectedVm(mProtectedVm)
- .gki(mGki));
+ .protectedVm(mProtectedVm));
}
@Test
public void testMicrodroidRamUsage() throws Exception {
- final String configPath = "assets/vm_config.json";
+ final String configPath = "assets/" + mOs + "/vm_config.json";
mMicrodroidDevice =
MicrodroidBuilder.fromDevicePath(getPathForPackage(PACKAGE_NAME), configPath)
.debugLevel("full")
.memoryMib(minMemorySize())
.cpuTopology("match_host")
.protectedVm(mProtectedVm)
- .gki(mGki)
.build(getAndroidDevice());
mMicrodroidDevice.waitForBootComplete(BOOT_COMPLETE_TIMEOUT);
mMicrodroidDevice.enableAdbRoot();
@@ -991,7 +991,7 @@
List<String> devices = getAssignableDevices();
assumeFalse("no assignable devices", devices.isEmpty());
- final String configPath = "assets/vm_config.json";
+ final String configPath = "assets/" + mOs + "/vm_config.json";
mMicrodroidDevice =
MicrodroidBuilder.fromDevicePath(getPathForPackage(PACKAGE_NAME), configPath)
.debugLevel("full")
@@ -999,7 +999,6 @@
.cpuTopology("match_host")
.protectedVm(true)
.addAssignableDevice(devices.get(0))
- .gki(mGki)
.build(getAndroidDevice());
mMicrodroidDevice.waitForBootComplete(BOOT_COMPLETE_TIMEOUT);
@@ -1034,6 +1033,8 @@
"GKI version \"" + mGki + "\" is not supported on this device",
getSupportedGKIVersions().contains(mGki));
}
+
+ mOs = (mGki != null) ? "microdroid_gki-" + mGki : "microdroid";
}
@After
diff --git a/tests/pvmfw/java/com/android/pvmfw/test/DebugPolicyHostTests.java b/tests/pvmfw/java/com/android/pvmfw/test/DebugPolicyHostTests.java
index 7d0faa4..b84d7dc 100644
--- a/tests/pvmfw/java/com/android/pvmfw/test/DebugPolicyHostTests.java
+++ b/tests/pvmfw/java/com/android/pvmfw/test/DebugPolicyHostTests.java
@@ -57,7 +57,10 @@
@NonNull private static final String PACKAGE_NAME = "com.android.microdroid.test";
@NonNull private static final String MICRODROID_DEBUG_FULL = "full";
@NonNull private static final String MICRODROID_DEBUG_NONE = "none";
- @NonNull private static final String MICRODROID_CONFIG_PATH = "assets/vm_config_apex.json";
+
+ @NonNull
+ private static final String MICRODROID_CONFIG_PATH = "assets/microdroid/vm_config_apex.json";
+
@NonNull private static final String MICRODROID_LOG_PATH = TEST_ROOT + "log.txt";
private static final int BOOT_COMPLETE_TIMEOUT_MS = 30000; // 30 seconds
private static final int BOOT_FAILURE_WAIT_TIME_MS = 10000; // 10 seconds
diff --git a/tests/pvmfw/java/com/android/pvmfw/test/PvmfwImgTest.java b/tests/pvmfw/java/com/android/pvmfw/test/PvmfwImgTest.java
index 95c1c4e..9fbbd87 100644
--- a/tests/pvmfw/java/com/android/pvmfw/test/PvmfwImgTest.java
+++ b/tests/pvmfw/java/com/android/pvmfw/test/PvmfwImgTest.java
@@ -53,7 +53,10 @@
@NonNull private static final String PACKAGE_FILE_NAME = "MicrodroidTestApp.apk";
@NonNull private static final String PACKAGE_NAME = "com.android.microdroid.test";
@NonNull private static final String MICRODROID_DEBUG_FULL = "full";
- @NonNull private static final String MICRODROID_CONFIG_PATH = "assets/vm_config_apex.json";
+
+ @NonNull
+ private static final String MICRODROID_CONFIG_PATH = "assets/microdroid/vm_config_apex.json";
+
private static final int BOOT_COMPLETE_TIMEOUT_MS = 30000; // 30 seconds
private static final int BOOT_FAILURE_WAIT_TIME_MS = 10000; // 10 seconds
diff --git a/tests/testapk/assets/vm_config.json b/tests/testapk/assets/microdroid/vm_config.json
similarity index 100%
rename from tests/testapk/assets/vm_config.json
rename to tests/testapk/assets/microdroid/vm_config.json
diff --git a/tests/testapk/assets/vm_config_apex.json b/tests/testapk/assets/microdroid/vm_config_apex.json
similarity index 100%
rename from tests/testapk/assets/vm_config_apex.json
rename to tests/testapk/assets/microdroid/vm_config_apex.json
diff --git a/tests/testapk/assets/vm_config_crash.json b/tests/testapk/assets/microdroid/vm_config_crash.json
similarity index 100%
rename from tests/testapk/assets/vm_config_crash.json
rename to tests/testapk/assets/microdroid/vm_config_crash.json
diff --git a/tests/testapk/assets/vm_config_extra_apk.json b/tests/testapk/assets/microdroid/vm_config_extra_apk.json
similarity index 100%
rename from tests/testapk/assets/vm_config_extra_apk.json
rename to tests/testapk/assets/microdroid/vm_config_extra_apk.json
diff --git a/tests/testapk/assets/vm_config_no_task.json b/tests/testapk/assets/microdroid/vm_config_no_task.json
similarity index 100%
rename from tests/testapk/assets/vm_config_no_task.json
rename to tests/testapk/assets/microdroid/vm_config_no_task.json
diff --git a/tests/testapk/assets/vm_config_no_tombstone.json b/tests/testapk/assets/microdroid/vm_config_no_tombstone.json
similarity index 100%
rename from tests/testapk/assets/vm_config_no_tombstone.json
rename to tests/testapk/assets/microdroid/vm_config_no_tombstone.json
diff --git a/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config.json b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config.json
new file mode 100644
index 0000000..2022127
--- /dev/null
+++ b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config.json
@@ -0,0 +1,10 @@
+{
+ "os": {
+ "name": "microdroid_gki-android14-6.1"
+ },
+ "task": {
+ "type": "microdroid_launcher",
+ "command": "MicrodroidTestNativeLib.so"
+ },
+ "export_tombstones": true
+}
diff --git a/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_apex.json b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_apex.json
new file mode 100644
index 0000000..bd3998d
--- /dev/null
+++ b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_apex.json
@@ -0,0 +1,21 @@
+{
+ "os": {
+ "name": "microdroid_gki-android14-6.1"
+ },
+ "task": {
+ "type": "microdroid_launcher",
+ "command": "MicrodroidTestNativeLib.so"
+ },
+ "apexes": [
+ {
+ "name": "com.android.art"
+ },
+ {
+ "name": "com.android.compos"
+ },
+ {
+ "name": "com.android.sdkext"
+ }
+ ],
+ "export_tombstones": true
+}
diff --git a/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_crash.json b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_crash.json
new file mode 100644
index 0000000..4692258
--- /dev/null
+++ b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_crash.json
@@ -0,0 +1,9 @@
+{
+ "os": {
+ "name": "microdroid_gki-android14-6.1"
+ },
+ "task": {
+ "type": "microdroid_launcher",
+ "command": "MicrodroidCrashNativeLib.so"
+ }
+}
diff --git a/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_extra_apk.json b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_extra_apk.json
new file mode 100644
index 0000000..1602294
--- /dev/null
+++ b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_extra_apk.json
@@ -0,0 +1,15 @@
+{
+ "os": {
+ "name": "microdroid_gki-android14-6.1"
+ },
+ "task": {
+ "type": "microdroid_launcher",
+ "command": "MicrodroidTestNativeLib.so"
+ },
+ "extra_apks": [
+ {
+ "path": "/system/etc/security/fsverity/BuildManifest.apk"
+ }
+ ],
+ "export_tombstones": true
+}
diff --git a/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_no_task.json b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_no_task.json
new file mode 100644
index 0000000..8282f99
--- /dev/null
+++ b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_no_task.json
@@ -0,0 +1,6 @@
+{
+ "os": {
+ "name": "microdroid_gki-android14-6.1"
+ },
+ "export_tombstones": true
+}
diff --git a/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_no_tombstone.json b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_no_tombstone.json
new file mode 100644
index 0000000..6e8a136
--- /dev/null
+++ b/tests/testapk/assets/microdroid_gki-android14-6.1/vm_config_no_tombstone.json
@@ -0,0 +1,10 @@
+{
+ "os": {
+ "name": "microdroid_gki-android14-6.1"
+ },
+ "task": {
+ "type": "microdroid_launcher",
+ "command": "MicrodroidTestNativeLib.so"
+ },
+ "export_tombstones": false
+}
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 c90fb5c..6605f89 100644
--- a/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
+++ b/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
@@ -31,8 +31,8 @@
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
@@ -96,7 +96,9 @@
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.OptionalLong;
import java.util.UUID;
@@ -118,17 +120,29 @@
private static final String KERNEL_VERSION = SystemProperties.get("ro.kernel.version");
- @Parameterized.Parameters(name = "protectedVm={0}")
- public static Object[] protectedVmConfigs() {
- return new Object[] { false, true };
+ @Parameterized.Parameters(name = "protectedVm={0},gki={1}")
+ public static Collection<Object[]> params() {
+ List<Object[]> ret = new ArrayList<>();
+ ret.add(new Object[] {true /* protectedVm */, null /* use microdroid kernel */});
+ ret.add(new Object[] {false /* protectedVm */, null /* use microdroid kernel */});
+ // TODO(b/302465542): run only the latest GKI on presubmit to reduce running time
+ for (String gki : SUPPORTED_GKI_VERSIONS) {
+ ret.add(new Object[] {true /* protectedVm */, gki});
+ ret.add(new Object[] {false /* protectedVm */, gki});
+ }
+ return ret;
}
- @Parameterized.Parameter public boolean mProtectedVm;
+ @Parameterized.Parameter(0)
+ public boolean mProtectedVm;
+
+ @Parameterized.Parameter(1)
+ public String mGki;
@Before
public void setup() {
grantPermission(VirtualMachine.MANAGE_VIRTUAL_MACHINE_PERMISSION);
- prepareTestSetup(mProtectedVm);
+ prepareTestSetup(mProtectedVm, mGki);
// USE_CUSTOM_VIRTUAL_MACHINE permission has protection level signature|development, meaning
// that it will be automatically granted when test apk is installed. We have some tests
// checking the behavior when caller doesn't have this permission (e.g.
@@ -146,7 +160,7 @@
private static final long ONE_MEBI = 1024 * 1024;
- private static final long MIN_MEM_ARM64 = 150 * ONE_MEBI;
+ private static final long MIN_MEM_ARM64 = 160 * ONE_MEBI;
private static final long MIN_MEM_X86_64 = 196 * ONE_MEBI;
private static final String EXAMPLE_STRING = "Literally any string!! :)";
@@ -473,8 +487,11 @@
@CddTest(requirements = {"9.17/C-1-1"})
public void vmConfigGetAndSetTests() {
// Minimal has as little as specified as possible; everything that can be is defaulted.
- VirtualMachineConfig.Builder minimalBuilder = newVmConfigBuilder();
- VirtualMachineConfig minimal = minimalBuilder.setPayloadBinaryName("binary.so").build();
+ VirtualMachineConfig.Builder minimalBuilder =
+ new VirtualMachineConfig.Builder(getContext())
+ .setPayloadBinaryName("binary.so")
+ .setProtectedVm(isProtectedVm());
+ VirtualMachineConfig minimal = minimalBuilder.build();
assertThat(minimal.getApkPath()).isNull();
assertThat(minimal.getDebugLevel()).isEqualTo(DEBUG_LEVEL_NONE);
@@ -518,11 +535,7 @@
assertThat(minimal.isCompatibleWith(minimal)).isTrue();
assertThat(maximal.isCompatibleWith(maximal)).isTrue();
- VirtualMachineConfig os =
- newVmConfigBuilder()
- .setPayloadBinaryName("binary.so")
- .setOs("microdroid_gki-android14-6.1")
- .build();
+ VirtualMachineConfig os = minimalBuilder.setOs("microdroid_gki-android14-6.1").build();
assertThat(os.getPayloadBinaryName()).isEqualTo("binary.so");
assertThat(os.getOs()).isEqualTo("microdroid_gki-android14-6.1");
assertThat(os.isCompatibleWith(minimal)).isFalse();
@@ -788,7 +801,7 @@
VirtualMachineConfig config =
newVmConfigBuilder()
- .setPayloadConfigPath("assets/vm_config.json")
+ .setPayloadConfigPath("assets/" + os() + "/vm_config.json")
.setMemoryBytes(minMemoryRequired())
.build();
@@ -910,7 +923,7 @@
grantPermission(VirtualMachine.USE_CUSTOM_VIRTUAL_MACHINE_PERMISSION);
VirtualMachineConfig config =
newVmConfigBuilder()
- .setPayloadConfigPath("assets/vm_config_extra_apk.json")
+ .setPayloadConfigPath("assets/" + os() + "/vm_config_extra_apk.json")
.setMemoryBytes(minMemoryRequired())
.setDebugLevel(DEBUG_LEVEL_FULL)
.build();
@@ -1055,7 +1068,7 @@
grantPermission(VirtualMachine.USE_CUSTOM_VIRTUAL_MACHINE_PERMISSION);
VirtualMachineConfig normalConfig =
newVmConfigBuilder()
- .setPayloadConfigPath("assets/vm_config.json")
+ .setPayloadConfigPath("assets/" + os() + "/vm_config.json")
.setDebugLevel(DEBUG_LEVEL_FULL)
.build();
forceCreateNewVirtualMachine("test_vm_a", normalConfig);
@@ -1082,7 +1095,7 @@
grantPermission(VirtualMachine.USE_CUSTOM_VIRTUAL_MACHINE_PERMISSION);
VirtualMachineConfig normalConfig =
newVmConfigBuilder()
- .setPayloadConfigPath("assets/vm_config.json")
+ .setPayloadConfigPath("assets/" + os() + "/vm_config.json")
.setDebugLevel(DEBUG_LEVEL_FULL)
.build();
forceCreateNewVirtualMachine("test_vm", normalConfig);
@@ -1106,7 +1119,7 @@
grantPermission(VirtualMachine.USE_CUSTOM_VIRTUAL_MACHINE_PERMISSION);
VirtualMachineConfig normalConfig =
newVmConfigBuilder()
- .setPayloadConfigPath("assets/vm_config.json")
+ .setPayloadConfigPath("assets/" + os() + "/vm_config.json")
.setDebugLevel(DEBUG_LEVEL_FULL)
.build();
VirtualMachine vm = forceCreateNewVirtualMachine("bcc_vm", normalConfig);
@@ -1265,7 +1278,7 @@
grantPermission(VirtualMachine.USE_CUSTOM_VIRTUAL_MACHINE_PERMISSION);
VirtualMachineConfig normalConfig =
newVmConfigBuilder()
- .setPayloadConfigPath("assets/vm_config_no_task.json")
+ .setPayloadConfigPath("assets/" + os() + "/vm_config_no_task.json")
.setDebugLevel(DEBUG_LEVEL_FULL)
.build();
forceCreateNewVirtualMachine("test_vm_invalid_config", normalConfig);
@@ -1285,8 +1298,8 @@
BootResult bootResult = tryBootVm(TAG, "test_vm_invalid_binary_path");
assertThat(bootResult.payloadStarted).isFalse();
- assertThat(bootResult.deathReason).isEqualTo(
- VirtualMachineCallback.STOP_REASON_MICRODROID_UNKNOWN_RUNTIME_ERROR);
+ assertThat(bootResult.deathReason)
+ .isEqualTo(VirtualMachineCallback.STOP_REASON_MICRODROID_UNKNOWN_RUNTIME_ERROR);
}
// Checks whether microdroid_launcher started but payload failed. reason must be recorded in the
@@ -1362,7 +1375,7 @@
grantPermission(VirtualMachine.USE_CUSTOM_VIRTUAL_MACHINE_PERMISSION);
VirtualMachineConfig config =
newVmConfigBuilder()
- .setPayloadConfigPath("assets/vm_config.json")
+ .setPayloadConfigPath("assets/" + os() + "/vm_config.json")
.setDebugLevel(DEBUG_LEVEL_FULL)
.build();
String vmNameOrig = "test_vm_orig";
@@ -1760,6 +1773,7 @@
@Test
public void testConsoleInputSupported() throws Exception {
assumeSupportedDevice();
+ assumeTrue("Not supported on GKI kernels", mGki == null);
VirtualMachineConfig config =
newVmConfigBuilder()