Commit graph

112 commits

Author SHA1 Message Date
Elliott Hughes
3e2b34136a Merge "Add OWNERS." am: 3289b9c928 am: 515c8fe572
am: aede8375fe

Change-Id: I28f7a8f3fa9c9837f4043768e70c0d985ed95abd
2017-12-08 01:29:20 +00:00
Elliott Hughes
3289b9c928 Merge "Add OWNERS." 2017-12-07 23:21:26 +00:00
Elliott Hughes
693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
James Hawkins
f0ca3729ff Merge "bootstat: Add more boot reasons." am: 4aba23831d am: bb69ab2010
am: 020dcbc20f

Change-Id: Iabe2e177c580f42f655b63f4b52c905542d33c27
2017-12-05 01:25:19 +00:00
James Hawkins
00433a2305 bootstat: Add more boot reasons.
Bug: none
Test: none
Change-Id: I4cc6e2e39b6c5954387006d48f2119211fa37dd5
2017-12-04 14:20:21 -08:00
James Hawkins
5b2b45e520 Merge "bootstat: Add four more boot reasons." am: 20a410b575 am: 9810df82a8
am: 701f2a7e80

Change-Id: I6eee3790433c1a894e77c83e0e2641731f81d4f6
2017-12-01 19:57:43 +00:00
James Hawkins
f4444f058c bootstat: Add four more boot reasons.
Bug: none
Test: none
Change-Id: Ifd62e3a8bb6142e89fcde819eab1caba3d7933b7
2017-11-30 15:01:40 -08:00
James Hawkins
4f07e909dc Merge "bootstat: Three more boot reasons." am: 5470a12513 am: 0a86c0c1ed
am: 9a8b18210b

Change-Id: Ia0090c56cef4b4a014cfc9106a03e5094fd47353
2017-11-30 18:06:34 +00:00
James Hawkins
5f85f8354b bootstat: Three more boot reasons.
Bug: none
Test: none
Change-Id: I37b6ed6ce73f403aa5f9db2c0234e9dc4c0f7c01
2017-11-29 14:30:06 -08:00
James Hawkins
b52ba1de8b Merge "bootstat: Add a few more bootreasons." am: b623389421 am: 6c640a1617
am: 0ea0130d31

Change-Id: I115c593e6e71bf8597d790d85921d66d40792a1a
2017-11-29 20:05:54 +00:00
James Hawkins
b623389421 Merge "bootstat: Add a few more bootreasons." 2017-11-29 19:29:54 +00:00
James Hawkins
74b1758cad bootstat: Add a few more bootreasons.
Bug: none
Test: none
Change-Id: I9b482e642a9eec26670118a265046194f3cc2a7a
2017-11-28 15:20:44 -08:00
Mark Salyzyn
aa9f6ee9ee Merge "bootstat: kernel_panic test w/o bootloader or pstore support" am: 70fda27eb2 am: 6c9f88863c
am: ae3bbc2fa2

Change-Id: Ied94a5c7a49d8cf252cca1c98624f504e8e82f2a
2017-11-21 17:24:36 +00:00
Mark Salyzyn
547063eab6 bootstat: kernel_panic test w/o bootloader or pstore support
If the platform has no bootloader or pstore support, kernel_panic
test should fail if the results are not correct. Drop skipping of
failed test if pstore support is lacking.

If device demonstrably has pstore content support, the result must
be exacting kernel_panic,sysrq. Otherwise accept the less precise
result.

Test: On hikey960 (which currently lacks reliable pstore, or a
      compliant bootloader reporting bootreason), expect failure of:
      system/core/bootstat/boot_reason_test.sh kernel_panic
Bug: 63736262
Change-Id: I071a2a9c00dc522ec037c8a8997fea524d17e6e4
2017-11-20 12:18:09 -08:00
Ivan Lozano
045064371e Fix sanitizer errors in bootstat.cpp.
Integer overflow sanitized builds are throwing an error on the while
loop decrement in the rfind function. This refactors the loop to prevent
decrementing the value on the final iteration.

