diff options
author | Sen Jiang <senj@google.com> | 2016-03-25 15:32:49 -0700 |
---|---|---|
committer | Sen Jiang <senj@google.com> | 2016-04-05 18:17:17 -0700 |
commit | fef85fd9ece49941db274559a938fe8b2c5157bf (patch) | |
tree | 7148aeec84f53e6a3c9b0639f92a2db8dc5d3600 /payload_consumer/filesystem_verifier_action_unittest.cc | |
parent | 44b35672c5f6064a890126a687db65ac12945299 (diff) |
Remove ComputeSourceHash mode in FileSystemVerification action.
This mode was used to calculate the source partition hash before download
the payload, and we will verify it against the hash in the payload.
Now that we are using per-operation source hash, this mode is no longer
needed.
Test: ./update_engine_unittests
Test: cros_workon_make update_engine --test
Bug: 26972259
Change-Id: Ie30a38cfd9f94e4efe02dfc8664e6785018261f6
Diffstat (limited to 'payload_consumer/filesystem_verifier_action_unittest.cc')
-rw-r--r-- | payload_consumer/filesystem_verifier_action_unittest.cc | 52 |
1 files changed, 15 insertions, 37 deletions
diff --git a/payload_consumer/filesystem_verifier_action_unittest.cc b/payload_consumer/filesystem_verifier_action_unittest.cc index fdc94d9d..ad224bc0 100644 --- a/payload_consumer/filesystem_verifier_action_unittest.cc +++ b/payload_consumer/filesystem_verifier_action_unittest.cc @@ -56,9 +56,7 @@ class FilesystemVerifierActionTest : public ::testing::Test { } // Returns true iff test has completed successfully. - bool DoTest(bool terminate_early, - bool hash_fail, - VerifierMode verifier_mode); + bool DoTest(bool terminate_early, bool hash_fail); brillo::FakeMessageLoop loop_{nullptr}; FakeBootControl fake_boot_control_; @@ -115,23 +113,8 @@ void StartProcessorInRunLoop(ActionProcessor* processor, } } -// TODO(garnold) Temporarily disabling this test, see chromium-os:31082 for -// details; still trying to track down the root cause for these rare write -// failures and whether or not they are due to the test setup or an inherent -// issue with the chroot environment, library versions we use, etc. -TEST_F(FilesystemVerifierActionTest, DISABLED_RunAsRootSimpleTest) { - ASSERT_EQ(0U, getuid()); - bool test = DoTest(false, false, VerifierMode::kComputeSourceHash); - EXPECT_TRUE(test); - if (!test) - return; - test = DoTest(false, false, VerifierMode::kVerifyTargetHash); - EXPECT_TRUE(test); -} - bool FilesystemVerifierActionTest::DoTest(bool terminate_early, - bool hash_fail, - VerifierMode verifier_mode) { + bool hash_fail) { string a_loop_file; if (!(utils::MakeTempFile("a_loop_file.XXXXXX", &a_loop_file, nullptr))) { @@ -170,15 +153,13 @@ bool FilesystemVerifierActionTest::DoTest(bool terminate_early, install_plan.target_slot = 1; InstallPlan::Partition part; part.name = "part"; - if (verifier_mode == VerifierMode::kVerifyTargetHash) { - part.target_size = kLoopFileSize - (hash_fail ? 1 : 0); - part.target_path = a_dev; - fake_boot_control_.SetPartitionDevice( - part.name, install_plan.target_slot, a_dev); - if (!HashCalculator::RawHashOfData(a_loop_data, &part.target_hash)) { - ADD_FAILURE(); - success = false; - } + part.target_size = kLoopFileSize - (hash_fail ? 1 : 0); + part.target_path = a_dev; + fake_boot_control_.SetPartitionDevice( + part.name, install_plan.target_slot, a_dev); + if (!HashCalculator::RawHashOfData(a_loop_data, &part.target_hash)) { + ADD_FAILURE(); + success = false; } part.source_size = kLoopFileSize; part.source_path = a_dev; @@ -193,7 +174,7 @@ bool FilesystemVerifierActionTest::DoTest(bool terminate_early, ActionProcessor processor; ObjectFeederAction<InstallPlan> feeder_action; - FilesystemVerifierAction copier_action(&fake_boot_control_, verifier_mode); + FilesystemVerifierAction copier_action(&fake_boot_control_); ObjectCollectorAction<InstallPlan> collector_action; BondActions(&feeder_action, &copier_action); @@ -265,8 +246,7 @@ TEST_F(FilesystemVerifierActionTest, MissingInputObjectTest) { processor.set_delegate(&delegate); - FilesystemVerifierAction copier_action(&fake_boot_control_, - VerifierMode::kVerifyTargetHash); + FilesystemVerifierAction copier_action(&fake_boot_control_); ObjectCollectorAction<InstallPlan> collector_action; BondActions(&copier_action, &collector_action); @@ -294,8 +274,7 @@ TEST_F(FilesystemVerifierActionTest, NonExistentDriveTest) { install_plan.partitions = {part}; feeder_action.set_obj(install_plan); - FilesystemVerifierAction verifier_action(&fake_boot_control_, - VerifierMode::kVerifyTargetHash); + FilesystemVerifierAction verifier_action(&fake_boot_control_); ObjectCollectorAction<InstallPlan> collector_action; BondActions(&verifier_action, &collector_action); @@ -311,18 +290,17 @@ TEST_F(FilesystemVerifierActionTest, NonExistentDriveTest) { TEST_F(FilesystemVerifierActionTest, RunAsRootVerifyHashTest) { ASSERT_EQ(0U, getuid()); - EXPECT_TRUE(DoTest(false, false, VerifierMode::kVerifyTargetHash)); - EXPECT_TRUE(DoTest(false, false, VerifierMode::kComputeSourceHash)); + EXPECT_TRUE(DoTest(false, false)); } TEST_F(FilesystemVerifierActionTest, RunAsRootVerifyHashFailTest) { ASSERT_EQ(0U, getuid()); - EXPECT_TRUE(DoTest(false, true, VerifierMode::kVerifyTargetHash)); + EXPECT_TRUE(DoTest(false, true)); } TEST_F(FilesystemVerifierActionTest, RunAsRootTerminateEarlyTest) { ASSERT_EQ(0U, getuid()); - EXPECT_TRUE(DoTest(true, false, VerifierMode::kVerifyTargetHash)); + EXPECT_TRUE(DoTest(true, false)); // TerminateEarlyTest may leak some null callbacks from the Stream class. while (loop_.RunOnce(false)) {} } |