summaryrefslogtreecommitdiff
path: root/tests/AppLaunch/src
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2020-03-30 15:27:31 -0700
committerIgor Murashkin <iam@google.com>2020-03-30 15:27:31 -0700
commitfcbe6c4359be4cf7e1b5144873b14cd288d0e4e7 (patch)
tree395fb31868d228f831b4c9363d29dfef38699486 /tests/AppLaunch/src
parent938c63035c85071203d41553bf5f168929e40254 (diff)
iorap: AppLaunch - wait for background job to complete.
The background job will always compile all pending packages, so trying to resume app launching too quickly after just 1 package has been compiled will lead to undefined behavior. Bug: 152322429 Test: am instrument Change-Id: I97f773206196bf0ac469fbb87109fd5473b5ea07
Diffstat (limited to 'tests/AppLaunch/src')
-rw-r--r--tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java27
1 files changed, 23 insertions, 4 deletions
diff --git a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
index 42cee7cc5f1e..13bf17954aa4 100644
--- a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
+++ b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
@@ -510,15 +510,18 @@ public class AppLaunch extends InstrumentationTestCase {
* based on status of the compilation command.
*/
private boolean compileAppForIorap(String appPkgName) throws IOException {
+ String logcatTimestamp = getTimeNowForLogcat();
+
getInstrumentation().getUiAutomation().
executeShellCommand(IORAP_COMPILE_CMD);
- for (int i = 0; i < IORAP_COMPILE_CMD_TIMEOUT; ++i) {
+ int i = 0;
+ for (i = 0; i < IORAP_COMPILE_CMD_TIMEOUT; ++i) {
IorapCompilationStatus status = waitForIorapCompiled(appPkgName);
if (status == IorapCompilationStatus.COMPLETE) {
Log.v(TAG, "compileAppForIorap: success");
logDumpsysIorapd(appPkgName);
- return true;
+ break;
} else if (status == IorapCompilationStatus.INSUFFICIENT_TRACES) {
Log.e(TAG, "compileAppForIorap: failed due to insufficient traces");
logDumpsysIorapd(appPkgName);
@@ -527,8 +530,24 @@ public class AppLaunch extends InstrumentationTestCase {
sleep(1000);
}
- Log.e(TAG, "compileAppForIorap: failed due to timeout");
- logDumpsysIorapd(appPkgName);
+ if (i == IORAP_COMPILE_CMD_TIMEOUT) {
+ Log.e(TAG, "compileAppForIorap: failed due to timeout");
+ logDumpsysIorapd(appPkgName);
+ return false;
+ }
+
+ // Wait for the job to finish completely.
+ // Other packages could be compiled in cyclic runs.
+ int currentAttempt = 0;
+ do {
+ String logcatLines = getLogcatSinceTime(logcatTimestamp);
+ if (logcatLines.contains("IorapForwardingService: Finished background job")) {
+ return true;
+ }
+ sleep(1000);
+ } while (currentAttempt++ < IORAP_COMPILE_CMD_TIMEOUT);
+
+ Log.e(TAG, "compileAppForIorap: failed due to jobscheduler timeout.");
return false;
}