summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--payload_consumer/postinstall_runner_action.cc4
-rw-r--r--payload_consumer/postinstall_runner_action.h18
-rw-r--r--payload_consumer/postinstall_runner_action_unittest.cc8
-rw-r--r--update_attempter.cc2
-rw-r--r--update_attempter_unittest.cc3
5 files changed, 19 insertions, 16 deletions
diff --git a/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc
index 33bbf5b1..84ca398c 100644
--- a/payload_consumer/postinstall_runner_action.cc
+++ b/payload_consumer/postinstall_runner_action.cc
@@ -25,6 +25,7 @@
#include <base/files/file_util.h>
#include "update_engine/common/action_processor.h"
+#include "update_engine/common/boot_control_interface.h"
#include "update_engine/common/subprocess.h"
#include "update_engine/common/utils.h"
@@ -159,8 +160,7 @@ void PostinstallRunnerAction::CompletePostinstall(ErrorCode error_code) {
// We only attempt to mark the new slot as active if all the postinstall
// steps succeeded.
if (error_code == ErrorCode::kSuccess &&
- !system_state_->boot_control()->SetActiveBootSlot(
- install_plan_.target_slot)) {
+ !boot_control_->SetActiveBootSlot(install_plan_.target_slot)) {
error_code = ErrorCode::kPostinstallRunnerError;
}
diff --git a/payload_consumer/postinstall_runner_action.h b/payload_consumer/postinstall_runner_action.h
index de19c0cd..ab267b82 100644
--- a/payload_consumer/postinstall_runner_action.h
+++ b/payload_consumer/postinstall_runner_action.h
@@ -21,17 +21,18 @@
#include "update_engine/common/action.h"
#include "update_engine/payload_consumer/install_plan.h"
-#include "update_engine/system_state.h"
// The Postinstall Runner Action is responsible for running the postinstall
// script of a successfully downloaded update.
namespace chromeos_update_engine {
+class BootControlInterface;
+
class PostinstallRunnerAction : public InstallPlanAction {
public:
- explicit PostinstallRunnerAction(SystemState* system_state)
- : PostinstallRunnerAction(system_state, nullptr) {}
+ explicit PostinstallRunnerAction(BootControlInterface* boot_control)
+ : PostinstallRunnerAction(boot_control, nullptr) {}
void PerformAction();
@@ -46,9 +47,9 @@ class PostinstallRunnerAction : public InstallPlanAction {
friend class PostinstallRunnerActionTest;
// Special constructor used for testing purposes.
- PostinstallRunnerAction(SystemState* system_state,
+ PostinstallRunnerAction(BootControlInterface* boot_control,
const char* powerwash_marker_file)
- : system_state_(system_state),
+ : boot_control_(boot_control),
powerwash_marker_file_(powerwash_marker_file) {}
void PerformPartitionPostinstall();
@@ -57,7 +58,8 @@ class PostinstallRunnerAction : public InstallPlanAction {
void CompletePartitionPostinstall(int return_code,
const std::string& output);
- //
+ // Complete the Action with the passed |error_code| and mark the new slot as
+ // ready. Called when the post-install script was run for all the partitions.
void CompletePostinstall(ErrorCode error_code);
InstallPlan install_plan_;
@@ -67,8 +69,8 @@ class PostinstallRunnerAction : public InstallPlanAction {
// InstallPlan.
size_t current_partition_{0};
- // The main SystemState singleton.
- SystemState* system_state_;
+ // The BootControlInerface used to mark the new slot as ready.
+ BootControlInterface* boot_control_;
// True if Powerwash Marker was created before invoking post-install script.
// False otherwise. Used for cleaning up if post-install fails.
diff --git a/payload_consumer/postinstall_runner_action_unittest.cc b/payload_consumer/postinstall_runner_action_unittest.cc
index c54ace80..beed4f16 100644
--- a/payload_consumer/postinstall_runner_action_unittest.cc
+++ b/payload_consumer/postinstall_runner_action_unittest.cc
@@ -34,9 +34,9 @@
#include <gtest/gtest.h>
#include "update_engine/common/constants.h"
+#include "update_engine/common/fake_boot_control.h"
#include "update_engine/common/test_utils.h"
#include "update_engine/common/utils.h"
-#include "update_engine/fake_system_state.h"
using brillo::MessageLoop;
using chromeos_update_engine::test_utils::System;
@@ -66,7 +66,7 @@ class PostinstallRunnerActionTest : public ::testing::Test {
brillo::BaseMessageLoop loop_{&base_loop_};
brillo::AsynchronousSignalHandler async_signal_handler_;
Subprocess subprocess_;
- FakeSystemState fake_system_state_;
+ FakeBootControl fake_boot_control_;
};
class PostinstActionProcessorDelegate : public ActionProcessorDelegate {
@@ -196,7 +196,7 @@ void PostinstallRunnerActionTest::DoTest(
install_plan.download_url = "http://devserver:8080/update";
install_plan.powerwash_required = powerwash_required;
feeder_action.set_obj(install_plan);
- PostinstallRunnerAction runner_action(&fake_system_state_,
+ PostinstallRunnerAction runner_action(&fake_boot_control_,
powerwash_marker_file.c_str());
BondActions(&feeder_action, &runner_action);
ObjectCollectorAction<InstallPlan> collector_action;
@@ -252,7 +252,7 @@ void PostinstallRunnerActionTest::DoTest(
// Death tests don't seem to be working on Hardy
TEST_F(PostinstallRunnerActionTest, DISABLED_RunAsRootDeathTest) {
ASSERT_EQ(0, getuid());
- PostinstallRunnerAction runner_action(&fake_system_state_);
+ PostinstallRunnerAction runner_action(&fake_boot_control_);
ASSERT_DEATH({ runner_action.TerminateProcessing(); },
"postinstall_runner_action.h:.*] Check failed");
}
diff --git a/update_attempter.cc b/update_attempter.cc
index 4790e849..3cdd6136 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -564,7 +564,7 @@ void UpdateAttempter::GenerateNewWaitingPeriod() {
void UpdateAttempter::BuildPostInstallActions(
InstallPlanAction* previous_action) {
shared_ptr<PostinstallRunnerAction> postinstall_runner_action(
- new PostinstallRunnerAction(system_state_));
+ new PostinstallRunnerAction(system_state_->boot_control()));
actions_.push_back(shared_ptr<AbstractAction>(postinstall_runner_action));
BondActions(previous_action,
postinstall_runner_action.get());
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index 1f6cd744..317f0ca5 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -288,7 +288,8 @@ TEST_F(UpdateAttempterTest, GetErrorCodeForActionTest) {
EXPECT_EQ(ErrorCode::kFilesystemVerifierError,
GetErrorCodeForAction(&filesystem_verifier_action,
ErrorCode::kError));
- PostinstallRunnerAction postinstall_runner_action(&fake_system_state);
+ PostinstallRunnerAction postinstall_runner_action(
+ fake_system_state.fake_boot_control());
EXPECT_EQ(ErrorCode::kPostinstallRunnerError,
GetErrorCodeForAction(&postinstall_runner_action,
ErrorCode::kError));