Test: Compiled and device boots without runtime error.
Bug: 30969751
Change-Id: Ice4532cce933062b3c14adf2d9749cfdea4ad84c
2017-11-08 08:23:23 -08:00
James Hawkins
8ac79bc820 bootstat: Add another boot reason.
Bug: None
Test: None
Change-Id: I865a12e9c8833c4a345284181aa1812be3eddadd
2017-10-31 10:07:34 -07:00
Mark Salyzyn
e7c95fb34f bootstat: test: add error propagation for fastboot format userdata
Test: system/core/bootstat/boot_reason_test.sh optional_factory_reset
Bug: 63736262
Change-Id: I8893df15ef802bb76c0795288df91d8463bfe3d1
2017-10-27 08:32:55 -07:00
Mark Salyzyn
293cb3b217 bootstat: handle a bad bit error rate issue with pstore
Create a private rfind that allows a fuzzy match based on a bit error
rate (BER) of 1 every 8 bits.  last kmsg is affected by pstore ramoops
backing that suffers from data corruption.  Add some additional
validation based on possible data corruption scenarios, as a noisy
match means higher chance of noisy data.

Noisy data notably can affect the battery level detection, but do not
typically result in false positives.  Battery level, or failure, is
the responsibility of the BatteryStats service, providing a positive
signal and strong device-independent algorithm.  The checking done in
bootstat is likely to be deprecated in favour of an API request to
BatteryStats once their algorithms deal with surprise outages due to
aging.

The kernel logging heuristic and BER fixup handily deals with a
prevalent issue where some bootloaders failure to properly notify us
of panics.  This is where the gains are noticed with this improvement.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I93b4210f12fb47c5c036f4d6eb4cafeee4896d35
2017-10-26 14:17:14 -07:00
Mark Salyzyn
747c0e6216 bootstat: better validation of battery level (shutdown,battery)
Replace simple strtoull with loop that ensures no leading zeros.
Restrict size of value buffer being checked as allocation was
going to end of retrieved buffer, which can cause unnecessary
memory pressure during boot.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: Ifdc1d4fd3a73794c001577024ce7cbfde9c25028
2017-10-26 14:17:14 -07:00
Mark Salyzyn
dafced93a5 bootstat: Do not allow unknown boot reasons to land in first field.
If we sniff an unknown boot reason from last kmsg, make sure it
has a "reboot," prefix.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: Ia1c401b8899d1f0c56bd4f5d8d2d19b7fc889a30
2017-10-26 14:14:40 -07:00
Mark Salyzyn
88d692c09e bootstat: move boot reason validation transformation policy into subroutine.
Allow for future policy adjustments.

SideEffects: None
Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I571fb7dafc6b80c75d2809a3da3f9b96784cef06
2017-10-26 14:11:04 -07:00
Mark Salyzyn
72a8ea3d3c bootstat: test: fix Its_Just_So_Hard_reboot
Add the test injection to known list, and deal with an error
propagation issue.

Test: system/core/bootstat/boot_reason_test.sh Its_Just_So_Hard_reboot
Bug: 63736262
Change-Id: I4799956978a8884c69c830fcedd7febd143651fd
2017-10-26 14:10:31 -07:00
Mark Salyzyn
c89f9da060 bootstat: add shutdown,thermal,battery
Test: system/core/bootreason/boot_reason_test.sh
Bug: 63736262
Change-Id: I30d6b5308fd8616eae31ad13e925d66c9fc07367
2017-10-25 15:45:49 -07:00
Mark Salyzyn
cabbe4ff35 bootstat: add reboot,2sec
Test: system/core/bootreason/boot_reason_test.sh
Bug: 63736262
Change-Id: Ie2e5872adb14e0979ff87eb4d2f57ab2849facd4
2017-10-25 15:45:49 -07:00
Mark Salyzyn
2a8e5cce33 bootstat: test: check ro.boot.bootreason in some tests
blind_reboot_test() did not report the ro.boot.bootreason value,
making it more difficult to diagnose failures.

Test: system/core/bootstat/boot_reason_test.sh cold warm hard
Bug: 63736262
Change-Id: I313cfef202b1e06c583b0b47cd5d0e0888a7dbe7
2017-10-25 15:45:49 -07:00
Mark Salyzyn
73691aafc2 bootstat: fix test regression (exec_background)
Deal with regression from 557a9d4054
where bootstat was moved to exec_background and actions delayed
to improve boot time.  Add a 1 second sleep rather than trying to
inspect the dmesg (debug only) for clues to the end of bootstat.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I87dfb6a07130112bf51c367632967efa53ea2534
2017-10-25 15:45:46 -07:00
Mark Salyzyn
bcf66ed699 bootstat: fix test regression (extra logging)
Deal with regression from 9a3870490a
where additional content is logged and should be ignored.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I70709ba5b00ea18a653ff8d1658556b7d4c48775
2017-10-25 15:40:56 -07:00
Treehugger Robot
a03c935e27 Merge "bootstat: Add more boot reasons found by logging in the wild." 2017-10-19 19:41:34 +00:00
James Hawkins
34073b583a bootstat: Add more boot reasons found by logging in the wild.
Bug: none
Test: none
Change-Id: I7e388326be44aeb3e6fdb79d2e173dc17eb8bc1f
2017-10-19 10:44:22 -07:00
Josh Gao
52315ae329 bootstat: remove extraneous android_logcat_destroy.
android_logcat_pclose already does that.

