Skip to content
Snippets Groups Projects
Commit 5775f059 authored by Gopinath Elanchezhian's avatar Gopinath Elanchezhian Committed by Gerrit Code Review
Browse files

Merge "Parse "Wait for property" duration from dmesg."

parents 149fa628 b2a29b81
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ public class DmesgParser implements IParser { ...@@ -42,6 +42,7 @@ public class DmesgParser implements IParser {
private static final String ACTION = "ACTION"; private static final String ACTION = "ACTION";
private static final String DURATION = "DURATION"; private static final String DURATION = "DURATION";
private static final String UEVENTD = "ueventd"; private static final String UEVENTD = "ueventd";
private static final String INIT = "init";
// Matches: [ 14.822691] init: // Matches: [ 14.822691] init:
private static final String SERVICE_PREFIX = String.format("^\\[\\s+(?<%s>.*)\\] init:\\s+", private static final String SERVICE_PREFIX = String.format("^\\[\\s+(?<%s>.*)\\] init:\\s+",
...@@ -94,6 +95,11 @@ public class DmesgParser implements IParser { ...@@ -94,6 +95,11 @@ public class DmesgParser implements IParser {
private static final Pattern UEVENTD_STAGE_INFO = Pattern.compile( private static final Pattern UEVENTD_STAGE_INFO = Pattern.compile(
String.format("%s%s", UEVENTD_PREFIX, STAGE_SUFFIX)); String.format("%s%s", UEVENTD_PREFIX, STAGE_SUFFIX));
private static final String PROPERTY_SUFFIX= String.format(
"(?<%s>.*)\\s+took\\s+(?<%s>.*)ms$", STAGE, DURATION);
// Matches [ 7.270487] init: Wait for property 'apexd.status=ready' took 230ms
private static final Pattern WAIT_FOR_PROPERTY_INFO = Pattern.compile(
String.format("%s%s", SERVICE_PREFIX, PROPERTY_SUFFIX));
private DmesgItem mDmesgItem = new DmesgItem(); private DmesgItem mDmesgItem = new DmesgItem();
...@@ -142,6 +148,7 @@ public class DmesgParser implements IParser { ...@@ -142,6 +148,7 @@ public class DmesgParser implements IParser {
* @param line individual line of the dmesg log * @param line individual line of the dmesg log
*/ */
private void parse(String line) { private void parse(String line) {
if (parseServiceInfo(line)) { if (parseServiceInfo(line)) {
return; return;
} }
...@@ -210,7 +217,17 @@ public class DmesgParser implements IParser { ...@@ -210,7 +217,17 @@ public class DmesgParser implements IParser {
stageInfoItem.setDuration((long) (Double.parseDouble( stageInfoItem.setDuration((long) (Double.parseDouble(
match.group(DURATION)) * 1000)); match.group(DURATION)) * 1000));
mDmesgItem.addStageInfoItem(stageInfoItem); mDmesgItem.addStageInfoItem(stageInfoItem);
return true;
}
if((match = matches(WAIT_FOR_PROPERTY_INFO, line)) != null) {
DmesgStageInfoItem stageInfoItem = new DmesgStageInfoItem();
stageInfoItem.setStageName(String.format("%s_%s", INIT, match.group(STAGE)));
stageInfoItem.setDuration((long) (Double.parseDouble(
match.group(DURATION))));
mDmesgItem.addStageInfoItem(stageInfoItem);
return true;
} }
return false; return false;
} }
......
...@@ -40,6 +40,7 @@ public class DmesgParserTest extends TestCase { ...@@ -40,6 +40,7 @@ public class DmesgParserTest extends TestCase {
private static final String NETD = "netd"; private static final String NETD = "netd";
private static final String[] LINES = private static final String[] LINES =
new String[] { new String[] {
"[ 2.471163] init: Wait for property 'apexd.status=ready' took 403ms",
"[ 3.786943] ueventd: Coldboot took 0.701291 seconds", "[ 3.786943] ueventd: Coldboot took 0.701291 seconds",
"[ 22.962730] init: starting service 'bootanim'...", "[ 22.962730] init: starting service 'bootanim'...",
"[ 23.252321] init: starting service 'netd'...", "[ 23.252321] init: starting service 'netd'...",
...@@ -96,7 +97,7 @@ public class DmesgParserTest extends TestCase { ...@@ -96,7 +97,7 @@ public class DmesgParserTest extends TestCase {
assertEquals("Service info items list size should be 2", 2, assertEquals("Service info items list size should be 2", 2,
dmesgParser.getServiceInfoItems().size()); dmesgParser.getServiceInfoItems().size());
assertEquals("Stage info items list size should be 2",2, assertEquals("Stage info items list size should be 3",3,
dmesgParser.getStageInfoItems().size()); dmesgParser.getStageInfoItems().size());
assertEquals("Action info items list size should be 9",9, assertEquals("Action info items list size should be 9",9,
dmesgParser.getActionInfoItems().size()); dmesgParser.getActionInfoItems().size());
...@@ -116,7 +117,7 @@ public class DmesgParserTest extends TestCase { ...@@ -116,7 +117,7 @@ public class DmesgParserTest extends TestCase {
dmesgParser.parseInfo(bufferedReader); dmesgParser.parseInfo(bufferedReader);
assertEquals("Service info items list size should be 2", 2, assertEquals("Service info items list size should be 2", 2,
dmesgParser.getServiceInfoItems().size()); dmesgParser.getServiceInfoItems().size());
assertEquals("Stage info items list size should be 2", 2, assertEquals("Stage info items list size should be 3", 3,
dmesgParser.getStageInfoItems().size()); dmesgParser.getStageInfoItems().size());
assertEquals("Action info items list size should be 9",9, assertEquals("Action info items list size should be 9",9,
dmesgParser.getActionInfoItems().size()); dmesgParser.getActionInfoItems().size());
...@@ -197,7 +198,7 @@ public class DmesgParserTest extends TestCase { ...@@ -197,7 +198,7 @@ public class DmesgParserTest extends TestCase {
dmesgParser.parseStageInfo(line); dmesgParser.parseStageInfo(line);
} }
List<DmesgStageInfoItem> stageInfoItems = dmesgParser.getStageInfoItems(); List<DmesgStageInfoItem> stageInfoItems = dmesgParser.getStageInfoItems();
assertEquals(2, stageInfoItems.size()); assertEquals(3, stageInfoItems.size());
assertEquals(EXPECTED_STAGE_INFO_ITEMS, stageInfoItems); assertEquals(EXPECTED_STAGE_INFO_ITEMS, stageInfoItems);
} }
...@@ -234,6 +235,7 @@ public class DmesgParserTest extends TestCase { ...@@ -234,6 +235,7 @@ public class DmesgParserTest extends TestCase {
private static List<DmesgStageInfoItem> getExpectedStageInfoItems() { private static List<DmesgStageInfoItem> getExpectedStageInfoItems() {
return Arrays.asList( return Arrays.asList(
new DmesgStageInfoItem("init_Wait for property 'apexd.status=ready'", null, 403L),
new DmesgStageInfoItem("ueventd_Coldboot", null, 701L), new DmesgStageInfoItem("ueventd_Coldboot", null, 701L),
new DmesgStageInfoItem("first", 41665L, null)); new DmesgStageInfoItem("first", 41665L, null));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment