Recognizing another SystemUI failure
Also switching investigator to logs starting with the system reboot, as SysUI crashes before the tests start. Change-Id: Ifab835c1ab3c1ce3495f012c6a522fae6e44a9ff
This commit is contained in:
@@ -18,9 +18,13 @@ package com.android.launcher3.util.rule;
|
||||
|
||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import androidx.test.uiautomator.UiDevice;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
class FailureInvestigator {
|
||||
@@ -28,17 +32,21 @@ class FailureInvestigator {
|
||||
return Pattern.compile(regex).matcher(string).find();
|
||||
}
|
||||
|
||||
static int getBugForFailure(CharSequence exception, String testsStartTime) {
|
||||
static int getBugForFailure(CharSequence exception) {
|
||||
if ("com.google.android.setupwizard".equals(
|
||||
UiDevice.getInstance(getInstrumentation()).getLauncherPackageName())) {
|
||||
return 145935261;
|
||||
}
|
||||
|
||||
final String logSinceTestsStart;
|
||||
final String logSinceBoot;
|
||||
try {
|
||||
logSinceTestsStart =
|
||||
final String systemBootTime =
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(
|
||||
new Date(System.currentTimeMillis() - SystemClock.elapsedRealtime()));
|
||||
|
||||
logSinceBoot =
|
||||
UiDevice.getInstance(getInstrumentation())
|
||||
.executeShellCommand("logcat -d -t " + testsStartTime.replace(" ", ""));
|
||||
.executeShellCommand("logcat -d -t " + systemBootTime.replace(" ", ""));
|
||||
} catch (IOException e) {
|
||||
return 0;
|
||||
}
|
||||
@@ -49,19 +57,24 @@ class FailureInvestigator {
|
||||
exception)) {
|
||||
if (matches(
|
||||
"BroadcastQueue: Can't deliver broadcast to com.android.systemui.*Crashing it",
|
||||
logSinceTestsStart)) {
|
||||
logSinceBoot)) {
|
||||
return 147845913;
|
||||
}
|
||||
if (matches(
|
||||
"Attempt to invoke virtual method 'boolean android\\.graphics\\.Bitmap\\"
|
||||
+ ".isRecycled\\(\\)' on a null object reference",
|
||||
logSinceTestsStart)) {
|
||||
logSinceBoot)) {
|
||||
return 148424291;
|
||||
}
|
||||
if (matches(
|
||||
"java\\.lang\\.IllegalArgumentException\\: Ranking map doesn't contain key",
|
||||
logSinceBoot)) {
|
||||
return 148570537;
|
||||
}
|
||||
} else if (matches("java.lang.AssertionError: Launcher build match not found", exception)) {
|
||||
if (matches(
|
||||
"TestStabilityRule: Launcher package: com.google.android.setupwizard",
|
||||
logSinceTestsStart)) {
|
||||
logSinceBoot)) {
|
||||
return 145935261;
|
||||
}
|
||||
} else if (matches("Launcher didn't initialize", exception)) {
|
||||
@@ -69,7 +82,7 @@ class FailureInvestigator {
|
||||
"ActivityManager: Reason: executing service com.google.android.apps"
|
||||
+ ".nexuslauncher/com.android.launcher3.notification"
|
||||
+ ".NotificationListener",
|
||||
logSinceTestsStart)) {
|
||||
logSinceBoot)) {
|
||||
return 148238677;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,9 @@ import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class FailureRewriterRule implements TestRule {
|
||||
private static final String TAG = "FailureRewriter";
|
||||
|
||||
private static final String testsStartTime =
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
return new Statement() {
|
||||
@@ -39,8 +33,7 @@ public class FailureRewriterRule implements TestRule {
|
||||
try {
|
||||
base.evaluate();
|
||||
} catch (Throwable e) {
|
||||
final int bug =
|
||||
FailureInvestigator.getBugForFailure(e.toString(), testsStartTime);
|
||||
final int bug = FailureInvestigator.getBugForFailure(e.toString());
|
||||
if (bug == 0) throw e;
|
||||
|
||||
Log.e(TAG, "Known bug found for the original failure "
|
||||
|
||||
Reference in New Issue
Block a user