Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: filesystem_copier_action_unittest.cc

Issue 3712003: AU: Verify source rootfs/kernel hashes before applying delta. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: verify source partitions only for new updates Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « filesystem_copier_action.cc ('k') | install_plan.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filesystem_copier_action_unittest.cc
diff --git a/filesystem_copier_action_unittest.cc b/filesystem_copier_action_unittest.cc
index d9305ff55deb0dfb7b7ac857b4981a7b250c0595..cd77befae9132e99bf368a1fc6f157d73e229b19 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
« no previous file with comments | « filesystem_copier_action.cc ('k') | install_plan.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698