Send an UMA metric when failed to boot into the new partition.

When a payload is successfully applied, the /other/ partition
is marked as valid and a reboot is needed, the reboot into this
new partition can fail due to several reasons. If than happens,
the firmware can rollback to the previous partition.

When this happens, this fix sends a new UMA metric with the
attempt number of this failing payload.

In order to test this functionality we need to fake the
utils::BootDevice() to emulate a reboot into the same or
a different partition. To achieve this, this function is
moved to a new "HardwareInterface" that can be faked
using the FakeHardware class that can hold similar hardware
related functions. Implementations and unittest were
refactored as needed.

BUG=chromium:243572
TEST=unittests

Change-Id: I1a4242df0bd61e2718ab881ead603b1d3705b877
Reviewed-on: https://gerrit.chromium.org/gerrit/61815
Commit-Queue: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
28 files changed
tree: 96986cc787b523a7decb100dec7de3f79218454c
  1. .gitignore
  2. 99-gpio-dutflag.rules
  3. action.h
  4. action_mock.h
  5. action_pipe.h
  6. action_pipe_unittest.cc
  7. action_processor.cc
  8. action_processor.h
  9. action_processor_mock.h
  10. action_processor_unittest.cc
  11. action_unittest.cc
  12. build
  13. bzip.cc
  14. bzip.h
  15. bzip_extent_writer.cc
  16. bzip_extent_writer.h
  17. bzip_extent_writer_unittest.cc
  18. certificate_checker.cc
  19. certificate_checker.h
  20. certificate_checker_mock.h
  21. certificate_checker_unittest.cc
  22. chrome_browser_proxy_resolver.cc
  23. chrome_browser_proxy_resolver.h
  24. chrome_browser_proxy_resolver_unittest.cc
  25. chrome_proxy_resolver.cc
  26. chrome_proxy_resolver.h
  27. chrome_proxy_resolver_unittest.cc
  28. clock.cc
  29. clock.h
  30. clock_interface.h
  31. connection_manager.cc
  32. connection_manager.h
  33. connection_manager_unittest.cc
  34. constants.cc
  35. constants.h
  36. cycle_breaker.cc
  37. cycle_breaker.h
  38. cycle_breaker_unittest.cc
  39. dbus_constants.h
  40. dbus_interface.h
  41. dbus_service.cc
  42. dbus_service.h
  43. delta_diff_generator.cc
  44. delta_diff_generator.h
  45. delta_diff_generator_unittest.cc
  46. delta_performer.cc
  47. delta_performer.h
  48. delta_performer_unittest.cc
  49. download_action.cc
  50. download_action.h
  51. download_action_unittest.cc
  52. error_code.h
  53. extent_mapper.cc
  54. extent_mapper.h
  55. extent_mapper_unittest.cc
  56. extent_ranges.cc
  57. extent_ranges.h
  58. extent_ranges_unittest.cc
  59. extent_writer.cc
  60. extent_writer.h
  61. extent_writer_unittest.cc
  62. fake_clock.h
  63. fake_hardware.cc
  64. fake_hardware.h
  65. file_descriptor.cc
  66. file_descriptor.h
  67. file_writer.cc
  68. file_writer.h
  69. file_writer_mock.h
  70. file_writer_unittest.cc
  71. filesystem_copier_action.cc
  72. filesystem_copier_action.h
  73. filesystem_copier_action_unittest.cc
  74. filesystem_iterator.cc
  75. filesystem_iterator.h
  76. filesystem_iterator_unittest.cc
  77. full_update_generator.cc
  78. full_update_generator.h
  79. full_update_generator_unittest.cc
  80. gen_coverage_html
  81. generate_delta_main.cc
  82. gpio_handler.cc
  83. gpio_handler.h
  84. gpio_handler_unittest.cc
  85. gpio_handler_unittest.h
  86. gpio_mock_file_descriptor.cc
  87. gpio_mock_file_descriptor.h
  88. gpio_mock_udev_interface.cc
  89. gpio_mock_udev_interface.h
  90. graph_types.h
  91. graph_utils.cc
  92. graph_utils.h
  93. graph_utils_unittest.cc
  94. hardware.cc
  95. hardware.h
  96. hardware_interface.h
  97. hardware_unittest.cc
  98. http_common.cc
  99. http_common.h
  100. http_fetcher.cc
  101. http_fetcher.h
  102. http_fetcher_unittest.cc
  103. inherit-review-settings-ok
  104. install_plan.cc
  105. install_plan.h
  106. integration_unittest.cc
  107. libcurl_http_fetcher.cc
  108. libcurl_http_fetcher.h
  109. LICENSE
  110. local_coverage_rate
  111. main.cc
  112. marshal.list
  113. metadata.cc
  114. metadata.h
  115. metadata_unittest.cc
  116. mock_connection_manager.h
  117. mock_dbus_interface.h
  118. mock_file_writer.h
  119. mock_gpio_handler.h
  120. mock_http_fetcher.cc
  121. mock_http_fetcher.h
  122. mock_payload_state.h
  123. mock_system_state.cc
  124. mock_system_state.h
  125. multi_range_http_fetcher.cc
  126. multi_range_http_fetcher.h
  127. omaha_hash_calculator.cc
  128. omaha_hash_calculator.h
  129. omaha_hash_calculator_unittest.cc
  130. omaha_request_action.cc
  131. omaha_request_action.h
  132. omaha_request_action_unittest.cc
  133. omaha_request_params.cc
  134. omaha_request_params.h
  135. omaha_request_params_unittest.cc
  136. omaha_response.h
  137. omaha_response_handler_action.cc
  138. omaha_response_handler_action.h
  139. omaha_response_handler_action_unittest.cc
  140. org.chromium.UpdateEngine.service
  141. payload_signer.cc
  142. payload_signer.h
  143. payload_signer_unittest.cc
  144. payload_state.cc
  145. payload_state.h
  146. payload_state_interface.h
  147. payload_state_unittest.cc
  148. postinstall_runner_action.cc
  149. postinstall_runner_action.h
  150. postinstall_runner_action_unittest.cc
  151. prefs.cc
  152. prefs.h
  153. prefs_interface.h
  154. prefs_mock.h
  155. prefs_unittest.cc
  156. proxy_resolver.cc
  157. proxy_resolver.h
  158. real_system_state.h
  159. run_unittests
  160. sample_omaha_v3_response.xml
  161. SConstruct
  162. setup_dev_packages
  163. simple_key_value_store.cc
  164. simple_key_value_store.h
  165. simple_key_value_store_unittest.cc
  166. subprocess.cc
  167. subprocess.h
  168. subprocess_unittest.cc
  169. system_state.cc
  170. system_state.h
  171. tarjan.cc
  172. tarjan.h
  173. tarjan_unittest.cc
  174. terminator.cc
  175. terminator.h
  176. terminator_unittest.cc
  177. test_http_server.cc
  178. test_utils.cc
  179. test_utils.h
  180. testrunner.cc
  181. topological_sort.cc
  182. topological_sort.h
  183. topological_sort_unittest.cc
  184. udev_interface.h
  185. unittest_key.pem
  186. unittest_key2.pem
  187. update_attempter.cc
  188. update_attempter.h
  189. update_attempter_mock.h
  190. update_attempter_unittest.cc
  191. update_check_scheduler.cc
  192. update_check_scheduler.h
  193. update_check_scheduler_unittest.cc
  194. update_engine.xml
  195. update_engine_client.cc
  196. update_metadata.proto
  197. UpdateEngine.conf
  198. utils.cc
  199. utils.h
  200. utils_unittest.cc
  201. WATCHLISTS
  202. zip_unittest.cc