summaryrefslogtreecommitdiff
path: root/payload_consumer/postinstall_runner_action_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'payload_consumer/postinstall_runner_action_unittest.cc')
-rw-r--r--payload_consumer/postinstall_runner_action_unittest.cc28
1 files changed, 8 insertions, 20 deletions
diff --git a/payload_consumer/postinstall_runner_action_unittest.cc b/payload_consumer/postinstall_runner_action_unittest.cc
index 3b6b49a4..5a8e9508 100644
--- a/payload_consumer/postinstall_runner_action_unittest.cc
+++ b/payload_consumer/postinstall_runner_action_unittest.cc
@@ -26,7 +26,6 @@
#include <base/bind.h>
#include <base/files/file_util.h>
-#include <base/files/scoped_temp_dir.h>
#include <base/message_loop/message_loop.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
@@ -38,6 +37,7 @@
#include "update_engine/common/constants.h"
#include "update_engine/common/fake_boot_control.h"
+#include "update_engine/common/fake_hardware.h"
#include "update_engine/common/test_utils.h"
#include "update_engine/common/utils.h"
@@ -88,10 +88,6 @@ class PostinstallRunnerActionTest : public ::testing::Test {
loop_.SetAsCurrent();
async_signal_handler_.Init();
subprocess_.Init(&async_signal_handler_);
- ASSERT_TRUE(working_dir_.CreateUniqueTempDir());
- // We use a test-specific powerwash marker file, to avoid race conditions.
- powerwash_marker_file_ =
- working_dir_.path().Append("factory_install_reset").value();
// These tests use the postinstall files generated by "generate_images.sh"
// stored in the "disk_ext2_unittest.img" image.
postinstall_image_ =
@@ -154,14 +150,11 @@ class PostinstallRunnerActionTest : public ::testing::Test {
brillo::AsynchronousSignalHandler async_signal_handler_;
Subprocess subprocess_;
- // A temporary working directory used for the test.
- base::ScopedTempDir working_dir_;
- string powerwash_marker_file_;
-
// The path to the postinstall sample image.
string postinstall_image_;
FakeBootControl fake_boot_control_;
+ FakeHardware fake_hardware_;
PostinstActionProcessorDelegate processor_delegate_;
// The PostinstallRunnerAction delegate receiving the progress updates.
@@ -189,8 +182,7 @@ void PostinstallRunnerActionTest::RunPosinstallAction(
install_plan.download_url = "http://127.0.0.1:8080/update";
install_plan.powerwash_required = powerwash_required;
feeder_action.set_obj(install_plan);
- PostinstallRunnerAction runner_action(&fake_boot_control_,
- powerwash_marker_file_.c_str());
+ PostinstallRunnerAction runner_action(&fake_boot_control_, &fake_hardware_);
postinstall_action_ = &runner_action;
runner_action.set_delegate(setup_action_delegate_);
BondActions(&feeder_action, &runner_action);
@@ -216,8 +208,7 @@ void PostinstallRunnerActionTest::RunPosinstallAction(
}
TEST_F(PostinstallRunnerActionTest, ProcessProgressLineTest) {
- PostinstallRunnerAction action(&fake_boot_control_,
- powerwash_marker_file_.c_str());
+ PostinstallRunnerAction action(&fake_boot_control_, &fake_hardware_);
testing::StrictMock<MockPostinstallRunnerActionDelegate> mock_delegate_;
action.set_delegate(&mock_delegate_);
@@ -246,7 +237,7 @@ TEST_F(PostinstallRunnerActionTest, RunAsRootSimpleTest) {
EXPECT_TRUE(processor_delegate_.processing_done_called_);
// Since powerwash_required was false, this should not trigger a powerwash.
- EXPECT_FALSE(utils::FileExists(powerwash_marker_file_.c_str()));
+ EXPECT_FALSE(fake_hardware_.IsPowerwashScheduled());
}
TEST_F(PostinstallRunnerActionTest, RunAsRootRunSymlinkFileTest) {
@@ -261,11 +252,8 @@ TEST_F(PostinstallRunnerActionTest, RunAsRootPowerwashRequiredTest) {
RunPosinstallAction(loop.dev(), "bin/postinst_example", true);
EXPECT_EQ(ErrorCode::kSuccess, processor_delegate_.code_);
- // Check that the powerwash marker file was set.
- string actual_cmd;
- EXPECT_TRUE(base::ReadFileToString(base::FilePath(powerwash_marker_file_),
- &actual_cmd));
- EXPECT_EQ(kPowerwashCommand, actual_cmd);
+ // Check that powerwash was scheduled.
+ EXPECT_TRUE(fake_hardware_.IsPowerwashScheduled());
}
// Runs postinstall from a partition file that doesn't mount, so it should
@@ -276,7 +264,7 @@ TEST_F(PostinstallRunnerActionTest, RunAsRootCantMountTest) {
// In case of failure, Postinstall should not signal a powerwash even if it
// was requested.
- EXPECT_FALSE(utils::FileExists(powerwash_marker_file_.c_str()));
+ EXPECT_FALSE(fake_hardware_.IsPowerwashScheduled());
}
// Check that the failures from the postinstall script cause the action to