Commit 45e9a3c2 authored by Zach Kirschenbaum's avatar Zach Kirschenbaum Committed by Chromium LUCI CQ

Reland "[fuchsia] handle RetrySystemUpdate reboot reason"

This reverts commit 0ec4e032.

Reason for revert: so in the reland, we can remove NOTREACHED

Original change's description:
> Revert "[fuchsia] handle RetrySystemUpdate reboot reason"
>
> This reverts commit 394a78b4.
>
> Reason for revert: this breaks something
>
> Original change's description:
> > [fuchsia] handle RetrySystemUpdate reboot reason
> >
> > In this change, we add support for RetrySystemUpdate. Also, we stop
> > mapping `RebootSource::OTA` to `StateControlRebootReason::SystemUpdate`
> > because reboots for system updates should only be called from
> > fuchsia.git -- the code we remove isn't being run anyway.
> >
> > BUG=fuchsia:64591
> > TEST=cast_reboot_unittests
> >
> > Change-Id: Ic15f86d31d3985d2fa5a2a3957c5ca61066cd476
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2600053
> > Reviewed-by: Sergey Volk <servolk@chromium.org>
> > Commit-Queue: Zach Kirschenbaum <zkbaum@google.com>
> > Cr-Commit-Position: refs/heads/master@{#838871}
>
> TBR=spang@chromium.org,servolk@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com,zkbaum@google.com
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: fuchsia:64591
> Change-Id: I9a2dd0fe105b1750c733925a8320a2f4e71cded2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611448
> Reviewed-by: Sergey Volk <servolk@chromium.org>
> Commit-Queue: Zach Kirschenbaum <zkbaum@google.com>
> Cr-Commit-Position: refs/heads/master@{#840361}

TBR=spang@chromium.org,servolk@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com,zkbaum@google.com

Bug: fuchsia:64591
Change-Id: I4d6fffa0df883dbb6dae6add7f8e81aedcd0a95c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611526
Commit-Queue: Zach Kirschenbaum <zkbaum@google.com>
Reviewed-by: default avatarSergey Volk <servolk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840604}
parent 710b3d87
......@@ -91,6 +91,9 @@ bool RebootShlib::RebootNow(RebootSource reboot_source) {
reason = StateControlRebootReason::USER_REQUEST;
break;
case RebootSource::OTA:
// We expect OTAs to be initiated by the platform via the
// fuchsia.hardware.power.statecontrol/Admin FIDL service. In case
// non-platform code wants to initiate OTAs too, we also support it here.
reason = StateControlRebootReason::SYSTEM_UPDATE;
break;
case RebootSource::OVERHEAT:
......@@ -175,6 +178,7 @@ RebootShlib::RebootSource RebootUtil::GetLastRebootSource() {
case RebootReason::USER_REQUEST:
return RebootShlib::RebootSource::API;
case RebootReason::SYSTEM_UPDATE:
case RebootReason::RETRY_SYSTEM_UPDATE:
return RebootShlib::RebootSource::OTA;
case RebootReason::HIGH_TEMPERATURE:
return RebootShlib::RebootSource::OVERHEAT;
......
......@@ -236,6 +236,24 @@ TEST_F(RebootFuchsiaTest, GetLastRebootSourceWithoutGranularReason) {
Eq(RebootShlib::RebootSource::SW_OTHER));
}
fuchsia::feedback::LastReboot GenerateLastReboot(bool graceful,
RebootReason reason) {
fuchsia::feedback::LastReboot last_reboot;
last_reboot.set_graceful(graceful);
last_reboot.set_reason(reason);
return last_reboot;
}
// RetrySystemUpdate must be handled separately because it does not work with
// the RebootFuchsiaParamTest family of tests. Those tests expect
// RebootSource::OTA to map to exactly one StateControlRebootReason, which is
// now not the case.
TEST_F(RebootFuchsiaTest, RebootReasonRetrySystemUpdateTranslatesFromFuchsia) {
SetLastReboot(GenerateLastReboot(true, RebootReason::RETRY_SYSTEM_UPDATE));
EXPECT_THAT(RebootUtil::GetLastRebootSource(),
Eq(RebootShlib::RebootSource::OTA));
}
class RebootFuchsiaParamTest : public RebootFuchsiaTest,
public ::testing::WithParamInterface<RebootReasonParam> {
public:
......@@ -249,12 +267,7 @@ TEST_P(RebootFuchsiaParamTest, RebootNowSendsFidlRebootReason) {
}
TEST_P(RebootFuchsiaParamTest, GetLastRebootSourceTranslatesReasonFromFuchsia) {
fuchsia::feedback::LastReboot last_reboot;
last_reboot.set_graceful(GetParam().graceful);
last_reboot.set_reason(GetParam().reason);
EXPECT_TRUE(last_reboot.has_graceful());
EXPECT_TRUE(last_reboot.has_reason());
SetLastReboot(std::move(last_reboot));
SetLastReboot(GenerateLastReboot(GetParam().graceful, GetParam().reason));
EXPECT_THAT(RebootUtil::GetLastRebootSource(), Eq(GetParam().source));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment