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) { ...@@ -91,8 +91,10 @@ bool RebootShlib::RebootNow(RebootSource reboot_source) {
reason = StateControlRebootReason::USER_REQUEST; reason = StateControlRebootReason::USER_REQUEST;
break; break;
case RebootSource::OTA: case RebootSource::OTA:
reason = StateControlRebootReason::SYSTEM_UPDATE; // We are only expecting OTAs initiated by the platform via the
break; // fuchsia.hardware.power.statecontrol/Admin FIDL service.
NOTREACHED();
return false;
case RebootSource::OVERHEAT: case RebootSource::OVERHEAT:
reason = StateControlRebootReason::HIGH_TEMPERATURE; reason = StateControlRebootReason::HIGH_TEMPERATURE;
break; break;
...@@ -175,6 +177,7 @@ RebootShlib::RebootSource RebootUtil::GetLastRebootSource() { ...@@ -175,6 +177,7 @@ RebootShlib::RebootSource RebootUtil::GetLastRebootSource() {
case RebootReason::USER_REQUEST: case RebootReason::USER_REQUEST:
return RebootShlib::RebootSource::API; return RebootShlib::RebootSource::API;
case RebootReason::SYSTEM_UPDATE: case RebootReason::SYSTEM_UPDATE:
case RebootReason::RETRY_SYSTEM_UPDATE:
return RebootShlib::RebootSource::OTA; return RebootShlib::RebootSource::OTA;
case RebootReason::HIGH_TEMPERATURE: case RebootReason::HIGH_TEMPERATURE:
return RebootShlib::RebootSource::OVERHEAT; return RebootShlib::RebootSource::OVERHEAT;
......
...@@ -66,8 +66,6 @@ const RebootReasonParam kRebootReasonParams[] = { ...@@ -66,8 +66,6 @@ const RebootReasonParam kRebootReasonParams[] = {
// Graceful reboot reasons. // Graceful reboot reasons.
{RebootReason::USER_REQUEST, RebootShlib::RebootSource::API, true, {RebootReason::USER_REQUEST, RebootShlib::RebootSource::API, true,
StateControlRebootReason::USER_REQUEST}, StateControlRebootReason::USER_REQUEST},
{RebootReason::SYSTEM_UPDATE, RebootShlib::RebootSource::OTA, true,
StateControlRebootReason::SYSTEM_UPDATE},
{RebootReason::HIGH_TEMPERATURE, RebootShlib::RebootSource::OVERHEAT, true, {RebootReason::HIGH_TEMPERATURE, RebootShlib::RebootSource::OVERHEAT, true,
StateControlRebootReason::HIGH_TEMPERATURE}, StateControlRebootReason::HIGH_TEMPERATURE},
{RebootReason::SESSION_FAILURE, RebootShlib::RebootSource::SW_OTHER, true}, {RebootReason::SESSION_FAILURE, RebootShlib::RebootSource::SW_OTHER, true},
...@@ -236,6 +234,33 @@ TEST_F(RebootFuchsiaTest, GetLastRebootSourceWithoutGranularReason) { ...@@ -236,6 +234,33 @@ TEST_F(RebootFuchsiaTest, GetLastRebootSourceWithoutGranularReason) {
Eq(RebootShlib::RebootSource::SW_OTHER)); 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, class RebootFuchsiaParamTest : public RebootFuchsiaTest,
public ::testing::WithParamInterface<RebootReasonParam> { public ::testing::WithParamInterface<RebootReasonParam> {
public: public:
...@@ -249,12 +274,7 @@ TEST_P(RebootFuchsiaParamTest, RebootNowSendsFidlRebootReason) { ...@@ -249,12 +274,7 @@ TEST_P(RebootFuchsiaParamTest, RebootNowSendsFidlRebootReason) {
} }
TEST_P(RebootFuchsiaParamTest, GetLastRebootSourceTranslatesReasonFromFuchsia) { TEST_P(RebootFuchsiaParamTest, GetLastRebootSourceTranslatesReasonFromFuchsia) {
fuchsia::feedback::LastReboot last_reboot; SetLastReboot(GenerateLastReboot(GetParam().graceful, GetParam().reason));
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));
EXPECT_THAT(RebootUtil::GetLastRebootSource(), Eq(GetParam().source)); 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