Ensure check-feature-enabled actually succeeds
The feature "check-feature-enabled" itself maybe disabled on a device
(likely due to older build), in which case command fails with err
"err=error: unrecognized subcommand 'check-feature-enabled". Assume that
the test command succeeds before reading the stdout.
Bug: 402701842
Test: Builds
Change-Id: Ie7bd0f80f68aa3c643cb9b60a6b940b50f91e562
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 fcef19a..7fc6d62 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
@@ -230,8 +230,12 @@
public boolean isFeatureEnabled(String feature) throws Exception {
CommandRunner android = new CommandRunner(getDevice());
- String result = android.run(VIRT_APEX + "bin/vm", "check-feature-enabled", feature);
- return result.contains("enabled");
+ String cmd = VIRT_APEX + "bin/vm check-feature-enabled " + feature;
+ CommandResult result = android.runForResult(cmd);
+ assumeTrue(
+ "Failed to run" + cmd + " " + result,
+ result.getStatus() == CommandStatus.SUCCESS && result.getExitCode() == 0);
+ return result.getStdout().trim().contains("Feature " + feature + " is enabled");
}
public List<AssignableDevice> getAssignableDevices() throws Exception {