Make BootImageProfileTest less flaky
Use the system properties instead of phenotype since GMS can change the
values more arbitrarily for PH properties.
Test: manual
Bug: 149645847
(cherry-picked from commit 599079b381)
Merged-In: If0a716075597f45e95b8357480e4b4a7c52fbb2a
Change-Id: If0a716075597f45e95b8357480e4b4a7c52fbb2a
This commit is contained in:
@@ -30,6 +30,7 @@ public class BootImageProfileTest implements IDeviceTest {
|
|||||||
private ITestDevice mTestDevice;
|
private ITestDevice mTestDevice;
|
||||||
private static final String SYSTEM_SERVER_PROFILE =
|
private static final String SYSTEM_SERVER_PROFILE =
|
||||||
"/data/misc/profiles/cur/0/android/primary.prof";
|
"/data/misc/profiles/cur/0/android/primary.prof";
|
||||||
|
private static final boolean USE_PHENOTYPE = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDevice(ITestDevice testDevice) {
|
public void setDevice(ITestDevice testDevice) {
|
||||||
@@ -41,15 +42,32 @@ public class BootImageProfileTest implements IDeviceTest {
|
|||||||
return mTestDevice;
|
return mTestDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getProperty(String property) throws Exception {
|
||||||
|
if (USE_PHENOTYPE) {
|
||||||
|
return mTestDevice.getProperty("persist.device_config.runtime_native_boot."
|
||||||
|
+ property);
|
||||||
|
} else {
|
||||||
|
return mTestDevice.getProperty("dalvik.vm." + property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String setProperty(String property, String value) throws Exception {
|
||||||
|
if (USE_PHENOTYPE) {
|
||||||
|
return mTestDevice.executeShellCommand(
|
||||||
|
"device_config put runtime_native_boot " + property + " " + value);
|
||||||
|
} else {
|
||||||
|
return mTestDevice.executeShellCommand(
|
||||||
|
"setprop dalvik.vm." + property + " " + value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that the boot image profile properties are set.
|
* Validate that the boot image profile properties are set.
|
||||||
*/
|
*/
|
||||||
public void validateProperties() throws Exception {
|
public void validateProperties() throws Exception {
|
||||||
String res = mTestDevice.getProperty(
|
String res = getProperty("profilebootclasspath");
|
||||||
"persist.device_config.runtime_native_boot.profilebootclasspath");
|
|
||||||
assertTrue("profile boot class path not enabled", res != null && res.equals("true"));
|
assertTrue("profile boot class path not enabled", res != null && res.equals("true"));
|
||||||
res = mTestDevice.getProperty(
|
res = getProperty("profilesystemserver");
|
||||||
"persist.device_config.runtime_native_boot.profilesystemserver");
|
|
||||||
assertTrue("profile system server not enabled", res != null && res.equals("true"));
|
assertTrue("profile system server not enabled", res != null && res.equals("true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,13 +85,12 @@ public class BootImageProfileTest implements IDeviceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testSystemServerProfile() throws Exception {
|
public void testSystemServerProfile() throws Exception {
|
||||||
final int numIterations = 20;
|
final int numIterations = 20;
|
||||||
for (int i = 1; i <= numIterations; ++i) {
|
|
||||||
String res;
|
String res;
|
||||||
res = mTestDevice.getProperty(
|
// Set properties and wait for them to be readable.
|
||||||
"persist.device_config.runtime_native_boot.profilebootclasspath");
|
for (int i = 1; i <= numIterations; ++i) {
|
||||||
|
res = getProperty("profilebootclasspath");
|
||||||
boolean profileBootClassPath = res != null && res.equals("true");
|
boolean profileBootClassPath = res != null && res.equals("true");
|
||||||
res = mTestDevice.getProperty(
|
res = getProperty("profilesystemserver");
|
||||||
"persist.device_config.runtime_native_boot.profilesystemserver");
|
|
||||||
boolean profileSystemServer = res != null && res.equals("true");
|
boolean profileSystemServer = res != null && res.equals("true");
|
||||||
if (profileBootClassPath && profileSystemServer) {
|
if (profileBootClassPath && profileSystemServer) {
|
||||||
break;
|
break;
|
||||||
@@ -83,17 +100,33 @@ public class BootImageProfileTest implements IDeviceTest {
|
|||||||
assertTrue("profile boot class path not enabled", profileSystemServer);
|
assertTrue("profile boot class path not enabled", profileSystemServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = mTestDevice.executeShellCommand(
|
res = setProperty("profilebootclasspath", "true");
|
||||||
"device_config put runtime_native_boot profilebootclasspath true");
|
res = setProperty("profilesystemserver", "true");
|
||||||
res = mTestDevice.executeShellCommand(
|
Thread.sleep(1000);
|
||||||
"device_config put runtime_native_boot profilesystemserver true");
|
|
||||||
res = mTestDevice.executeShellCommand("stop");
|
|
||||||
res = mTestDevice.executeShellCommand("start");
|
|
||||||
Thread.sleep(5000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restart shell and wait for system boot.
|
||||||
|
res = mTestDevice.executeShellCommand("stop");
|
||||||
|
assertTrue("stop shell: " + res, res.length() == 0);
|
||||||
|
res = mTestDevice.executeShellCommand("start");
|
||||||
|
assertTrue("start shell: " + res, res.length() == 0);
|
||||||
|
for (int i = 1; i <= numIterations; ++i) {
|
||||||
|
res = getProperty("profilebootclasspath");
|
||||||
|
boolean profileBootClassPath = res != null && res.equals("true");
|
||||||
|
res = getProperty("profilesystemserver");
|
||||||
|
boolean profileSystemServer = res != null && res.equals("true");
|
||||||
|
if (profileBootClassPath && profileSystemServer) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i == numIterations) {
|
||||||
|
assertTrue("profile system server not enabled", profileSystemServer);
|
||||||
|
assertTrue("profile boot class path not enabled", profileSystemServer);
|
||||||
|
}
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
// Trunacte the profile before force it to be saved to prevent previous profiles
|
// Trunacte the profile before force it to be saved to prevent previous profiles
|
||||||
// causing the test to pass.
|
// causing the test to pass.
|
||||||
String res;
|
|
||||||
res = mTestDevice.executeShellCommand("truncate -s 0 " + SYSTEM_SERVER_PROFILE).trim();
|
res = mTestDevice.executeShellCommand("truncate -s 0 " + SYSTEM_SERVER_PROFILE).trim();
|
||||||
assertTrue(res, res.length() == 0);
|
assertTrue(res, res.length() == 0);
|
||||||
// Wait up to 20 seconds for the profile to be saved.
|
// Wait up to 20 seconds for the profile to be saved.
|
||||||
|
|||||||
Reference in New Issue
Block a user