Copy the corresponding code in update_engine to dlcservice along with unittest.
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform2/+/c524c614ccd378be03abc3c85627d822399234d2 commit c524c614ccd378be03abc3c85627d822399234d2 Author: Xiaochu Liu <xiaochu@chromium.org> Date: Wed Oct 31 19:42:32 2018 dlcservice: support deciding current boot slot The functions are copied from src/aosp/system/update_engine/boot_control_chromeos.* and src/aosp/system/update_engine/common/utils.h along with the unittests. We duplicate the code in update_engine mainly because update_engine is a shared code base (aosp, chromium os) and we do not have a great way to share in this case (libbrillo is an overkill and aosp merging in update_engine could be troublesome). BUG= chromium:898254 TEST=unittest Change-Id: I7214d963d1d392599d86dec3426e9477ddd202ba Reviewed-on: https://chromium-review.googlesource.com/1299296 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Xiaochu Liu <xiaochu@chromium.org> Reviewed-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Xiaochu Liu <xiaochu@chromium.org> [add] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/boot_device.cc [add] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/boot_device_test.cc [modify] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/dlc_service_dbus_adaptor.cc [add] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/boot_slot_test.cc [modify] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/dlc_service_dbus_adaptor.h [modify] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/dlc_service.cc [add] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/boot_slot.h [add] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/mock_boot_device.h [add] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/boot_slot.cc [add] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/boot_device.h [modify] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/BUILD.gn [modify] https://crrev.com/c524c614ccd378be03abc3c85627d822399234d2/dlcservice/dlc_service_dbus_adaptor_test.cc
Comment 1 by xiaochu@chromium.org
, Oct 23