summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Rowe <erowe@google.com>2013-12-12 11:26:33 -0800
committerEric Rowe <erowe@google.com>2013-12-12 11:26:49 -0800
commit3b87b00dc86c8e35f35b715e1c8e732c1fcfd581 (patch)
treea10ee71b896eb74de054e14947e8f67046222887 /tests
parent342b8e510e060a4ba589bdc4290a14acf31de854 (diff)
downloadloganalysis-3b87b00dc86c8e35f35b715e1c8e732c1fcfd581.tar.gz
Stop parsing between reboot and new log.
Bug: 12104558 Change-Id: Ide5e8938e2452b5b653739480666229ed28203b3
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/loganalysis/parser/LogcatParserTest.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/src/com/android/loganalysis/parser/LogcatParserTest.java b/tests/src/com/android/loganalysis/parser/LogcatParserTest.java
index 4ae1460..bfc9297 100644
--- a/tests/src/com/android/loganalysis/parser/LogcatParserTest.java
+++ b/tests/src/com/android/loganalysis/parser/LogcatParserTest.java
@@ -431,6 +431,50 @@ public class LogcatParserTest extends TestCase {
}
/**
+ * Test that events while the device is rebooting are ignored.
+ */
+ public void testParse_reboot() throws ParseException {
+ List<String> lines = Arrays.asList(
+ "04-25 09:15:47.799 123 3082 I ShutdownThread: Rebooting, reason: null",
+ "04-25 09:55:47.799 3064 3082 E AndroidRuntime: java.lang.Exception",
+ "04-25 09:55:47.799 3064 3082 E AndroidRuntime: \tat class.method1(Class.java:1)",
+ "04-25 09:55:47.799 3064 3082 E AndroidRuntime: \tat class.method2(Class.java:2)",
+ "04-25 09:55:47.799 3064 3082 E AndroidRuntime: \tat class.method3(Class.java:3)");
+
+ LogcatItem logcat = new LogcatParser("2012").parse(lines);
+ assertNotNull(logcat);
+ assertEquals(parseTime("2012-04-25 09:15:47.799"), logcat.getStartTime());
+ assertEquals(parseTime("2012-04-25 09:55:47.799"), logcat.getStopTime());
+ assertEquals(0, logcat.getEvents().size());
+ }
+
+ /**
+ * Test that events while the device is rebooting are ignored, but devices after the reboot are
+ * captured.
+ */
+ public void testParse_reboot_resume() throws ParseException {
+ List<String> lines = Arrays.asList(
+ "04-25 09:15:47.799 123 3082 I ShutdownThread: Rebooting, reason: null",
+ "04-25 09:55:47.799 3064 3082 E AndroidRuntime: java.lang.Exception",
+ "04-25 09:55:47.799 3064 3082 E AndroidRuntime: \tat class.method1(Class.java:1)",
+ "04-25 09:55:47.799 3064 3082 E AndroidRuntime: \tat class.method2(Class.java:2)",
+ "04-25 09:55:47.799 3064 3082 E AndroidRuntime: \tat class.method3(Class.java:3)",
+ "logcat interrupted. May see duplicated content in log.--------- beginning of /dev/log/main",
+ "04-25 09:59:47.799 3064 3082 E AndroidRuntime: java.lang.Exception2",
+ "04-25 09:59:47.799 3064 3082 E AndroidRuntime: \tat class.method1(Class.java:1)",
+ "04-25 09:59:47.799 3064 3082 E AndroidRuntime: \tat class.method2(Class.java:2)",
+ "04-25 09:59:47.799 3064 3082 E AndroidRuntime: \tat class.method3(Class.java:3)");
+
+
+ LogcatItem logcat = new LogcatParser("2012").parse(lines);
+ assertNotNull(logcat);
+ assertEquals(parseTime("2012-04-25 09:15:47.799"), logcat.getStartTime());
+ assertEquals(parseTime("2012-04-25 09:59:47.799"), logcat.getStopTime());
+ assertEquals(1, logcat.getEvents().size());
+ assertEquals("java.lang.Exception2", logcat.getJavaCrashes().get(0).getException());
+ }
+
+ /**
* Test that the time logcat format can be parsed.
*/
public void testParse_time() throws ParseException {