Commit 394a78b4 authored by Zach Kirschenbaum's avatar Zach Kirschenbaum Committed by Chromium LUCI CQ

[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/+/2600053Reviewed-by: default avatarSergey Volk <servolk@chromium.org>
Commit-Queue: Zach Kirschenbaum <zkbaum@google.com>
Cr-Commit-Position: refs/heads/master@{#838871}
parent 8094efc8
......@@ -91,8 +91,10 @@ bool RebootShlib::RebootNow(RebootSource reboot_source) {
reason = StateControlRebootReason::USER_REQUEST;
break;
case RebootSource::OTA:
reason = StateControlRebootReason::SYSTEM_UPDATE;
break;
// We are only expecting OTAs initiated by the platform via the
// fuchsia.hardware.power.statecontrol/Admin FIDL service.
NOTREACHED();
return false;
case RebootSource::OVERHEAT:
reason = StateControlRebootReason::HIGH_TEMPERATURE;
break;
......@@ -175,6 +177,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;
......
......@@ -66,8 +66,6 @@ const RebootReasonParam kRebootReasonParams[] = {
// Graceful reboot reasons.
{RebootReason::USER_REQUEST, RebootShlib::RebootSource::API, true,
StateControlRebootReason::USER_REQUEST},
{RebootReason::SYSTEM_UPDATE, RebootShlib::RebootSource::OTA, true,
StateControlRebootReason::SYSTEM_UPDATE},
{RebootReason::HIGH_TEMPERATURE, RebootShlib::RebootSource::OVERHEAT, true,
StateControlRebootReason::HIGH_TEMPERATURE},
{RebootReason::SESSION_FAILURE, RebootShlib::RebootSource::SW_OTHER, true},
......@@ -236,6 +234,33 @@ TEST_F(RebootFuchsiaTest, GetLastRebootSourceWithoutGranularReason) {
Eq(RebootShlib::RebootSource::SW_OTHER));
}
TEST_F(RebootFuchsiaTest, RebootSourceOtaNotSupported) {
EXPECT_DEATH(RebootShlib::RebootNow(RebootShlib::RebootSource::OTA), "");
}
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;
}
// SystemUpdate-related reasons must be handled separately. Otherwise, they will
// fail RebootNowSendsFidlRebootReason because RebootNow panics when given
// RebootShlib::RebootSource::OTA.
TEST_F(RebootFuchsiaTest, RebootReasonSystemUpdate) {
SetLastReboot(GenerateLastReboot(true, RebootReason::SYSTEM_UPDATE));
EXPECT_THAT(RebootUtil::GetLastRebootSource(),
Eq(RebootShlib::RebootSource::OTA));
}
TEST_F(RebootFuchsiaTest, RebootReasonRetrySystemUpdate) {
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 +274,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