diff options
author | Mathieu Chartier <mathieuc@google.com> | 2019-10-24 08:09:56 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-10-24 08:09:56 -0700 |
commit | ca31663ab4fd7da6cb5102add2c93e591cc35119 (patch) | |
tree | 6b9d6665b0f06b5734041b054aa2f110c596fea3 | |
parent | c7ed6b4fe5735447337cedd701b3d61753f80a68 (diff) | |
parent | 761ce2abac004b05069991bacfe57803e16dfa43 (diff) | |
download | base-ca31663ab4fd7da6cb5102add2c93e591cc35119.tar.gz |
Merge "Fix waiting for system server to be running for BootImageProfileTest"
am: 761ce2abac
Change-Id: I597247d864e5b92d734405c87b59ef3282f80cb9
-rw-r--r-- | tests/BootImageProfileTest/src/com/android/bootimageprofile/BootImageProfileTest.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/BootImageProfileTest/src/com/android/bootimageprofile/BootImageProfileTest.java b/tests/BootImageProfileTest/src/com/android/bootimageprofile/BootImageProfileTest.java index ccdd452b3f1e..81937e6b7005 100644 --- a/tests/BootImageProfileTest/src/com/android/bootimageprofile/BootImageProfileTest.java +++ b/tests/BootImageProfileTest/src/com/android/bootimageprofile/BootImageProfileTest.java @@ -54,11 +54,15 @@ public class BootImageProfileTest implements IDeviceTest { assertTrue("profile system server not enabled", res != null && res.equals("true")); } - private void forceSaveProfile(String pkg) throws Exception { + private boolean forceSaveProfile(String pkg) throws Exception { String pid = mTestDevice.executeShellCommand("pidof " + pkg).trim(); - assertTrue("Invalid pid " + pid, pid.length() > 0); + if (pid.length() == 0) { + // Not yet running. + return false; + } String res = mTestDevice.executeShellCommand("kill -s SIGUSR1 " + pid).trim(); assertTrue("kill SIGUSR1: " + res, res.length() == 0); + return true; } @Test @@ -71,10 +75,13 @@ public class BootImageProfileTest implements IDeviceTest { // Wait up to 20 seconds for the profile to be saved. for (int i = 0; i < 20; ++i) { // Force save the profile since we truncated it. - forceSaveProfile("system_server"); - String s = mTestDevice.executeShellCommand("wc -c <" + SYSTEM_SERVER_PROFILE).trim(); - if (!"0".equals(s)) { - break; + if (forceSaveProfile("system_server")) { + // Might fail if system server is not yet running. + String s = mTestDevice.executeShellCommand( + "wc -c <" + SYSTEM_SERVER_PROFILE).trim(); + if (!"0".equals(s)) { + break; + } } Thread.sleep(1000); } |