Merge "Don't ignore failure to set a property" into main
diff --git a/compos/tests/java/android/compos/test/ComposTestCase.java b/compos/tests/java/android/compos/test/ComposTestCase.java
index 4851321..bd011fa 100644
--- a/compos/tests/java/android/compos/test/ComposTestCase.java
+++ b/compos/tests/java/android/compos/test/ComposTestCase.java
@@ -116,13 +116,13 @@
@Test
public void testOdrefreshSpeed() throws Exception {
- getDevice().setProperty(SYSTEM_SERVER_COMPILER_FILTER_PROP_NAME, "speed");
+ setPropertyOrThrow(getDevice(), SYSTEM_SERVER_COMPILER_FILTER_PROP_NAME, "speed");
testOdrefresh();
}
@Test
public void testOdrefreshSpeedProfile() throws Exception {
- getDevice().setProperty(SYSTEM_SERVER_COMPILER_FILTER_PROP_NAME, "speed-profile");
+ setPropertyOrThrow(getDevice(), SYSTEM_SERVER_COMPILER_FILTER_PROP_NAME, "speed-profile");
testOdrefresh();
}
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 98327a9..937fbee 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
@@ -112,6 +112,13 @@
LogArchiver.archiveLogThenDelete(logs, device, remotePath, localName);
}
+ public static void setPropertyOrThrow(ITestDevice device, String propertyName, String value)
+ throws DeviceNotAvailableException {
+ if (!device.setProperty(propertyName, value)) {
+ throw new RuntimeException("Failed to set sysprop " + propertyName + " to " + value);
+ }
+ }
+
// Run an arbitrary command in the host side and returns the result.
// Note failure is not an error.
public static String tryRunOnHost(String... cmd) {
diff --git a/tests/hostside/java/com/android/microdroid/test/DebugPolicyHostTests.java b/tests/hostside/java/com/android/microdroid/test/DebugPolicyHostTests.java
index 9cf28c7..ffeae09 100644
--- a/tests/hostside/java/com/android/microdroid/test/DebugPolicyHostTests.java
+++ b/tests/hostside/java/com/android/microdroid/test/DebugPolicyHostTests.java
@@ -130,8 +130,8 @@
// or tryLaunchProtectedNonDebuggableVm().
mCustomPvmfwBinFileOnHost =
FileUtil.createTempFile(CUSTOM_PVMFW_FILE_PREFIX, CUSTOM_PVMFW_FILE_SUFFIX);
- mAndroidDevice.setProperty(CUSTOM_PVMFW_IMG_PATH_PROP, CUSTOM_PVMFW_IMG_PATH);
- mAndroidDevice.setProperty(CUSTOM_DEBUG_POLICY_PATH_PROP, CUSTOM_DEBUG_POLICY_PATH);
+ setPropertyOrThrow(mAndroidDevice, CUSTOM_PVMFW_IMG_PATH_PROP, CUSTOM_PVMFW_IMG_PATH);
+ setPropertyOrThrow(mAndroidDevice, CUSTOM_DEBUG_POLICY_PATH_PROP, CUSTOM_DEBUG_POLICY_PATH);
// Prepare for launching microdroid
mAndroidDevice.installPackage(findTestFile(PACKAGE_FILE_NAME), /* reinstall */ false);
@@ -151,8 +151,8 @@
mAndroidDevice.uninstallPackage(PACKAGE_NAME);
// Cleanup for custom debug policies
- mAndroidDevice.setProperty(CUSTOM_DEBUG_POLICY_PATH_PROP, "");
- mAndroidDevice.setProperty(CUSTOM_PVMFW_IMG_PATH_PROP, "");
+ setPropertyOrThrow(mAndroidDevice, CUSTOM_DEBUG_POLICY_PATH_PROP, "");
+ setPropertyOrThrow(mAndroidDevice, CUSTOM_PVMFW_IMG_PATH_PROP, "");
FileUtil.deleteFile(mCustomPvmfwBinFileOnHost);
cleanUpVirtualizationTestSetup(mAndroidDevice);
diff --git a/tests/hostside/java/com/android/microdroid/test/PvmfwImgTest.java b/tests/hostside/java/com/android/microdroid/test/PvmfwImgTest.java
index 320b722..af92674 100644
--- a/tests/hostside/java/com/android/microdroid/test/PvmfwImgTest.java
+++ b/tests/hostside/java/com/android/microdroid/test/PvmfwImgTest.java
@@ -93,7 +93,7 @@
// when launching with launchProtectedVmAndWaitForBootCompleted().
mCustomPvmfwBinFileOnHost =
FileUtil.createTempFile(CUSTOM_PVMFW_FILE_PREFIX, CUSTOM_PVMFW_FILE_SUFFIX);
- mAndroidDevice.setProperty(CUSTOM_PVMFW_IMG_PATH_PROP, CUSTOM_PVMFW_IMG_PATH);
+ setPropertyOrThrow(mAndroidDevice, CUSTOM_PVMFW_IMG_PATH_PROP, CUSTOM_PVMFW_IMG_PATH);
// Prepare for launching microdroid
mAndroidDevice.installPackage(findTestFile(PACKAGE_FILE_NAME), /* reinstall */ false);
@@ -113,7 +113,7 @@
mAndroidDevice.uninstallPackage(PACKAGE_NAME);
// Cleanup for custom pvmfw.img
- mAndroidDevice.setProperty(CUSTOM_PVMFW_IMG_PATH_PROP, "");
+ setPropertyOrThrow(mAndroidDevice, CUSTOM_PVMFW_IMG_PATH_PROP, "");
FileUtil.deleteFile(mCustomPvmfwBinFileOnHost);
cleanUpVirtualizationTestSetup(mAndroidDevice);