Bug: http://b/67960705
Test: mma
Change-Id: I03d06b10807e8a313c9654c2e1db36bfb59e3f99
2017-10-18 16:57:33 -07:00
Mark Salyzyn
244947e813 bootstat: test: duration fixes
misspelled duration_test in test_thermal_shutdown

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I5981fa899db84199aefb46c8741511e6889bc79c
2017-10-13 09:29:53 -07:00
Mark Salyzyn
9a3870490a bootstat: test: inject ro.boot.bootreason values
Adding a set of automated engineering unit tests with a strict list of
prerequisites.  Not meant for "user" builds.  Must have a crafted
bootloader that does not set the boot reason.  Only works on platforms
where the bootloader either by accident or specifically does not set
the ro.boot.bootreason via kernel command line configuration
androidboot.bootreason=.  If the tests do not have the prerequisites,
the test will report success, but with protest.

These new tests should work on current Hikey and Hikey960 bootloaders
but could very well become obsolete if those platform bootloaders
start setting the boot reason.

We do not want a platform solution as it could allow a third party to
override the bootloader boot reason.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I1793184a8484b83e1d9077475bc65af9816dadf7
2017-10-11 13:48:33 -07:00
Mark Salyzyn
bb52cbf35d Merge "bootstat: test: refine reported test durations" 2017-10-11 20:33:05 +00:00
Mark Salyzyn
444e3a9f74 Merge "bootstat: Add some reserved sys.boot.reason values to enumeration" 2017-10-11 20:32:00 +00:00
Mark Salyzyn
2450cb1a30 bootstat: test: refine reported test durations
Use actual test durations to refine future duration estimates.
Better estimates are cosmetic, but lend confidence to the test
results.

SideEffects: none
Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I49143b78a6dc6fb21838a3d6c70b7eb5a8b4cba5
2017-10-11 10:56:54 -07:00
Mark Salyzyn
243fa29804 bootstat: Add some reserved sys.boot.reason values to enumeration
Add cold,powerkey, warm,s3_wakeup and hard,hw_reset so that
sys.boot.reason values can also be enumerated.  Also add
some reserved speculative entries associated with forced
suspend to RAM and DISK; shutdown,suspend and shutdown,hibernate
respectively.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 67636061
Change-Id: Ic43523748e6006aaca882f8eec7c1f0c08431bd8
2017-10-11 10:56:42 -07:00
James Hawkins
25f7122512 bootstat: Special case logging for empty boot reason.
Empty boot reason is mostly unexpected but may take up the bulk of
unknown reported boot reason values.

Bug: none
Test: none
Change-Id: I9978658c2b052d5cf5d28299861b0d1125ba9fc0
2017-10-10 16:37:05 -07:00
Mark Salyzyn
6290982ee3 init+bootstat: reduce last reboot reason to canonical alias
To make parsing easier for last reboot reason.  This also ensures that
last boot reason matches the content that is typically returned by the
bootloader or in turn landed in the canonical system boot reason.

Simplify parsing in bootstat.  Adjust and fix boot_reason_test.sh for
new reality.  Allow boot reason tests battery and kernel_panic to pass
if device does not support pstore (empty before and after the test).
If device somehow landed in fastboot mode while waiting for the
display, issue a fastboot reboot to move the test along.  Some cleanup
and standardization changes to the test script.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I97d5467c0b4a6d65df3525f1a2d0051db813d5ad
2017-10-10 09:37:59 -07:00
Mark Salyzyn
0af71a5327 bootstat: system_boot_reason does not handle reboot_<reason> case
Heuristic would translate reboot_<reason> to reboot._<reason>. Add
checking/squashing for leading comma (,) _or_ underscore (_).

