Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loganalysis
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
tools
loganalysis
Commits
21a5f6af
Commit
21a5f6af
authored
9 years ago
by
Eric Rowe
Browse files
Options
Downloads
Patches
Plain Diff
Add support for ro.boot.bootreason in parsing
Bug: 25597146 Change-Id: If8617d180fc37eb756e89bb24d7a2e12d9be9533
parent
c20ea281
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/com/android/loganalysis/parser/BugreportParser.java
+10
-3
10 additions, 3 deletions
src/com/android/loganalysis/parser/BugreportParser.java
tests/src/com/android/loganalysis/parser/BugreportParserTest.java
+58
-3
58 additions, 3 deletions
...c/com/android/loganalysis/parser/BugreportParserTest.java
with
68 additions
and
6 deletions
src/com/android/loganalysis/parser/BugreportParser.java
+
10
−
3
View file @
21a5f6af
...
...
@@ -57,7 +57,8 @@ public class BugreportParser extends AbstractSectionParser {
private
static
final
String
DUMPSYS_SECTION_REGEX
=
"------ DUMPSYS .*"
;
private
static
final
String
NOOP_SECTION_REGEX
=
"------ .* ------"
;
private
static
final
String
BOOTREASON
=
"androidboot.bootreason"
;
private
static
final
String
BOOTREASON_PROP
=
"ro.boot.bootreason"
;
private
static
final
String
BOOTREASON_KERNEL
=
"androidboot.bootreason"
;
/**
* Matches: == dumpstate: 2012-04-26 12:13:14
...
...
@@ -225,8 +226,14 @@ public class BugreportParser extends AbstractSectionParser {
lastKmsg
=
new
KernelLogItem
();
mBugreport
.
setLastKmsg
(
lastKmsg
);
}
if
(
mCommandLine
.
containsKey
(
BOOTREASON
))
{
String
bootreason
=
mCommandLine
.
get
(
BOOTREASON
);
String
bootreason
=
null
;
if
(
mBugreport
.
getSystemProps
()
!=
null
&&
mBugreport
.
getSystemProps
().
containsKey
(
BOOTREASON_PROP
))
{
bootreason
=
mBugreport
.
getSystemProps
().
get
(
BOOTREASON_PROP
);
}
else
if
(
mCommandLine
.
containsKey
(
BOOTREASON_KERNEL
))
{
bootreason
=
mCommandLine
.
get
(
BOOTREASON_KERNEL
);
}
if
(
bootreason
!=
null
)
{
Matcher
m
=
KernelLogParser
.
BAD_BOOTREASONS
.
matcher
(
bootreason
);
if
(
m
.
matches
())
{
MiscKernelLogItem
item
=
new
MiscKernelLogItem
();
...
...
This diff is collapsed.
Click to expand it.
tests/src/com/android/loganalysis/parser/BugreportParserTest.java
+
58
−
3
View file @
21a5f6af
...
...
@@ -17,6 +17,7 @@ package com.android.loganalysis.parser;
import
com.android.loganalysis.item.BugreportItem
;
import
com.android.loganalysis.item.IItem
;
import
com.android.loganalysis.item.MiscKernelLogItem
;
import
com.android.loganalysis.util.ArrayUtil
;
import
junit.framework.TestCase
;
...
...
@@ -228,9 +229,9 @@ public class BugreportParserTest extends TestCase {
}
/**
* Test
* Test
that a normal boot triggers a normal boot event and no unknown reason.
*/
public
void
testParse_bootreason_good
()
{
public
void
testParse_bootreason_
kernel_
good
()
{
List
<
String
>
lines
=
Arrays
.
asList
(
"========================================================"
,
"== dumpstate: 1999-01-01 02:03:04"
,
...
...
@@ -245,7 +246,10 @@ public class BugreportParserTest extends TestCase {
assertEquals
(
"NORMAL_REBOOT"
,
bugreport
.
getLastKmsg
().
getEvents
().
get
(
0
).
getCategory
());
}
public
void
testParse_bootreason_bad
()
{
/**
* Test that a kernel reset boot triggers a kernel reset event and no unknown reason.
*/
public
void
testParse_bootreason_kernel_bad
()
{
List
<
String
>
lines
=
Arrays
.
asList
(
"========================================================"
,
"== dumpstate: 1999-01-01 02:03:04"
,
...
...
@@ -260,12 +264,56 @@ public class BugreportParserTest extends TestCase {
assertEquals
(
"KERNEL_RESET"
,
bugreport
.
getLastKmsg
().
getEvents
().
get
(
0
).
getCategory
());
}
/**
* Test that a normal boot triggers a normal boot event and no unknown reason.
*/
public
void
testParse_bootreason_prop_good
()
{
List
<
String
>
lines
=
Arrays
.
asList
(
"========================================================"
,
"== dumpstate: 1999-01-01 02:03:04"
,
"========================================================"
,
"------ SYSTEM PROPERTIES ------"
,
"[ro.boot.bootreason]: [reboot]"
,
""
);
BugreportItem
bugreport
=
new
BugreportParser
().
parse
(
lines
);
assertNotNull
(
bugreport
.
getLastKmsg
());
assertEquals
(
1
,
bugreport
.
getLastKmsg
().
getEvents
().
size
());
assertEquals
(
"Last boot reason: reboot"
,
bugreport
.
getLastKmsg
().
getEvents
().
get
(
0
).
getStack
());
assertEquals
(
"NORMAL_REBOOT"
,
bugreport
.
getLastKmsg
().
getEvents
().
get
(
0
).
getCategory
());
}
/**
* Test that a kernel reset boot triggers a kernel reset event and no unknown reason.
*/
public
void
testParse_bootreason_prop_bad
()
{
List
<
String
>
lines
=
Arrays
.
asList
(
"========================================================"
,
"== dumpstate: 1999-01-01 02:03:04"
,
"========================================================"
,
"------ SYSTEM PROPERTIES ------"
,
"[ro.boot.bootreason]: [hw_reset]"
,
""
);
BugreportItem
bugreport
=
new
BugreportParser
().
parse
(
lines
);
assertNotNull
(
bugreport
.
getLastKmsg
());
assertEquals
(
1
,
bugreport
.
getLastKmsg
().
getEvents
().
size
());
assertEquals
(
"Last boot reason: hw_reset"
,
bugreport
.
getLastKmsg
().
getEvents
().
get
(
0
).
getStack
());
assertEquals
(
"KERNEL_RESET"
,
bugreport
.
getLastKmsg
().
getEvents
().
get
(
0
).
getCategory
());
}
/**
* Test that a kernel panic in the last kmsg and a kernel panic only triggers one kernel reset.
*/
public
void
testParse_bootreason_duplicate
()
{
List
<
String
>
lines
=
Arrays
.
asList
(
"========================================================"
,
"== dumpstate: 1999-01-01 02:03:04"
,
"========================================================"
,
"Command line: androidboot.bootreason=hw_reset"
,
"------ SYSTEM PROPERTIES ------"
,
"[ro.boot.bootreason]: [hw_reset]"
,
""
,
"------ LAST KMSG (/proc/last_kmsg) ------"
,
"[ 0.000000] Initializing cgroup subsys cpu"
,
"[ 16.203491] Kernel panic"
,
...
...
@@ -430,6 +478,10 @@ public class BugreportParserTest extends TestCase {
assertNull
(
bugreport
.
getSystemProps
());
assertNull
(
bugreport
.
getTop
());
assertNotNull
(
bugreport
.
getLastKmsg
());
List
<
MiscKernelLogItem
>
events
=
bugreport
.
getLastKmsg
().
getMiscEvents
(
KernelLogParser
.
KERNEL_RESET
);
assertEquals
(
events
.
size
(),
1
);
assertEquals
(
events
.
get
(
0
).
getStack
(),
"Unknown reason"
);
lines
=
Arrays
.
asList
(
"========================================================"
,
...
...
@@ -463,6 +515,9 @@ public class BugreportParserTest extends TestCase {
assertNull
(
bugreport
.
getSystemProps
());
assertNull
(
bugreport
.
getTop
());
assertNotNull
(
bugreport
.
getLastKmsg
());
events
=
bugreport
.
getLastKmsg
().
getMiscEvents
(
KernelLogParser
.
KERNEL_RESET
);
assertEquals
(
events
.
size
(),
1
);
assertEquals
(
events
.
get
(
0
).
getStack
(),
"Unknown reason"
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment