diff options
author | Darin Petkov <petkov@chromium.org> | 2010-10-13 10:59:44 -0700 |
---|---|---|
committer | Darin Petkov <petkov@chromium.org> | 2010-10-13 10:59:44 -0700 |
commit | 698d04196deec8374ff148291db0afc7fec9cdcc (patch) | |
tree | 2835c2c975e5db2f9ac5b853f35d833121cd4e09 /filesystem_copier_action_unittest.cc | |
parent | 7ea3233e05ea10345aae337cd095f2c46ca90520 (diff) |
AU: Verify source rootfs/kernel hashes before applying delta.
New style full updates will not send the old rootfs hash so no check takes
place.
BUG=7562
TEST=unit tests, gmerged on device and tested with good/bad source partition
Change-Id: I65b28bf57110e4d87472d4aea59121878cde24b0
Review URL: http://codereview.chromium.org/3712003
Diffstat (limited to 'filesystem_copier_action_unittest.cc')
-rw-r--r-- | filesystem_copier_action_unittest.cc | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/filesystem_copier_action_unittest.cc b/filesystem_copier_action_unittest.cc index d9305ff5..cd77befa 100644 --- a/filesystem_copier_action_unittest.cc +++ b/filesystem_copier_action_unittest.cc @@ -2,12 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <glib.h> +#include <fcntl.h> + #include <set> #include <string> #include <vector> + +#include <base/eintr_wrapper.h> +#include <base/string_util.h> +#include <glib.h> #include <gtest/gtest.h> -#include "base/string_util.h" + #include "update_engine/filesystem_copier_action.h" #include "update_engine/filesystem_iterator.h" #include "update_engine/omaha_hash_calculator.h" @@ -314,4 +319,31 @@ TEST_F(FilesystemCopierActionTest, RunAsRootTerminateEarlyTest) { DoTest(false, true, false); } +TEST_F(FilesystemCopierActionTest, RunAsRootDetermineFilesystemSizeTest) { + string img; + EXPECT_TRUE(utils::MakeTempFile("/tmp/img.XXXXXX", &img, NULL)); + ScopedPathUnlinker img_unlinker(img); + CreateExtImageAtPath(img, NULL); + // Extend the "partition" holding the file system from 10MiB to 20MiB. + EXPECT_EQ(0, System(StringPrintf( + "dd if=/dev/zero of=%s seek=20971519 bs=1 count=1", + img.c_str()))); + EXPECT_EQ(20 * 1024 * 1024, utils::FileSize(img)); + + for (int i = 0; i < 2; ++i) { + bool is_kernel = i == 1; + FilesystemCopierAction action(is_kernel); + EXPECT_EQ(kint64max, action.filesystem_size_); + { + int fd = HANDLE_EINTR(open(img.c_str(), O_RDONLY)); + EXPECT_TRUE(fd > 0); + ScopedFdCloser fd_closer(&fd); + action.DetermineFilesystemSize(fd); + } + EXPECT_EQ(is_kernel ? kint64max : 10 * 1024 * 1024, + action.filesystem_size_); + } +} + + } // namespace chromeos_update_engine |