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

Side by Side Diff: src/platform/update_engine/extent_mapper_unittest.cc

Issue 650199: AU: Extent Mapper class (Closed)
Patch Set: fixes for review Created 10 years, 10 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
« no previous file with comments | « src/platform/update_engine/extent_mapper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <sys/stat.h>
6 #include <sys/types.h>
7 #include <unistd.h>
8 #include <set>
9 #include <string>
10 #include <vector>
11 #include <gtest/gtest.h>
12 #include "base/basictypes.h"
13 #include "update_engine/extent_mapper.h"
14 #include "update_engine/utils.h"
15
16 using std::set;
17 using std::string;
18 using std::vector;
19
20 namespace chromeos_update_engine {
21
22 class ExtentMapperTest : public ::testing::Test {};
23
24 TEST(ExtentMapperTest, RunAsRootSimpleTest) {
25 // It's hard to have a concrete test for extent mapping without including
26 // a specific filesystem image.
27 // In lieu of this, we do a weak test: make sure the extents of the unittest
28 // executable are consistent and they match with the size of the file.
29 const string kFilename = "/proc/self/exe";
30 const off_t kBlockSize = 4096;
31
32 vector<Extent> extents;
33
34 ASSERT_TRUE(ExtentsForFileFibmap(kFilename, &extents));
35
36 EXPECT_FALSE(extents.empty());
37 set<uint64> blocks;
38
39 for (vector<Extent>::const_iterator it = extents.begin();
40 it != extents.end(); ++it) {
41 for (uint64 block = it->start_block();
42 block < it->start_block() + it->num_blocks();
43 block++) {
44 EXPECT_FALSE(utils::SetContainsKey(blocks, block));
45 blocks.insert(block);
46 }
47 }
48
49 struct stat stbuf;
50 EXPECT_EQ(0, stat(kFilename.c_str(), &stbuf));
51 EXPECT_EQ(blocks.size(), (stbuf.st_size + kBlockSize - 1)/kBlockSize);
52 }
53
54 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « src/platform/update_engine/extent_mapper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698