summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-05-17 14:21:24 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-05-17 14:21:24 +0000
commit177a4163a494fca8fa1a029b4953898ef1752290 (patch)
treede8ef3a2d06c0a2926f65987e5fb6ee0e718fb11
parent6f9812173359fe40cc3a82c67fb78ac567d81c26 (diff)
parent7e8dea6d064b0132db27f7014bf806bb6d05d7ad (diff)
downloadloganalysis-177a4163a494fca8fa1a029b4953898ef1752290.tar.gz
release-request-323db86e-b638-4d24-8eb1-d2e3bf4a9d1a-for-git_oc-mr1-release-4017779 snap-temp-L47900000064949209
Change-Id: I5c11705ebe8b6016a11f64e2b3c12a3cd13f152c
-rw-r--r--src/com/android/loganalysis/item/DmesgStageInfoItem.java23
-rw-r--r--src/com/android/loganalysis/parser/DmesgParser.java28
-rw-r--r--src/com/android/loganalysis/parser/EventsLogParser.java57
-rw-r--r--tests/src/com/android/loganalysis/parser/DmesgParserTest.java21
-rw-r--r--tests/src/com/android/loganalysis/parser/EventsLogParserTest.java111
-rw-r--r--tests/src/com/android/loganalysis/util/RegexTrieTest.java51
6 files changed, 154 insertions, 137 deletions
diff --git a/src/com/android/loganalysis/item/DmesgStageInfoItem.java b/src/com/android/loganalysis/item/DmesgStageInfoItem.java
index a5bfd39..a446090 100644
--- a/src/com/android/loganalysis/item/DmesgStageInfoItem.java
+++ b/src/com/android/loganalysis/item/DmesgStageInfoItem.java
@@ -30,9 +30,11 @@ public class DmesgStageInfoItem extends GenericItem {
public static final String STAGE_NAME = "STAGE_NAME";
/** Constant for JSON output */
public static final String STAGE_START_TIME = "STAGE_START_TIME";
+ /** Constant for JSON output */
+ public static final String STAGE_DURATION = "STAGE_DURATION";
private static final Set<String> ATTRIBUTES = new HashSet<String>(Arrays.asList(
- STAGE_NAME, STAGE_START_TIME));
+ STAGE_NAME, STAGE_START_TIME, STAGE_DURATION));
/**
* The constructor for {@link DmesgStageInfoItem}.
@@ -44,10 +46,11 @@ public class DmesgStageInfoItem extends GenericItem {
/**
* The constructor for {@link DmesgStageInfoItem}.
*/
- public DmesgStageInfoItem(String name, Long startTime) {
+ public DmesgStageInfoItem(String name, Long startTime, Long duration) {
super(ATTRIBUTES);
setAttribute(STAGE_NAME, name);
setAttribute(STAGE_START_TIME, startTime);
+ setAttribute(STAGE_DURATION, duration);
}
/**
@@ -78,10 +81,24 @@ public class DmesgStageInfoItem extends GenericItem {
setAttribute(STAGE_START_TIME, startTime);
}
+ /**
+ * Get the duration in msecs
+ */
+ public Long getDuration() {
+ return (Long) getAttribute(STAGE_DURATION);
+ }
+
+ /**
+ * Set the duration in msecs
+ */
+ public void setDuration(Long duration) {
+ setAttribute(STAGE_DURATION, duration);
+ }
+
@Override
public String toString() {
return "StageInfoItem [getStageName()=" + getStageName() + ", getStartTime()="
- + getStartTime() + "]";
+ + getStartTime() + ", getDuration()=" + getDuration() + "]";
}
}
diff --git a/src/com/android/loganalysis/parser/DmesgParser.java b/src/com/android/loganalysis/parser/DmesgParser.java
index bd0d8e4..ce3d389 100644
--- a/src/com/android/loganalysis/parser/DmesgParser.java
+++ b/src/com/android/loganalysis/parser/DmesgParser.java
@@ -20,6 +20,7 @@ import com.android.loganalysis.item.DmesgActionInfoItem;
import com.android.loganalysis.item.DmesgItem;
import com.android.loganalysis.item.DmesgServiceInfoItem;
import com.android.loganalysis.item.DmesgStageInfoItem;
+
import com.google.common.annotations.VisibleForTesting;
import java.io.BufferedReader;
@@ -39,15 +40,22 @@ public class DmesgParser implements IParser {
private static final String TIMESTAMP = "TIMESTAMP";
private static final String STAGE = "STAGE";
private static final String ACTION = "ACTION";
+ private static final String DURATION = "DURATION";
+ private static final String UEVENTD = "ueventd";
+
// Matches: [ 14.822691] init:
private static final String SERVICE_PREFIX = String.format("^\\[\\s+(?<%s>.*)\\] init:\\s+",
TIMESTAMP);
+ // Matches: [ 3.791635] ueventd:
+ private static final String UEVENTD_PREFIX = String.format("^\\[\\s+(?<%s>.*)\\] ueventd:\\s+",
+ TIMESTAMP);
+
// Matches: starting service 'ueventd'...
private static final String START_SERVICE_SUFFIX = String.format("starting service "
+ "\\'(?<%s>.*)\\'...", SERVICENAME);
// Matches: Service 'ueventd' (pid 439) exited with status 0
private static final String EXIT_SERVICE_SUFFIX = String.format("Service \\'(?<%s>.*)\\'\\s+"
- + "\\((?<PID>.*)\\) exited with status 0", SERVICENAME);
+ + "\\((?<PID>.*)\\) exited with status 0.*", SERVICENAME);
private static final Pattern START_SERVICE = Pattern.compile(
String.format("%s%s", SERVICE_PREFIX, START_SERVICE_SUFFIX));
@@ -65,12 +73,18 @@ public class DmesgParser implements IParser {
// Matches: init: processing action (early-init)
private static final String START_PROCESSING_ACTION_PREFIX = String.format(
- "processing action \\((?<%s>.*)\\)", ACTION);
+ "processing action \\((?<%s>.*)\\) from.*$", ACTION);
// Matches: [ 14.942872] init: processing action (early-init)
private static final Pattern START_PROCESSING_ACTION = Pattern.compile(
String.format("%s%s", SERVICE_PREFIX, START_PROCESSING_ACTION_PREFIX));
+ // Matches: [ 3.791635] ueventd: Coldboot took 0.695055 seconds
+ private static final String STAGE_SUFFIX= String.format(
+ "(?<%s>.*)\\s+took\\s+(?<%s>.*)\\s+seconds$", STAGE, DURATION);
+ private static final Pattern UEVENTD_STAGE_INFO = Pattern.compile(
+ String.format("%s%s", UEVENTD_PREFIX, STAGE_SUFFIX));
+
private DmesgItem mDmesgItem = new DmesgItem();
@@ -163,7 +177,8 @@ public class DmesgParser implements IParser {
/**
* Parse init stages log from each {@code line} of dmesg log and
- * store the stage name and start time in a {@link DmesgStageInfoItem} object
+ * store the stage name, start time and duration if available in a
+ * {@link DmesgStageInfoItem} object
*
* @param individual line of the dmesg log
* @return {@code true}, if the {@code line} indicates start of a boot stage,
@@ -180,6 +195,13 @@ public class DmesgParser implements IParser {
mDmesgItem.addStageInfoItem(stageInfoItem);
return true;
}
+ if((match = matches(UEVENTD_STAGE_INFO, line)) != null) {
+ DmesgStageInfoItem stageInfoItem = new DmesgStageInfoItem();
+ stageInfoItem.setStageName(String.format("%s_%s", UEVENTD, match.group(STAGE)));
+ stageInfoItem.setDuration((long) (Double.parseDouble(
+ match.group(DURATION)) * 1000));
+ mDmesgItem.addStageInfoItem(stageInfoItem);
+ }
return false;
}
diff --git a/src/com/android/loganalysis/parser/EventsLogParser.java b/src/com/android/loganalysis/parser/EventsLogParser.java
index a15abf8..33afb2f 100644
--- a/src/com/android/loganalysis/parser/EventsLogParser.java
+++ b/src/com/android/loganalysis/parser/EventsLogParser.java
@@ -35,24 +35,21 @@ public class EventsLogParser implements IParser {
// 08-21 17:53:53.876 1053 2135
private static final String EVENTS_PREFIX = "^\\d{2}-\\d{2} \\d{2}:\\d{2}"
+ ":\\d{2}.\\d{3}\\s+\\d+\\s+\\d+ ";
- // 08-21 17:53:53.876 1053 2135 I am_restart_activity:
- // [0,188098346,127,com.google.android.gm/.ConversationListActivityGmail]
- private static final Pattern ACTIVITY_RESTART = Pattern.compile(
- String.format("%s%s", EVENTS_PREFIX, "I am_restart_activity: "
- + "\\[\\d+\\,\\d+\\,\\d+\\,(?<componentname>.*)\\]$"));
- // 08-21 17:53:53.876 1053 2135 I am_resume_activity:
- // [0,228277756,132,com.google.android.gm/.ConversationListActivityGmail]
- private static final Pattern ACTIVITY_RESUME = Pattern.compile(
- String.format("%s%s", EVENTS_PREFIX, "I am_resume_activity: "
- + "\\[\\d+\\,\\d+\\,\\d+\\,(?<componentname>.*)\\]$"));
- // 08-21 17:53:53.876 1053 2135 I sysui_action: [321,74]
- private static final Pattern STARTING_WINDOW_DELAY = Pattern.compile(
- String.format("%s%s", EVENTS_PREFIX, "I sysui_action: \\[321,"
- + "(?<startdelay>.*)\\]$"));
- // 08-21 17:53:53.876 1053 2135 I sysui_action: [319,99]
+
+ // 01-01 01:38:44.863 1037 1111 I sysui_multi_action:
+ // [319,64,321,64,322,99,325,5951,757,761,758,9,759,4,806,com.google.android.gm,871,
+ // com.google.android.gm.welcome.WelcomeTourActivity,905,0]
+ private static final Pattern TRANSITION_STARTING_DELAY = Pattern.compile(
+ String.format("%s%s", EVENTS_PREFIX, "I sysui_multi_action: \\[319,(.*),321,(.*)"
+ + ",322,(.*),806,(.*),871,(.*),905.*\\]$"));
+
+ // 01-01 01:38:44.863 1037 1111 I sysui_multi_action:
+ // [319,64,322,99,325,5951,757,761,758,9,759,4,806,com.google.android.gm,871,
+ // com.google.android.gm.welcome.WelcomeTourActivity,905,0]
private static final Pattern TRANSITION_DELAY = Pattern.compile(
- String.format("%s%s", EVENTS_PREFIX, "I sysui_action: \\[319,"
- + "(?<transitdelay>.*)\\]$"));
+ String.format("%s%s", EVENTS_PREFIX, "I sysui_multi_action: \\[319,(.*),322,(.*)"
+ + ",806,(.*),871,(.*),905.*\\]$"));
+
// 08-21 17:53:53.876 1053 2135 I sysui_latency: [1,50]
private static final Pattern ACTION_LATENCY = Pattern.compile(
String.format("%s%s", EVENTS_PREFIX, "I sysui_latency: \\[(?<action>.*),"
@@ -75,30 +72,18 @@ public class EventsLogParser implements IParser {
throws IOException {
List<TransitionDelayItem> transitionDelayItems = new ArrayList<TransitionDelayItem>();
String line;
- List<String> componentNameStack = new ArrayList<String>();
- boolean isRecentStartWindowDelay = false;
while ((line = input.readLine()) != null) {
Matcher match = null;
- if ((match = matches(ACTIVITY_RESTART, line)) != null ||
- ((match = matches(ACTIVITY_RESUME, line)) != null)) {
- componentNameStack.add(match.group("componentname"));
- isRecentStartWindowDelay = false;
- } else if (((match = matches(STARTING_WINDOW_DELAY, line)) != null)
- && (componentNameStack.size() > 0)) {
+ if (((match = matches(TRANSITION_STARTING_DELAY, line)) != null)) {
TransitionDelayItem delayItem = new TransitionDelayItem();
- delayItem.setComponentName(
- componentNameStack.remove(componentNameStack.size() - 1));
- delayItem.setStartingWindowDelay(Long.parseLong(match.group("startdelay")));
- delayItem.setTransitionDelay(-1);
+ delayItem.setComponentName(match.group(4) + "/" + match.group(5));
+ delayItem.setTransitionDelay(Long.parseLong(match.group(1)));
+ delayItem.setStartingWindowDelay(Long.parseLong(match.group(2)));
transitionDelayItems.add(delayItem);
- isRecentStartWindowDelay = true;
- } else if (((match = matches(TRANSITION_DELAY, line)) != null)
- && (componentNameStack.size() > 0) && !isRecentStartWindowDelay) {
+ } else if (((match = matches(TRANSITION_DELAY, line)) != null)) {
TransitionDelayItem delayItem = new TransitionDelayItem();
- delayItem.setComponentName(
- componentNameStack.remove(componentNameStack.size() - 1));
- delayItem.setTransitionDelay(Long.parseLong(match.group("transitdelay")));
- delayItem.setStartingWindowDelay(-1);
+ delayItem.setComponentName(match.group(3) + "/" + match.group(4));
+ delayItem.setTransitionDelay(Long.parseLong(match.group(1)));
transitionDelayItems.add(delayItem);
}
}
diff --git a/tests/src/com/android/loganalysis/parser/DmesgParserTest.java b/tests/src/com/android/loganalysis/parser/DmesgParserTest.java
index 2206733..7db2c49 100644
--- a/tests/src/com/android/loganalysis/parser/DmesgParserTest.java
+++ b/tests/src/com/android/loganalysis/parser/DmesgParserTest.java
@@ -39,6 +39,7 @@ public class DmesgParserTest extends TestCase {
private static final String BOOT_ANIMATION = "bootanim";
private static final String NETD = "netd";
private static final String[] LINES = new String[] {
+ "[ 3.786943] ueventd: Coldboot took 0.701291 seconds",
"[ 22.962730] init: starting service 'bootanim'...",
"[ 23.252321] init: starting service 'netd'...",
"[ 29.331069] ipa-wan ipa_wwan_ioctl:1428 dev(rmnet_data0) register to IPA",
@@ -46,15 +47,14 @@ public class DmesgParserTest extends TestCase {
"[ 35.642666] SELinux: initialized (dev fuse, type fuse), uses genfs_contexts",
"[ 39.855818] init: Service 'bootanim' (pid 588) exited with status 0",
"[ 41.665818] init: init first stage started!",
- "[ 42.425056] init: init second stage started!",
- "[ 44.942872] init: processing action (early-init)",
- "[ 47.233446] init: processing action (set_mmap_rnd_bits)",
- "[ 47.240083] init: processing action (set_kptr_restrict)",
- "[ 47.245778] init: processing action (keychord_init)",
- "[ 52.361049] init: processing action (persist.sys.usb.config=* boot)",
- "[ 52.361108] init: processing action (enable_property_trigger)",
- "[ 52.361313] init: processing action (security.perf_harden=1)",
- "[ 52.361495] init: processing action (ro.debuggable=1)",
+ "[ 44.942872] init: processing action (early-init) from (/init.rc:13)",
+ "[ 47.233446] init: processing action (set_mmap_rnd_bits) from (<Builtin Action>:0)",
+ "[ 47.240083] init: processing action (set_kptr_restrict) from (<Builtin Action>:0)",
+ "[ 47.245778] init: processing action (keychord_init) from (<Builtin Action>:0)",
+ "[ 52.361049] init: processing action (persist.sys.usb.config=* boot) from (<Builtin Action>:0)",
+ "[ 52.361108] init: processing action (enable_property_trigger) from (<Builtin Action>:0)",
+ "[ 52.361313] init: processing action (security.perf_harden=1) from (/init.rc:677)",
+ "[ 52.361495] init: processing action (ro.debuggable=1) from (/init.rc:700)",
"[ 59.331069] ipa-wan ipa_wwan_ioctl:1428 dev(rmnet_data0) register to IPA",
"[ 62.182592] ueventd: fixup /sys/devices/virtual/input/poll_delay 0 1004 660",
"[ 65.642666] SELinux: initialized (dev fuse, type fuse), uses genfs_contexts",
@@ -231,7 +231,8 @@ public class DmesgParserTest extends TestCase {
private static List<DmesgStageInfoItem> getExpectedStageInfoItems() {
return Arrays.asList(
- new DmesgStageInfoItem("first", 41665L), new DmesgStageInfoItem("second", 42425L));
+ new DmesgStageInfoItem("ueventd_Coldboot", null, 701L),
+ new DmesgStageInfoItem("first", 41665L, null));
}
private static Map<String, DmesgServiceInfoItem> getExpectedServiceInfoItems() {
diff --git a/tests/src/com/android/loganalysis/parser/EventsLogParserTest.java b/tests/src/com/android/loganalysis/parser/EventsLogParserTest.java
index a3dc283..f811580 100644
--- a/tests/src/com/android/loganalysis/parser/EventsLogParserTest.java
+++ b/tests/src/com/android/loganalysis/parser/EventsLogParserTest.java
@@ -71,46 +71,44 @@ public class EventsLogParserTest extends TestCase {
}
/**
- * Test for Cold launch transition delay info
+ * Test for Cold launch transition delay and starting window delay info
*/
- public void testColdLaunchTransitionDelay() throws IOException {
+ public void testValidTransitionDelay() throws IOException {
List<String> lines = Arrays
- .asList("08-25 13:01:19.412 1152 9031 I am_restart_activity: [0,85290699,38,com.google.android.gm/.ConversationListActivityGmail]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [321,85]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [320,1]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [319,85]");
+ .asList("01-02 08:12:10.849 934 986 I sysui_multi_action: [319,42,321,59,322,208,325,84100,757,761,758,9,759,4,806,com.google.android.apps.maps,871,com.google.android.maps.MapsActivity,905,0]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_trigger_nav_btn,802,1]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_source_app,802,1]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,804,799,overview_source_app_index,801,8,802,1]");
List<TransitionDelayItem> transitionItems = (new EventsLogParser()).
parseTransitionDelayInfo(readInputBuffer(getTempFile(lines)));
assertEquals("Transition Delay items list should have one item", 1,
transitionItems.size());
assertEquals("Component name not parsed correctly",
- "com.google.android.gm/.ConversationListActivityGmail",
+ "com.google.android.apps.maps/com.google.android.maps.MapsActivity",
transitionItems.get(0).getComponentName());
- assertEquals("Cold launch info is not set correctly", 85,
- transitionItems.get(0).getStartingWindowDelay());
- assertEquals("Hot launch info is set which is not expected", -1,
+ assertEquals("Transition delay is not parsed correctly", 42,
transitionItems.get(0).getTransitionDelay());
+ assertEquals("Starting window delay is not parsed correctly", 59,
+ transitionItems.get(0).getStartingWindowDelay());
}
/**
- * Test for Hot launch transition delay
+ * Test for only transition delay in hot launch
*/
- public void testHotLaunchTransitionDelay() throws IOException {
+ public void testOnlyTransitionDelay() throws IOException {
List<String> lines = Arrays
- .asList("08-25 13:02:04.740 1152 2715 I am_resume_activity: [0,85290699,38,com.google.android.gm/.ConversationListActivityGmail]",
- "08-25 13:02:04.754 1152 1180 I sysui_count: [window_time_0,23]",
- "08-25 13:02:04.755 1152 1226 I sysui_action: [320,0]",
- "08-25 13:02:04.755 1152 1226 I sysui_action: [319,37]");
+ .asList("01-02 08:12:10.849 934 986 I sysui_multi_action: [319,42,322,208,325,84100,757,761,758,9,759,4,806,com.google.android.apps.maps,871,com.google.android.maps.MapsActivity,905,0]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_trigger_nav_btn,802,1]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_source_app,802,1]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,804,799,overview_source_app_index,801,8,802,1]");
List<TransitionDelayItem> transitionItems = (new EventsLogParser()).
parseTransitionDelayInfo(readInputBuffer(getTempFile(lines)));
- assertEquals("Transition Delay items list shopuld have one item", 1,
+ assertEquals("Transition Delay items list should have one item", 1,
transitionItems.size());
assertEquals("Component name not parsed correctly",
- "com.google.android.gm/.ConversationListActivityGmail",
+ "com.google.android.apps.maps/com.google.android.maps.MapsActivity",
transitionItems.get(0).getComponentName());
- assertEquals("Cold launch info is set which is not expected", -1,
- transitionItems.get(0).getStartingWindowDelay());
- assertEquals("Hot launch info is not set correctly", 37,
+ assertEquals("Transition delay is not parsed correctly", 42,
transitionItems.get(0).getTransitionDelay());
}
@@ -119,26 +117,19 @@ public class EventsLogParserTest extends TestCase {
*/
public void testTransitionDelayOrder() throws IOException {
List<String> lines = Arrays
- .asList("08-25 13:01:19.412 1152 9031 I am_restart_activity: [0,85290699,38,com.google.android.gm/.ConversationListActivityGmail]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [321,85]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [320,1]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [319,85]",
- "08-25 12:56:15.850 1152 8968 I am_focused_stack: [0,0,1,appDied setFocusedActivity]",
- "08-25 12:56:15.850 1152 8968 I wm_task_moved: [6,1,1]",
- "08-25 12:56:15.852 1152 8968 I am_focused_activity: [0,com.google.android.apps.nexuslauncher/.NexusLauncherActivity,appDied]",
- "08-25 12:56:15.852 1152 8968 I wm_task_removed: [27,removeTask]",
- "08-25 12:56:15.852 1152 8968 I wm_stack_removed: 1",
- "08-25 13:02:04.740 1152 2715 I am_resume_activity: [0,85290699,38,com.google.android.gm/.ConversationListActivityGmail]",
- "08-25 13:02:04.754 1152 1180 I sysui_count: [window_time_0,23]",
- "08-25 13:02:04.755 1152 1226 I sysui_action: [320,0]",
- "08-25 13:02:04.755 1152 1226 I sysui_action: [319,37]");
+ .asList("01-02 08:12:10.849 934 986 I sysui_multi_action: [319,42,321,59,322,208,325,84100,757,761,758,9,759,4,806,com.google.android.apps.maps,871,com.google.android.maps.MapsActivity,905,0]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_trigger_nav_btn,802,1]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_source_app,802,1]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,804,799,overview_source_app_index,801,8,802,1]",
+ "01-02 08:12:42.187 934 986 I sysui_multi_action: [319,61,321,46,322,159,325,84131,757,761,758,9,759,4,806,com.google.android.apps.maps,871,com.google.android.maps.MapsActivity,905,0]",
+ "01-02 08:12:42.450 1446 1446 I sysui_multi_action: [757,224,758,2]");
List<TransitionDelayItem> transitionItems = (new EventsLogParser()).
parseTransitionDelayInfo(readInputBuffer(getTempFile(lines)));
assertEquals("Transition Delay items list should have two items", 2,
transitionItems.size());
- assertEquals("Cold launch transition delay is not the first item", 85,
- transitionItems.get(0).getStartingWindowDelay());
- assertEquals("Hot launch transition delay is not the second item", 37,
+ assertEquals("Transition delay for the first item is not set correct", 42,
+ transitionItems.get(0).getTransitionDelay());
+ assertEquals("Transition delay for the second item is not set correct", 61,
transitionItems.get(1).getTransitionDelay());
}
@@ -147,27 +138,18 @@ public class EventsLogParserTest extends TestCase {
*/
public void testDifferentAppTransitionDelay() throws IOException {
List<String> lines = Arrays
- .asList("08-25 13:01:19.412 1152 9031 I am_restart_activity: [0,85290699,38,com.google.android.gm/.ConversationListActivityGmail]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [321,85]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [320,1]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [319,85]",
- "08-25 12:56:15.850 1152 8968 I am_focused_stack: [0,0,1,appDied setFocusedActivity]",
- "08-25 12:56:15.850 1152 8968 I wm_task_moved: [6,1,1]",
- "08-25 12:56:15.852 1152 8968 I am_focused_activity: [0,com.google.android.apps.nexuslauncher/.NexusLauncherActivity,appDied]",
- "08-25 12:56:15.852 1152 8968 I wm_task_removed: [27,removeTask]",
- "08-25 12:56:15.852 1152 8968 I wm_stack_removed: 1",
- "08-25 13:03:35.528 1152 2715 I am_restart_activity: [0,32358360,39,com.google.android.apps.maps/com.google.android.maps.MapsActivity]",
- "08-25 13:03:35.540 1152 1179 I am_pss : [7727,10032,com.google.android.apps.nexuslauncher,50991104,45486080,0]",
- "08-25 13:03:35.566 1152 1179 I am_pss : [9207,10045,com.google.android.googlequicksearchbox:search,111955968,102227968,0]",
- "08-25 13:03:35.569 1152 1226 I sysui_action: [321,92]",
- "08-25 13:03:35.569 1152 1226 I sysui_action: [320,1]",
- "08-25 13:03:35.569 1152 1226 I sysui_action: [319,92]");
+ .asList("01-02 08:11:58.691 934 986 I sysui_multi_action: [319,48,321,37,322,82,325,84088,757,761,758,9,759,4,806,com.google.android.calculator,871,com.android.calculator2.Calculator,905,0]",
+ "01-02 08:12:03.639 934 970 I sysui_multi_action: [757,803,799,window_time_0,802,5]",
+ "01-02 08:12:10.849 934 986 I sysui_multi_action: [319,42,321,59,322,208,325,84100,757,761,758,9,759,4,806,com.google.android.apps.maps,871,com.google.android.maps.MapsActivity,905,0]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_trigger_nav_btn,802,1]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_source_app,802,1]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,804,799,overview_source_app_index,801,8,802,1]");
List<TransitionDelayItem> transitionItems = (new EventsLogParser()).
parseTransitionDelayInfo(readInputBuffer(getTempFile(lines)));
assertEquals("Transition Delay items list should have two items", 2,
transitionItems.size());
- assertEquals("Gmail is not the first transition delay item",
- "com.google.android.gm/.ConversationListActivityGmail",
+ assertEquals("Calculator is not the first transition delay item",
+ "com.google.android.calculator/com.android.calculator2.Calculator",
transitionItems.get(0).getComponentName());
assertEquals("Maps is not the second transition delay item",
"com.google.android.apps.maps/com.google.android.maps.MapsActivity",
@@ -175,23 +157,16 @@ public class EventsLogParserTest extends TestCase {
}
/**
- * Test for invalid transition delay items pattern
+ * Test for invalid transition delay items pattern having different code.
*/
public void testInvalidTransitionPattern() throws IOException {
List<String> lines = Arrays
- .asList("08-25 13:01:19.412 1152 9031 I am_restart_activity: [com.google.android.gm/.ConversationListActivityGmail,0,85290699,38]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [321,85]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [320,1]",
- "08-25 13:01:19.437 1152 1226 I sysui_action: [319,85]",
- "08-25 12:56:15.850 1152 8968 I am_focused_stack: [0,0,1,appDied setFocusedActivity]",
- "08-25 12:56:15.850 1152 8968 I wm_task_moved: [6,1,1]",
- "08-25 12:56:15.852 1152 8968 I am_focused_activity: [0,com.google.android.apps.nexuslauncher/.NexusLauncherActivity,appDied]",
- "08-25 12:56:15.852 1152 8968 I wm_task_removed: [27,removeTask]",
- "08-25 12:56:15.852 1152 8968 I wm_stack_removed: 1",
- "08-25 13:02:04.740 1152 2715 I am_res_activity: [0,85290699,38,com.google.android.gm/.ConversationListActivityGmail]",
- "08-25 13:02:04.754 1152 1180 I sysui_count: [window_time_0,23]",
- "08-25 13:02:04.755 1152 1226 I sysui_action: [320,0]",
- "08-25 13:02:04.755 1152 1226 I sysui_action: [319,37]");
+ .asList("01-02 08:11:58.691 934 986 I sysui_multi_action: [319,48,322,82,325,84088,757,761,758,9,759,4,807,com.google.android.calculator,871,com.android.calculator2.Calculator,905,0]",
+ "01-02 08:12:03.639 934 970 I sysui_multi_action: [757,803,799,window_time_0,802,5]",
+ "01-02 08:12:10.849 934 986 I sysui_multi_action: 319,42,321,59,322,208,325,84100,757,761,758,9,759,4,806,com.google.android.apps.maps,871,com.google.android.maps.MapsActivity,905,0]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_trigger_nav_btn,802,1]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_source_app,802,1]",
+ "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,804,799,overview_source_app_index,801,8,802,1]");
List<TransitionDelayItem> transitionItems = (new EventsLogParser()).
parseTransitionDelayInfo(readInputBuffer(getTempFile(lines)));
assertEquals("Transition Delay items list should be empty", 0,
diff --git a/tests/src/com/android/loganalysis/util/RegexTrieTest.java b/tests/src/com/android/loganalysis/util/RegexTrieTest.java
index 3b00e55..4b689b6 100644
--- a/tests/src/com/android/loganalysis/util/RegexTrieTest.java
+++ b/tests/src/com/android/loganalysis/util/RegexTrieTest.java
@@ -15,9 +15,18 @@
*/
package com.android.loganalysis.util;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import com.android.loganalysis.util.RegexTrie.CompPattern;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import java.util.ArrayList;
import java.util.Arrays;
@@ -25,25 +34,26 @@ import java.util.HashMap;
import java.util.List;
import java.util.regex.Pattern;
-/**
- * Set of unit tests to verify the behavior of the RegexTrie
- */
-public class RegexTrieTest extends TestCase {
+/** Set of unit tests to verify the behavior of the RegexTrie */
+@RunWith(JUnit4.class)
+public class RegexTrieTest {
private RegexTrie<Integer> mTrie = null;
private static final Integer STORED_VAL = 42;
private static final List<String> NULL_LIST = Arrays.asList((String)null);
- @Override
+ @Before
public void setUp() throws Exception {
mTrie = new RegexTrie<Integer>();
}
+ @Test
public void testStringPattern() {
mTrie.put(STORED_VAL, "[p]art1", "[p]art2", "[p]art3");
Integer retrieved = mTrie.retrieve("part1", "part2", "part3");
assertEquals(STORED_VAL, retrieved);
}
+ @Test
public void testAlternation_single() {
mTrie.put(STORED_VAL, "alpha|beta");
Integer retrieved;
@@ -59,6 +69,7 @@ public class RegexTrieTest extends TestCase {
assertNull(retrieved);
}
+ @Test
public void testAlternation_multiple() {
mTrie.put(STORED_VAL, "a|alpha", "b|beta");
Integer retrieved;
@@ -79,6 +90,7 @@ public class RegexTrieTest extends TestCase {
assertNull(retrieved);
}
+ @Test
public void testGroups_fullMatch() {
mTrie.put(STORED_VAL, "a|(alpha)", "b|(beta)");
Integer retrieved;
@@ -109,6 +121,7 @@ public class RegexTrieTest extends TestCase {
assertEquals(Arrays.asList("beta"), groups.get(1));
}
+ @Test
public void testGroups_partialMatch() {
mTrie.put(STORED_VAL, "a|(alpha)", "b|(beta)");
Integer retrieved;
@@ -140,9 +153,8 @@ public class RegexTrieTest extends TestCase {
assertEquals(Arrays.asList("beta"), groups.get(1));
}
- /**
- * Make sure that the wildcard functionality works
- */
+ /** Make sure that the wildcard functionality works */
+ @Test
public void testWildcard() {
mTrie.put(STORED_VAL, "a", null);
Integer retrieved;
@@ -165,6 +177,7 @@ public class RegexTrieTest extends TestCase {
* Make sure that if a wildcard and a more specific match could both match, that the more
* specific match takes precedence
*/
+ @Test
public void testWildcard_precedence() {
// Do one before and one after the wildcard to check for ordering effects
mTrie.put(STORED_VAL + 1, "a", "(b)");
@@ -196,6 +209,7 @@ public class RegexTrieTest extends TestCase {
* Verify a bugfix: make sure that no NPE results from calling #retrieve with a wildcard but
* without a place to retrieve captures.
*/
+ @Test
public void testWildcard_noCapture() throws NullPointerException {
mTrie.put(STORED_VAL, "a", null);
String[] key = new String[] {"a", "b", "c"};
@@ -205,6 +219,7 @@ public class RegexTrieTest extends TestCase {
// test passes if no exceptions were thrown
}
+ @Test
public void testMultiChild() {
mTrie.put(STORED_VAL + 1, "a", "b");
mTrie.put(STORED_VAL + 2, "a", "c");
@@ -217,8 +232,9 @@ public class RegexTrieTest extends TestCase {
}
/**
- * Make sure that {@link CompPattern#equals} works as expected. Shake a proverbial fist at Java
+ * Make sure that {@link CompPattern#equals} works as expected. Shake a proverbial fist at Java
*/
+ @Test
public void testCompPattern_equality() {
String regex = "regex";
Pattern p1 = Pattern.compile(regex);
@@ -229,19 +245,20 @@ public class RegexTrieTest extends TestCase {
CompPattern cpOther = new CompPattern(pOther);
// This is the problem with Pattern as implemented
- assertFalse(p1.equals(p2));
- assertFalse(p2.equals(p1));
+ assertNotEquals(p1, p2);
+ assertNotEquals(p2, p1);
// Make sure that wrapped patterns with the same regex are considered equivalent
- assertTrue(cp2.equals(p1));
- assertTrue(cp2.equals(p2));
- assertTrue(cp2.equals(cp1));
+ assertEquals(cp2, p1);
+ assertEquals(cp2, p1);
+ assertEquals(cp2, cp1);
// And make sure that wrapped patterns with different regexen are still considered different
- assertFalse(cp2.equals(pOther));
- assertFalse(cp2.equals(cpOther));
+ assertNotEquals(cp2, pOther);
+ assertNotEquals(cp2, cpOther);
}
+ @Test
public void testCompPattern_hashmap() {
HashMap<CompPattern, Integer> map = new HashMap<CompPattern, Integer>();
String regex = "regex";