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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « filesystem_copier_action.cc ('k') | install_plan.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <glib.h> 5 #include <fcntl.h>
6
6 #include <set> 7 #include <set>
7 #include <string> 8 #include <string>
8 #include <vector> 9 #include <vector>
10
11 #include <base/eintr_wrapper.h>
12 #include <base/string_util.h>
13 #include <glib.h>
9 #include <gtest/gtest.h> 14 #include <gtest/gtest.h>
10 #include "base/string_util.h" 15
11 #include "update_engine/filesystem_copier_action.h" 16 #include "update_engine/filesystem_copier_action.h"
12 #include "update_engine/filesystem_iterator.h" 17 #include "update_engine/filesystem_iterator.h"
13 #include "update_engine/omaha_hash_calculator.h" 18 #include "update_engine/omaha_hash_calculator.h"
14 #include "update_engine/test_utils.h" 19 #include "update_engine/test_utils.h"
15 #include "update_engine/utils.h" 20 #include "update_engine/utils.h"
16 21
17 using std::set; 22 using std::set;
18 using std::string; 23 using std::string;
19 using std::vector; 24 using std::vector;
20 25
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 TEST_F(FilesystemCopierActionTest, RunAsRootNoSpaceTest) { 312 TEST_F(FilesystemCopierActionTest, RunAsRootNoSpaceTest) {
308 ASSERT_EQ(0, getuid()); 313 ASSERT_EQ(0, getuid());
309 DoTest(true, false, false); 314 DoTest(true, false, false);
310 } 315 }
311 316
312 TEST_F(FilesystemCopierActionTest, RunAsRootTerminateEarlyTest) { 317 TEST_F(FilesystemCopierActionTest, RunAsRootTerminateEarlyTest) {
313 ASSERT_EQ(0, getuid()); 318 ASSERT_EQ(0, getuid());
314 DoTest(false, true, false); 319 DoTest(false, true, false);
315 } 320 }
316 321
322 TEST_F(FilesystemCopierActionTest, RunAsRootDetermineFilesystemSizeTest) {
323 string img;
324 EXPECT_TRUE(utils::MakeTempFile("/tmp/img.XXXXXX", &img, NULL));
325 ScopedPathUnlinker img_unlinker(img);
326 CreateExtImageAtPath(img, NULL);
327 // Extend the "partition" holding the file system from 10MiB to 20MiB.
328 EXPECT_EQ(0, System(StringPrintf(
329 "dd if=/dev/zero of=%s seek=20971519 bs=1 count=1",
330 img.c_str())));
331 EXPECT_EQ(20 * 1024 * 1024, utils::FileSize(img));
332
333 for (int i = 0; i < 2; ++i) {
334 bool is_kernel = i == 1;
335 FilesystemCopierAction action(is_kernel);
336 EXPECT_EQ(kint64max, action.filesystem_size_);
337 {
338 int fd = HANDLE_EINTR(open(img.c_str(), O_RDONLY));
339 EXPECT_TRUE(fd > 0);
340 ScopedFdCloser fd_closer(&fd);
341 action.DetermineFilesystemSize(fd);
342 }
343 EXPECT_EQ(is_kernel ? kint64max : 10 * 1024 * 1024,
344 action.filesystem_size_);
345 }
346 }
347
348
317 } // namespace chromeos_update_engine 349 } // namespace chromeos_update_engine
OLDNEW
« 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