Merge "Set boot image profile properties in a loop for BootImageProfileTest" am: 33905aa38d
Change-Id: Icda0be79e45ac0c61ed0051e6c2a8fc468042024
This commit is contained in:
@@ -19,18 +19,8 @@
|
|||||||
-->
|
-->
|
||||||
<target_preparer
|
<target_preparer
|
||||||
class="com.android.tradefed.targetprep.DeviceSetup">
|
class="com.android.tradefed.targetprep.DeviceSetup">
|
||||||
<!-- we need this magic flag, otherwise it always reboots and breaks the selinux -->
|
<!-- we need this magic flag, otherwise it always reboots and breaks selinux -->
|
||||||
<option name="force-skip-system-props" value="true" />
|
<option name="force-skip-system-props" value="true" />
|
||||||
|
|
||||||
<option name="run-command" value="device_config put runtime_native_boot profilesystemserver true" />
|
|
||||||
<option name="run-command" value="device_config put runtime_native_boot profilebootclasspath true" />
|
|
||||||
|
|
||||||
<!-- Profiling does not pick up the above changes we restart the shell -->
|
|
||||||
<option name="run-command" value="stop" />
|
|
||||||
<option name="run-command" value="start" />
|
|
||||||
|
|
||||||
<!-- give it some time to restart the shell; otherwise the first unit test might fail -->
|
|
||||||
<option name="run-command" value="sleep 2" />
|
|
||||||
</target_preparer>
|
</target_preparer>
|
||||||
|
|
||||||
<test class="com.android.tradefed.testtype.HostTest" >
|
<test class="com.android.tradefed.testtype.HostTest" >
|
||||||
|
|||||||
@@ -42,10 +42,9 @@ public class BootImageProfileTest implements IDeviceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that the boot image profile properties are set.
|
* Validate that the boot image profile properties are set.
|
||||||
*/
|
*/
|
||||||
@Test
|
public void validateProperties() throws Exception {
|
||||||
public void testProperties() throws Exception {
|
|
||||||
String res = mTestDevice.getProperty(
|
String res = mTestDevice.getProperty(
|
||||||
"persist.device_config.runtime_native_boot.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"));
|
||||||
@@ -67,13 +66,37 @@ public class BootImageProfileTest implements IDeviceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSystemServerProfile() throws Exception {
|
public void testSystemServerProfile() throws Exception {
|
||||||
|
final int numIterations = 20;
|
||||||
|
for (int i = 1; i <= numIterations; ++i) {
|
||||||
|
String res;
|
||||||
|
res = mTestDevice.getProperty(
|
||||||
|
"persist.device_config.runtime_native_boot.profilebootclasspath");
|
||||||
|
boolean profileBootClassPath = res != null && res.equals("true");
|
||||||
|
res = mTestDevice.getProperty(
|
||||||
|
"persist.device_config.runtime_native_boot.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);
|
||||||
|
}
|
||||||
|
|
||||||
|
res = mTestDevice.executeShellCommand(
|
||||||
|
"device_config put runtime_native_boot profilebootclasspath true");
|
||||||
|
res = mTestDevice.executeShellCommand(
|
||||||
|
"device_config put runtime_native_boot profilesystemserver true");
|
||||||
|
res = mTestDevice.executeShellCommand("stop");
|
||||||
|
res = mTestDevice.executeShellCommand("start");
|
||||||
|
Thread.sleep(5000);
|
||||||
|
}
|
||||||
// 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;
|
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.
|
||||||
final int numIterations = 20;
|
|
||||||
for (int i = 1; i <= numIterations; ++i) {
|
for (int i = 1; i <= numIterations; ++i) {
|
||||||
// Force save the profile since we truncated it.
|
// Force save the profile since we truncated it.
|
||||||
if (forceSaveProfile("system_server")) {
|
if (forceSaveProfile("system_server")) {
|
||||||
@@ -89,6 +112,9 @@ public class BootImageProfileTest implements IDeviceTest {
|
|||||||
// In case the profile is partially saved, wait an extra second.
|
// In case the profile is partially saved, wait an extra second.
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
|
||||||
|
// Validate that properties are still set.
|
||||||
|
validateProperties();
|
||||||
|
|
||||||
// Validate that the profile is non empty.
|
// Validate that the profile is non empty.
|
||||||
res = mTestDevice.executeShellCommand("profman --dump-only --profile-file="
|
res = mTestDevice.executeShellCommand("profman --dump-only --profile-file="
|
||||||
+ SYSTEM_SERVER_PROFILE);
|
+ SYSTEM_SERVER_PROFILE);
|
||||||
|
|||||||
Reference in New Issue
Block a user