diff options
author | Eric Rowe <erowe@google.com> | 2014-09-30 15:36:03 -0700 |
---|---|---|
committer | Eric Rowe <erowe@google.com> | 2014-09-30 15:36:03 -0700 |
commit | 57560505cf7012b9783902cb55d143e9bdecd47b (patch) | |
tree | 8b2c1fe627ec9cbeaa5034c86c86458000b9705b | |
parent | 39451c5b979db78e8b3149a078339fae7241c681 (diff) | |
download | loganalysis-57560505cf7012b9783902cb55d143e9bdecd47b.tar.gz |
Loosen restrictions on command line format
Change-Id: Ic16907e7e98ee1a9be9b0a75b9cccffee6c75441
3 files changed, 21 insertions, 10 deletions
diff --git a/src/com/android/loganalysis/parser/BugreportParser.java b/src/com/android/loganalysis/parser/BugreportParser.java index 604ec1a..09ba78d 100644 --- a/src/com/android/loganalysis/parser/BugreportParser.java +++ b/src/com/android/loganalysis/parser/BugreportParser.java @@ -69,7 +69,7 @@ public class BugreportParser extends AbstractSectionParser { * Matches: Command line: key=value key=value */ private static final Pattern COMMAND_LINE = Pattern.compile( - "Command line:((\\s+[^\\s=]+=[^\\s]*)*)\\s*"); + "Command line: (.*)"); private IParser mBugreportParser = new IParser() { @Override @@ -87,11 +87,14 @@ public class BugreportParser extends AbstractSectionParser { if (m.matches()) { String argString = m.group(1).trim(); if (!argString.isEmpty()) { - String[] pairs = argString.split("\\s+"); - for (String pair : pairs) { - System.out.println(pair); - String[] keyValue = pair.split("=", 2); - mCommandLine.put(keyValue[0], keyValue[1]); + String[] args = argString.split("\\s+"); + for (String arg : args) { + String[] keyValue = arg.split("=", 2); + if (keyValue.length == 2) { + mCommandLine.put(keyValue[0], keyValue[1]); + } else { + mCommandLine.put(keyValue[0], null); + } } } } diff --git a/tests/src/com/android/loganalysis/parser/BugreportParserFuncTest.java b/tests/src/com/android/loganalysis/parser/BugreportParserFuncTest.java index 2a456d2..b759e98 100644 --- a/tests/src/com/android/loganalysis/parser/BugreportParserFuncTest.java +++ b/tests/src/com/android/loganalysis/parser/BugreportParserFuncTest.java @@ -77,6 +77,8 @@ public class BugreportParserFuncTest extends TestCase { assertNotNull(bugreport.getSystemLog().getStartTime()); assertNotNull(bugreport.getSystemLog().getStopTime()); + assertNotNull(bugreport.getLastKmsg()); + System.out.println(String.format("Stats for bugreport:\n" + " Time: %s\n" + " System Properties: %d items\n" + @@ -85,7 +87,8 @@ public class BugreportParserFuncTest extends TestCase { " System Log:\n" + " Start time: %s\n" + " Stop time: %s\n" + - " %d ANR(s), %d Java Crash(es), %d Native Crash(es)", + " %d ANR(s), %d Java Crash(es), %d Native Crash(es)\n" + + " %d Kernel Reset(s), %d Kernel Error(s)", bugreport.getTime(), bugreport.getSystemProps().size(), bugreport.getMemInfo().size(), @@ -94,7 +97,9 @@ public class BugreportParserFuncTest extends TestCase { bugreport.getSystemLog().getStopTime().toString(), bugreport.getSystemLog().getAnrs().size(), bugreport.getSystemLog().getJavaCrashes().size(), - bugreport.getSystemLog().getNativeCrashes().size())); + bugreport.getSystemLog().getNativeCrashes().size(), + bugreport.getLastKmsg().getMiscEvents(KernelLogParser.KERNEL_RESET).size(), + bugreport.getLastKmsg().getMiscEvents(KernelLogParser.KERNEL_ERROR).size())); } } diff --git a/tests/src/com/android/loganalysis/parser/BugreportParserTest.java b/tests/src/com/android/loganalysis/parser/BugreportParserTest.java index 1eedf46..a17493e 100644 --- a/tests/src/com/android/loganalysis/parser/BugreportParserTest.java +++ b/tests/src/com/android/loganalysis/parser/BugreportParserTest.java @@ -208,9 +208,12 @@ public class BugreportParserTest extends TestCase { assertEquals("value=withequals", bugreport.getCommandLine().get("key1")); assertEquals("", bugreport.getCommandLine().get("key2")); - lines = Arrays.asList("Command line: key1=value=withequals key2= key3"); + lines = Arrays.asList("Command line: key1=value1 nonkey key2="); bugreport = new BugreportParser().parse(lines); - assertTrue(bugreport.getCommandLine().isEmpty()); + assertEquals(3, bugreport.getCommandLine().size()); + assertEquals("value1", bugreport.getCommandLine().get("key1")); + assertEquals("", bugreport.getCommandLine().get("key2")); + assertNull(bugreport.getCommandLine().get("nonkey")); } /** |