Revert "vm tool: rename --gki arg to more generic --os one"
Revert submission 3323102
Reason for revert: DroidMonitor: Potential culprit for http://b/376483022 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.
Reverted changes: /q/submissionid:3323102
Change-Id: Id2923b891929dd695821da09a116a95d16ef8372
diff --git a/android/vm/src/main.rs b/android/vm/src/main.rs
index 110e0ca..81ca8fa 100644
--- a/android/vm/src/main.rs
+++ b/android/vm/src/main.rs
@@ -155,10 +155,10 @@
#[arg(long)]
devices: Vec<PathBuf>,
- /// Version of OS to use. If not set, defaults to microdroid.
- /// You can list all available OSes via `vm info` command.
+ /// Version of GKI to use. If set, use instead of microdroid kernel
+ #[cfg(vendor_modules)]
#[arg(long)]
- os: Option<String>,
+ gki: Option<String>,
}
impl MicrodroidConfig {
@@ -172,6 +172,16 @@
}
}
+ fn gki(&self) -> Option<&str> {
+ cfg_if::cfg_if! {
+ if #[cfg(vendor_modules)] {
+ self.gki.as_deref()
+ } else {
+ None
+ }
+ }
+ }
+
fn devices(&self) -> &[PathBuf] {
cfg_if::cfg_if! {
if #[cfg(device_assignment)] {
diff --git a/android/vm/src/run.rs b/android/vm/src/run.rs
index b07a472..0e1f4cc 100644
--- a/android/vm/src/run.rs
+++ b/android/vm/src/run.rs
@@ -140,7 +140,11 @@
bail!("Either --config-path or --payload-binary-name must be defined")
};
- let os_name = if let Some(ref os) = config.microdroid.os { os } else { "microdroid" };
+ let os_name = if let Some(ver) = config.microdroid.gki() {
+ format!("microdroid_gki-{ver}")
+ } else {
+ "microdroid".to_owned()
+ };
let payload_config_str = format!("{:?}!{:?}", config.apk, payload);
@@ -188,7 +192,7 @@
memoryMib: config.common.mem.unwrap_or(0) as i32, // 0 means use the VM default
cpuTopology: config.common.cpu_topology,
customConfig: Some(custom_config),
- osName: os_name.to_string(),
+ osName: os_name,
hugePages: config.common.hugepages,
boostUclamp: config.common.boost_uclamp,
});
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 811d8db..c5e0171 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
@@ -40,8 +40,11 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
-import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
public abstract class MicrodroidHostTestCaseBase extends BaseHostJUnit4Test {
protected static final String TEST_ROOT = "/data/local/tmp/virt/";
@@ -67,13 +70,8 @@
* 1000
/ MICRODROID_COMMAND_RETRY_INTERVAL_MILLIS);
- // We use a map here because the parameterizer `DeviceParameterizedRunner` doesn't support "-"
- // in test names.
- // The key of the map is the name of the parameter while the value is the actual OS variant.
- protected static final Map<String, String> SUPPORTED_OSES =
- Map.ofEntries(
- Map.entry("microdroid", "microdroid"),
- Map.entry("android15_66", "microdroid_gki-android15-6.6"));
+ protected static final Set<String> SUPPORTED_GKI_VERSIONS =
+ Collections.unmodifiableSet(new HashSet(Arrays.asList("android15-6.6")));
/* Keep this sync with AssignableDevice.aidl */
public static final class AssignableDevice {
@@ -263,6 +261,13 @@
return parseStringArrayFieldsFromVmInfo("Available OS list: ");
}
+ public List<String> getSupportedGKIVersions() throws Exception {
+ return getSupportedOSList().stream()
+ .filter(os -> os.startsWith("microdroid_gki-"))
+ .map(os -> os.replaceFirst("^microdroid_gki-", ""))
+ .collect(Collectors.toList());
+ }
+
protected boolean isPkvmHypervisor() throws DeviceNotAvailableException {
return "kvm.arm-protected".equals(getDevice().getProperty("ro.boot.hypervisor.version"));
}
diff --git a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
index 0f77f7a..ee2da09 100644
--- a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
+++ b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
@@ -78,6 +78,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -111,18 +112,36 @@
}
}
+ // This map is needed because the parameterizer `DeviceParameterizedRunner` doesn't support "-"
+ // in test names. The key is the test name, while the value is the actual kernel version.
+ private static HashMap<String, String> sGkiVersions = new HashMap<>();
+
+ private static void initGkiVersions() {
+ if (!sGkiVersions.isEmpty()) {
+ return;
+ }
+ sGkiVersions.put("null", null); /* use microdroid kernel */
+ // TODO(b/302465542): run only the latest GKI on presubmit to reduce running time
+ for (String gki : SUPPORTED_GKI_VERSIONS) {
+ String key = gki.split("-")[0];
+ assertThat(sGkiVersions.containsKey(key)).isFalse();
+ sGkiVersions.put(key, gki);
+ }
+ }
+
public static List<Object[]> params() {
List<Object[]> ret = new ArrayList<>();
- for (Object[] osKey : osVersions()) {
- ret.add(new Object[] {true /* protectedVm */, osKey[0]});
- ret.add(new Object[] {false /* protectedVm */, osKey[0]});
+ for (Object[] gki : gkiVersions()) {
+ ret.add(new Object[] {true /* protectedVm */, gki[0]});
+ ret.add(new Object[] {false /* protectedVm */, gki[0]});
}
return ret;
}
- public static List<Object[]> osVersions() {
- return SUPPORTED_OSES.keySet().stream()
- .map(osKey -> new Object[] {osKey})
+ public static List<Object[]> gkiVersions() {
+ initGkiVersions();
+ return sGkiVersions.keySet().stream()
+ .map(gki -> new Object[] {gki})
.collect(Collectors.toList());
}
@@ -285,10 +304,10 @@
Map<String, File> keyOverrides,
boolean isProtected,
boolean updateBootconfigs,
- String os)
+ String gki)
throws Exception {
CommandRunner android = new CommandRunner(getDevice());
- os = SUPPORTED_OSES.get(os);
+ gki = sGkiVersions.get(gki);
File virtApexDir = FileUtil.createTempDir("virt_apex");
@@ -340,6 +359,7 @@
// - its idsig
// Load etc/microdroid.json
+ final String os = (gki == null) ? "microdroid" : "microdroid_gki-" + gki;
File microdroidConfigFile = new File(virtApexEtcDir, os + ".json");
JSONObject config = new JSONObject(FileUtil.readStringFromFile(microdroidConfigFile));
@@ -404,6 +424,9 @@
"--console " + CONSOLE_PATH,
"--log " + LOG_PATH,
configPath);
+ if (gki != null) {
+ args.add("--gki " + gki);
+ }
PipedInputStream pis = new PipedInputStream();
Process process = createRunUtil().runCmdInBackground(args, new PipedOutputStream(pis));
@@ -477,12 +500,12 @@
}
@Test
- @Parameters(method = "osVersions")
- @TestCaseName("{method}_os_{0}")
+ @Parameters(method = "gkiVersions")
+ @TestCaseName("{method}_gki_{0}")
@CddTest(requirements = {"9.17/C-2-1", "9.17/C-2-2", "9.17/C-2-6"})
- public void protectedVmRunsPvmfw(String os) throws Exception {
+ public void protectedVmRunsPvmfw(String gki) throws Exception {
// Arrange
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(true);
final String configPath = "assets/vm_config_apex.json";
@@ -493,7 +516,7 @@
.memoryMib(minMemorySize())
.cpuTopology("match_host")
.protectedVm(true)
- .os(SUPPORTED_OSES.get(os))
+ .gki(sGkiVersions.get(gki))
.name("protected_vm_runs_pvmfw")
.build(getAndroidDevice());
@@ -510,12 +533,12 @@
}
@Test
- @Parameters(method = "osVersions")
- @TestCaseName("{method}_os_{0}")
+ @Parameters(method = "gkiVersions")
+ @TestCaseName("{method}_gki_{0}")
@CddTest(requirements = {"9.17/C-2-1", "9.17/C-2-2", "9.17/C-2-5", "9.17/C-2-6"})
- public void protectedVmWithImageSignedWithDifferentKeyFailsToVerifyPayload(String os)
+ public void protectedVmWithImageSignedWithDifferentKeyFailsToVerifyPayload(String gki)
throws Exception {
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(true);
File key = findTestFile("test.com.android.virt.pem");
@@ -526,7 +549,7 @@
/* keyOverrides= */ Map.of(),
/* isProtected= */ true,
/* updateBootconfigs= */ true,
- os);
+ gki);
// Assert
vmInfo.mProcess.waitFor(5L, TimeUnit.SECONDS);
@@ -539,13 +562,13 @@
}
@Test
- @Parameters(method = "osVersions")
- @TestCaseName("{method}_os_{0}")
+ @Parameters(method = "gkiVersions")
+ @TestCaseName("{method}_gki_{0}")
@CddTest(requirements = {"9.17/C-2-2", "9.17/C-2-6"})
- public void testBootSucceedsWhenNonProtectedVmStartsWithImagesSignedWithDifferentKey(String os)
+ public void testBootSucceedsWhenNonProtectedVmStartsWithImagesSignedWithDifferentKey(String gki)
throws Exception {
// Preconditions
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
File key = findTestFile("test.com.android.virt.pem");
Map<String, File> keyOverrides = Map.of();
@@ -555,7 +578,7 @@
keyOverrides,
/* isProtected= */ false,
/* updateBootconfigs= */ true,
- os);
+ gki);
assertThatEventually(
100000,
() ->
@@ -567,12 +590,12 @@
}
@Test
- @Parameters(method = "osVersions")
- @TestCaseName("{method}_os_{0}")
+ @Parameters(method = "gkiVersions")
+ @TestCaseName("{method}_gki_{0}")
@CddTest(requirements = {"9.17/C-2-2", "9.17/C-2-5", "9.17/C-2-6"})
- public void testBootFailsWhenVbMetaDigestDoesNotMatchBootconfig(String os) throws Exception {
+ public void testBootFailsWhenVbMetaDigestDoesNotMatchBootconfig(String gki) throws Exception {
// protectedVmWithImageSignedWithDifferentKeyRunsPvmfw() is the protected case.
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
// Sign everything with key1 except vbmeta
File key = findTestFile("test.com.android.virt.pem");
@@ -583,7 +606,7 @@
Map.of(),
/* isProtected= */ false,
/* updateBootconfigs= */ false,
- os);
+ gki);
// Wait so that init can print errors to console (time in cuttlefish >> in real device)
assertThatEventually(
100000,
@@ -631,7 +654,7 @@
}
private boolean isTombstoneGeneratedWithCmd(
- boolean protectedVm, String os, String configPath, String... crashCommand)
+ boolean protectedVm, String gki, String configPath, String... crashCommand)
throws Exception {
CommandRunner android = new CommandRunner(getDevice());
String testStartTime = android.runWithTimeout(1000, "date", "'+%Y-%m-%d %H:%M:%S.%N'");
@@ -642,7 +665,7 @@
.memoryMib(minMemorySize())
.cpuTopology("match_host")
.protectedVm(protectedVm)
- .os(SUPPORTED_OSES.get(os))
+ .gki(sGkiVersions.get(gki))
.build(getAndroidDevice());
mMicrodroidDevice.waitForBootComplete(BOOT_COMPLETE_TIMEOUT);
mMicrodroidDevice.enableAdbRoot();
@@ -659,18 +682,18 @@
@Test
@Parameters(method = "params")
- @TestCaseName("{method}_protectedVm_{0}_os_{1}")
- public void testTombstonesAreGeneratedUponUserspaceCrash(boolean protectedVm, String os)
+ @TestCaseName("{method}_protectedVm_{0}_gki_{1}")
+ public void testTombstonesAreGeneratedUponUserspaceCrash(boolean protectedVm, String gki)
throws Exception {
// Preconditions
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
// TODO(b/291867858): tombstones are failing in HWASAN enabled Microdroid.
assumeFalse("tombstones are failing in HWASAN enabled Microdroid.", isHwasan());
assertThat(
isTombstoneGeneratedWithCmd(
protectedVm,
- os,
+ gki,
"assets/vm_config.json",
"kill",
"-SIGSEGV",
@@ -680,18 +703,18 @@
@Test
@Parameters(method = "params")
- @TestCaseName("{method}_protectedVm_{0}_os_{1}")
+ @TestCaseName("{method}_protectedVm_{0}_gki_{1}")
public void testTombstonesAreNotGeneratedIfNotExportedUponUserspaceCrash(
- boolean protectedVm, String os) throws Exception {
+ boolean protectedVm, String gki) throws Exception {
// Preconditions
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
// TODO(b/291867858): tombstones are failing in HWASAN enabled Microdroid.
assumeFalse("tombstones are failing in HWASAN enabled Microdroid.", isHwasan());
assertThat(
isTombstoneGeneratedWithCmd(
protectedVm,
- os,
+ gki,
"assets/vm_config_no_tombstone.json",
"kill",
"-SIGSEGV",
@@ -701,12 +724,12 @@
@Test
@Parameters(method = "params")
- @TestCaseName("{method}_protectedVm_{0}_os_{1}")
+ @TestCaseName("{method}_protectedVm_{0}_gki_{1}")
@Ignore("b/341087884") // TODO(b/341087884): fix & re-enable
- public void testTombstonesAreGeneratedUponKernelCrash(boolean protectedVm, String os)
+ public void testTombstonesAreGeneratedUponKernelCrash(boolean protectedVm, String gki)
throws Exception {
// Preconditions
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
assumeFalse("Cuttlefish is not supported", isCuttlefish());
assumeFalse("Skipping test because ramdump is disabled on user build", isUserBuild());
@@ -715,7 +738,7 @@
assertThat(
isTombstoneGeneratedWithCmd(
protectedVm,
- os,
+ gki,
"assets/vm_config.json",
"echo",
"c",
@@ -725,12 +748,12 @@
}
private boolean isTombstoneGeneratedWithVmRunApp(
- boolean protectedVm, String os, boolean debuggable, String... additionalArgs)
+ boolean protectedVm, String gki, boolean debuggable, String... additionalArgs)
throws Exception {
// we can't use microdroid builder as it wants ADB connection (debuggable)
CommandRunner android = new CommandRunner(getDevice());
String testStartTime = android.runWithTimeout(1000, "date", "'+%Y-%m-%d %H:%M:%S.%N'");
- os = SUPPORTED_OSES.get(os);
+ gki = sGkiVersions.get(gki);
android.run("rm", "-rf", TEST_ROOT + "*");
android.run("mkdir", "-p", TEST_ROOT + "*");
@@ -757,8 +780,10 @@
if (protectedVm) {
cmd.add("--protected");
}
- cmd.add("--os");
- cmd.add(os);
+ if (gki != null) {
+ cmd.add("--gki");
+ cmd.add(gki);
+ }
Collections.addAll(cmd, additionalArgs);
android.run(cmd.toArray(new String[0]));
@@ -766,10 +791,10 @@
}
private boolean isTombstoneGeneratedWithCrashPayload(
- boolean protectedVm, String os, boolean debuggable) throws Exception {
+ boolean protectedVm, String gki, boolean debuggable) throws Exception {
return isTombstoneGeneratedWithVmRunApp(
protectedVm,
- os,
+ gki,
debuggable,
"--payload-binary-name",
"MicrodroidCrashNativeLib.so");
@@ -777,76 +802,76 @@
@Test
@Parameters(method = "params")
- @TestCaseName("{method}_protectedVm_{0}_os_{1}")
- public void testTombstonesAreGeneratedWithCrashPayload(boolean protectedVm, String os)
+ @TestCaseName("{method}_protectedVm_{0}_gki_{1}")
+ public void testTombstonesAreGeneratedWithCrashPayload(boolean protectedVm, String gki)
throws Exception {
// Preconditions
// TODO(b/291867858): tombstones are failing in HWASAN enabled Microdroid.
assumeFalse("tombstones are failing in HWASAN enabled Microdroid.", isHwasan());
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
// Act
- assertThat(isTombstoneGeneratedWithCrashPayload(protectedVm, os, /* debuggable= */ true))
+ assertThat(isTombstoneGeneratedWithCrashPayload(protectedVm, gki, /* debuggable= */ true))
.isTrue();
}
@Test
@Parameters(method = "params")
- @TestCaseName("{method}_protectedVm_{0}_os_{1}")
+ @TestCaseName("{method}_protectedVm_{0}_gki_{1}")
public void testTombstonesAreNotGeneratedWithCrashPayloadWhenNonDebuggable(
- boolean protectedVm, String os) throws Exception {
+ boolean protectedVm, String gki) throws Exception {
// Preconditions
// TODO(b/291867858): tombstones are failing in HWASAN enabled Microdroid.
assumeFalse("tombstones are failing in HWASAN enabled Microdroid.", isHwasan());
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
// Act
- assertThat(isTombstoneGeneratedWithCrashPayload(protectedVm, os, /* debuggable= */ false))
+ assertThat(isTombstoneGeneratedWithCrashPayload(protectedVm, gki, /* debuggable= */ false))
.isFalse();
}
private boolean isTombstoneGeneratedWithCrashConfig(
- boolean protectedVm, String os, boolean debuggable) throws Exception {
+ boolean protectedVm, String gki, boolean debuggable) throws Exception {
return isTombstoneGeneratedWithVmRunApp(
- protectedVm, os, debuggable, "--config-path", "assets/vm_config_crash.json");
+ protectedVm, gki, debuggable, "--config-path", "assets/vm_config_crash.json");
}
@Test
@Parameters(method = "params")
- @TestCaseName("{method}_protectedVm_{0}_os_{1}")
- public void testTombstonesAreGeneratedWithCrashConfig(boolean protectedVm, String os)
+ @TestCaseName("{method}_protectedVm_{0}_gki_{1}")
+ public void testTombstonesAreGeneratedWithCrashConfig(boolean protectedVm, String gki)
throws Exception {
// Preconditions
// TODO(b/291867858): tombstones are failing in HWASAN enabled Microdroid.
assumeFalse("tombstones are failing in HWASAN enabled Microdroid.", isHwasan());
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
// Act
- assertThat(isTombstoneGeneratedWithCrashConfig(protectedVm, os, /* debuggable= */ true))
+ assertThat(isTombstoneGeneratedWithCrashConfig(protectedVm, gki, /* debuggable= */ true))
.isTrue();
}
@Test
@Parameters(method = "params")
- @TestCaseName("{method}_protectedVm_{0}_os_{1}")
+ @TestCaseName("{method}_protectedVm_{0}_gki_{1}")
public void testTombstonesAreNotGeneratedWithCrashConfigWhenNonDebuggable(
- boolean protectedVm, String os) throws Exception {
+ boolean protectedVm, String gki) throws Exception {
// TODO(b/291867858): tombstones are failing in HWASAN enabled Microdroid.
assumeFalse("tombstones are failing in HWASAN enabled Microdroid.", isHwasan());
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
- assertThat(isTombstoneGeneratedWithCrashConfig(protectedVm, os, /* debuggable= */ false))
+ assertThat(isTombstoneGeneratedWithCrashConfig(protectedVm, gki, /* debuggable= */ false))
.isFalse();
}
@Test
@Parameters(method = "params")
- @TestCaseName("{method}_protectedVm_{0}_os_{1}")
- public void testTelemetryPushedAtoms(boolean protectedVm, String os) throws Exception {
- assumeKernelSupported(os);
+ @TestCaseName("{method}_protectedVm_{0}_gki_{1}")
+ public void testTelemetryPushedAtoms(boolean protectedVm, String gki) throws Exception {
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
// Reset statsd config and report before the test
ConfigUtils.removeConfig(getDevice());
@@ -869,7 +894,7 @@
.memoryMib(minMemorySize())
.cpuTopology("match_host")
.protectedVm(protectedVm)
- .os(SUPPORTED_OSES.get(os))
+ .gki(sGkiVersions.get(gki))
.name("test_telemetry_pushed_atoms")
.build(device);
microdroid.waitForBootComplete(BOOT_COMPLETE_TIMEOUT);
@@ -1006,11 +1031,11 @@
@Test
@Parameters(method = "params")
- @TestCaseName("{method}_protectedVm_{0}_os_{1}")
+ @TestCaseName("{method}_protectedVm_{0}_gki_{1}")
@CddTest(requirements = {"9.17/C-1-1", "9.17/C-1-2", "9.17/C/1-3"})
- public void testMicrodroidBoots(boolean protectedVm, String os) throws Exception {
+ public void testMicrodroidBoots(boolean protectedVm, String gki) throws Exception {
// Preconditions
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
final String configPath = "assets/vm_config.json"; // path inside the APK
@@ -1021,34 +1046,34 @@
.cpuTopology("match_host")
.protectedVm(protectedVm)
.name("test_microdroid_boots")
- .os(SUPPORTED_OSES.get(os)));
+ .gki(sGkiVersions.get(gki)));
}
@Test
- public void testMicrodroidRamUsage_protectedVm_true_os_microdroid() throws Exception {
- checkMicrodroidRamUsage(/* protectedVm= */ true, /* os= */ "microdroid");
+ public void testMicrodroidRamUsage_protectedVm_true_gki_null() throws Exception {
+ checkMicrodroidRamUsage(/* protectedVm= */ true, /* gki= */ "null");
}
@Test
- public void testMicrodroidRamUsage_protectedVm_false_os_microdroid() throws Exception {
- checkMicrodroidRamUsage(/* protectedVm= */ false, /* os= */ "microdroid");
+ public void testMicrodroidRamUsage_protectedVm_false_gki_null() throws Exception {
+ checkMicrodroidRamUsage(/* protectedVm= */ false, /* gki= */ "null");
}
@Test
- public void testMicrodroidRamUsage_protectedVm_true_os_android15_66() throws Exception {
- checkMicrodroidRamUsage(/* protectedVm= */ true, /* os= */ "android15_66");
+ public void testMicrodroidRamUsage_protectedVm_true_gki_android15() throws Exception {
+ checkMicrodroidRamUsage(/* protectedVm= */ true, /* gki= */ "android15");
}
@Test
- public void testMicrodroidRamUsage_protectedVm_false_os_android15_66() throws Exception {
- checkMicrodroidRamUsage(/* protectedVm= */ false, /* os= */ "android15_66");
+ public void testMicrodroidRamUsage_protectedVm_false_gki_android15() throws Exception {
+ checkMicrodroidRamUsage(/* protectedVm= */ false, /* gki= */ "android15");
}
// TODO(b/209036125): Upgrade this function to a parameterized test once metrics can be
// collected with tradefed parameterizer.
- void checkMicrodroidRamUsage(boolean protectedVm, String os) throws Exception {
+ void checkMicrodroidRamUsage(boolean protectedVm, String gki) throws Exception {
// Preconditions
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
final String configPath = "assets/vm_config.json";
@@ -1058,7 +1083,7 @@
.memoryMib(minMemorySize())
.cpuTopology("match_host")
.protectedVm(protectedVm)
- .os(SUPPORTED_OSES.get(os))
+ .gki(sGkiVersions.get(gki))
.name("test_microdroid_ram_usage")
.build(getAndroidDevice());
mMicrodroidDevice.waitForBootComplete(BOOT_COMPLETE_TIMEOUT);
@@ -1241,10 +1266,10 @@
@Test
@Parameters(method = "params")
- @TestCaseName("{method}_protectedVm_{0}_os_{1}")
- public void testDeviceAssignment(boolean protectedVm, String os) throws Exception {
+ @TestCaseName("{method}_protectedVm_{0}_gki_{1}")
+ public void testDeviceAssignment(boolean protectedVm, String gki) throws Exception {
// Preconditions
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
assumeVfioPlatformSupported();
@@ -1255,7 +1280,7 @@
// Try assign devices one by one
for (AssignableDevice device : devices) {
- launchWithDeviceAssignment(device.node, protectedVm, os);
+ launchWithDeviceAssignment(device.node, protectedVm, gki);
String dtPath =
new CommandRunner(mMicrodroidDevice)
@@ -1277,7 +1302,7 @@
}
}
- private void launchWithDeviceAssignment(String device, boolean protectedVm, String os)
+ private void launchWithDeviceAssignment(String device, boolean protectedVm, String gki)
throws Exception {
Objects.requireNonNull(device);
final String configPath = "assets/vm_config.json";
@@ -1288,7 +1313,7 @@
.memoryMib(minMemorySize())
.cpuTopology("match_host")
.protectedVm(protectedVm)
- .os(SUPPORTED_OSES.get(os))
+ .gki(sGkiVersions.get(gki))
.addAssignableDevice(device)
.build(getAndroidDevice());
@@ -1297,18 +1322,20 @@
}
@Test
- public void testOsVersions() throws Exception {
- for (String os : getSupportedOSList()) {
- assertWithMessage("Unknown OS \"%s\"", os).that(SUPPORTED_OSES.values()).contains(os);
+ public void testGkiVersions() throws Exception {
+ for (String gki : getSupportedGKIVersions()) {
+ assertTrue(
+ "Unknown gki \"" + gki + "\". Supported gkis: " + SUPPORTED_GKI_VERSIONS,
+ SUPPORTED_GKI_VERSIONS.contains(gki));
}
}
@Test
@Parameters(method = "params")
- @TestCaseName("{method}_protectedVm_{0}_os_{1}")
- public void testHugePages(boolean protectedVm, String os) throws Exception {
+ @TestCaseName("{method}_protectedVm_{0}_gki_{1}")
+ public void testHugePages(boolean protectedVm, String gki) throws Exception {
// Preconditions
- assumeKernelSupported(os);
+ assumeKernelSupported(gki);
assumeVmTypeSupported(protectedVm);
ITestDevice device = getDevice();
@@ -1332,7 +1359,7 @@
.memoryMib(minMemorySize())
.cpuTopology("match_host")
.protectedVm(protectedVm)
- .os(SUPPORTED_OSES.get(os))
+ .gki(sGkiVersions.get(gki))
.hugePages(true)
.name("test_huge_pages")
.build(getAndroidDevice());
@@ -1412,11 +1439,13 @@
return runUtil;
}
- private void assumeKernelSupported(String osKey) throws Exception {
- String os = SUPPORTED_OSES.get(osKey);
- assumeTrue(
- "Skipping test as OS \"" + os + "\" is not supported",
- getSupportedOSList().contains(os));
+ private void assumeKernelSupported(String gki) throws Exception {
+ String gkiVersion = sGkiVersions.get(gki);
+ if (gkiVersion != null) {
+ assumeTrue(
+ "Skipping test as the GKI is not supported: " + gkiVersion,
+ getSupportedGKIVersions().contains(gkiVersion));
+ }
}
private void assumeVmTypeSupported(boolean protectedVm) throws Exception {