summaryrefslogtreecommitdiff
path: root/tests/BootImageProfileTest/src
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2019-09-24 13:11:26 -0700
committerMathieu Chartier <mathieuc@google.com>2019-09-24 15:13:26 -0700
commit4aafe443c37849cfa0f37378bdc87647c8d00d01 (patch)
treef9315aa71d9af26467a08c91ec568288add5795a /tests/BootImageProfileTest/src
parent6c5f83aaa3f81ee0b1d789f11f402145f04674bb (diff)
Wait for the profile to not be empty in BootImageProfileTest
Keep trying to force profile saves until it's not empty. This handles the case when the system server isn't started enough to save a profile yet. This can be affected by boot time fluctuations if we don't wait. Test: atest BootImageProfileTest Bug: 139883463 Change-Id: I98b359412f919bd64c2cd2a5b7d6659d1cef113d
Diffstat (limited to 'tests/BootImageProfileTest/src')
-rw-r--r--tests/BootImageProfileTest/src/com/android/bootimageprofile/BootImageProfileTest.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/BootImageProfileTest/src/com/android/bootimageprofile/BootImageProfileTest.java b/tests/BootImageProfileTest/src/com/android/bootimageprofile/BootImageProfileTest.java
index 17986a3c9d61..730b210f1529 100644
--- a/tests/BootImageProfileTest/src/com/android/bootimageprofile/BootImageProfileTest.java
+++ b/tests/BootImageProfileTest/src/com/android/bootimageprofile/BootImageProfileTest.java
@@ -66,10 +66,18 @@ public class BootImageProfileTest implements IDeviceTest {
String res;
res = mTestDevice.executeShellCommand("truncate -s 0 " + SYSTEM_SERVER_PROFILE).trim();
assertTrue(res, res.length() == 0);
- // Force save profiles in case the system just started.
+ // 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;
+ }
+ Thread.sleep(1000);
+ }
+ // In case the profile is partially saved, wait an extra second.
Thread.sleep(1000);
- forceSaveProfile("system_server");
- Thread.sleep(2000);
// Validate that the profile is non empty.
res = mTestDevice.executeShellCommand("profman --dump-only --profile-file="
+ SYSTEM_SERVER_PROFILE);