diff options
Diffstat (limited to 'payload_consumer/postinstall_runner_action_unittest.cc')
-rw-r--r-- | payload_consumer/postinstall_runner_action_unittest.cc | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/payload_consumer/postinstall_runner_action_unittest.cc b/payload_consumer/postinstall_runner_action_unittest.cc index 84f2c2c4..cf5158b2 100644 --- a/payload_consumer/postinstall_runner_action_unittest.cc +++ b/payload_consumer/postinstall_runner_action_unittest.cc @@ -103,6 +103,8 @@ class PostinstallRunnerActionTest : public ::testing::Test { bool is_rollback, bool save_rollback_data); + void RunPostinstallActionWithInstallPlan(const InstallPlan& install_plan); + public: void ResumeRunningAction() { ASSERT_NE(nullptr, postinstall_action_); @@ -180,9 +182,6 @@ void PostinstallRunnerActionTest::RunPostinstallAction( bool powerwash_required, bool is_rollback, bool save_rollback_data) { - ActionProcessor processor; - processor_ = &processor; - auto feeder_action = std::make_unique<ObjectFeederAction<InstallPlan>>(); InstallPlan::Partition part; part.name = "part"; part.target_path = device_path; @@ -194,6 +193,14 @@ void PostinstallRunnerActionTest::RunPostinstallAction( install_plan.powerwash_required = powerwash_required; install_plan.is_rollback = is_rollback; install_plan.rollback_data_save_requested = save_rollback_data; + RunPostinstallActionWithInstallPlan(install_plan); +} + +void PostinstallRunnerActionTest::RunPostinstallActionWithInstallPlan( + const chromeos_update_engine::InstallPlan& install_plan) { + ActionProcessor processor; + processor_ = &processor; + auto feeder_action = std::make_unique<ObjectFeederAction<InstallPlan>>(); feeder_action->set_obj(install_plan); auto runner_action = std::make_unique<PostinstallRunnerAction>( &fake_boot_control_, &fake_hardware_); @@ -220,7 +227,7 @@ void PostinstallRunnerActionTest::RunPostinstallAction( EXPECT_TRUE(processor_delegate_.processing_stopped_called_ || processor_delegate_.processing_done_called_); if (processor_delegate_.processing_done_called_) { - // Sanity check that the code was set when the processor finishes. + // Validation check that the code was set when the processor finishes. EXPECT_TRUE(processor_delegate_.code_set_); } } @@ -335,6 +342,27 @@ TEST_F(PostinstallRunnerActionTest, RunAsRootCantMountTest) { EXPECT_FALSE(fake_hardware_.GetIsRollbackPowerwashScheduled()); } +TEST_F(PostinstallRunnerActionTest, RunAsRootSkipOptionalPostinstallTest) { + InstallPlan::Partition part; + part.name = "part"; + part.target_path = "/dev/null"; + part.run_postinstall = true; + part.postinstall_path = kPostinstallDefaultScript; + part.postinstall_optional = true; + InstallPlan install_plan; + install_plan.partitions = {part}; + install_plan.download_url = "http://127.0.0.1:8080/update"; + + // Optional postinstalls will be skipped, and the postinstall action succeeds. + RunPostinstallActionWithInstallPlan(install_plan); + EXPECT_EQ(ErrorCode::kSuccess, processor_delegate_.code_); + + part.postinstall_optional = false; + install_plan.partitions = {part}; + RunPostinstallActionWithInstallPlan(install_plan); + EXPECT_EQ(ErrorCode::kPostinstallRunnerError, processor_delegate_.code_); +} + // Check that the failures from the postinstall script cause the action to // fail. TEST_F(PostinstallRunnerActionTest, RunAsRootErrScriptTest) { |