Test: compile
Bug: 63736262
Change-Id: I7ef4930ec8c064a8151183ac08d292931a8584c8
2017-10-05 14:42:08 -07:00
Mark Salyzyn
161b8626bd init: report shutdown,container for sigterm of init
Change HandleSigtermSignal() handler to report shutdown,container. Add
the new reason to bootstat.  Remove log stutter as
HandlPowerctlMessage will also do a LOG(INFO) reporting
shutdown,container as reason.

Sending SIGTERM to init is to allow a host OS to ask an Android
Container instance to shutdown.  The temptation is to report
shutdown,sigterm but that does not accurately describe the usage
scenario.

Test: compile
Bug: 63736262
Change-Id: I3c5798921bdbef5d2689ad22a2e8103741b570b4
2017-09-27 09:10:00 -07:00
Mark Salyzyn
9033bf5a2e bootstat: Add reboot,userrequested
Result of holding power button down and hitting restart.

Test: compile
Bug: 63736262
Change-Id: I271bdf135cece5fd9dc9e60ddf8add595ed3da4c
2017-09-21 11:30:29 -07:00
Mark Salyzyn
a16e437e9d bootstat: validate last kmsg and bootreason content more carefully
Establish a tighter trust relationship with digitization of the
battery level.  Validate the reboot reason collected from the last
kmsg.  Validate the last reboot reason before using for enhancing
system reboot reason.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63636262
Change-Id: I45fbac4a33c09295cda89de3b73c93a884033e3b
2017-09-20 11:28:02 -07:00
Mark Salyzyn
14b1e6d63d bootstat: clang-format rebase
Code style has drifted too far from our current clang-format
settings.

Test: compile
Side-Effects: none
Bug: 63736262
Change-Id: Ie390459db123cfadf09aa06c8dafb1ae69a72af8
2017-09-20 11:27:56 -07:00
Mark Salyzyn
6461089bf8 bootstat: refine kernel panic details
If bootloader reports kernel_panic, gives us permission for a
deeper check of which kind occurred.  Resolve a problem with
some kernels that do not have the 'sysrq: SysRq :' log stutter.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: Idb8978de7a4f4e3c671c6ab7efc5ebe841f7bbd8
2017-09-19 16:30:05 -07:00
Mark Salyzyn
557a9d4054 bootstat: reduce overall boot time
Run bootstat as a oneshot service rather than as a series of inline
exec commands.  exec commands impact boot time.

Test: cts-tradefed run cts-dev --module CtsBootStatsTestCases
      system/core/bootstat/boot_reason_test.sh all
         (make sure it filters out new init reports)
Bug: 65736247
Change-Id: Ic9d509a8cbee4bc1e278081de1001e25ae0915fd
2017-09-19 07:36:34 -07:00
Mark Salyzyn
8a30fcabcb bootstat: battery test fails on QC devices
Send the message multiple times into the last dmesg log so that one
may be picked up without data corruption.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: Ie42ad1940b1eb4915e4cf6cc61815d0275a70ffe
2017-09-19 07:36:34 -07:00
Mark Salyzyn
25246ddfe6 bootstat: bootloader stat files misspelled
Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I6620c9965f4af8b6a3829f1f4cdcc9b691471a71
2017-09-19 14:34:42 +00:00
Mark Salyzyn
08b0256ea1 bootstat: reboot cold, warm and hard tests failed
If the bootloader insists on reporting reboot for cold, warm and
hard, we need to reconstruct canonical reason from the
persist.sys.boot.reason property.

Some log lines contained bootstate, letting their noise through
during testing, changed regex to look for bootstat[^e].

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I3788c6cf8aca7fc73dd01bf95acb596d18ed7ee4
2017-09-18 21:03:10 +00:00
James Hawkins
5240f204ed bootstat: Log the ro.boot.bootreason property through the new platform_reason Tron field.
Bug: 63584589
Test: none
Change-Id: Ifd6f3d4432d764b5ffc7db10dec5e573214f7c97
2017-09-15 16:01:57 -07:00
Mark Salyzyn
277eca138b adb: reboot: last boot command default
For reboot [reboot_arg] requests via either reboot or adb reboot,
if reboot_arg is empty then report "shell" or "adb" respectively.

Test: boot_reason_test.sh shell_reboot adb_reboot
Bug: 63736262
Change-Id: Ie613d9e62db6a705885e4e7520aede27af3aa1b9
2017-09-12 12:24:02 -07:00