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

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

Issue 1718001: AU: Class to perform delta updates. (Closed)
Patch Set: fixes for review Created 10 years, 8 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium 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 <sys/types.h> 5 #include <sys/types.h>
6 #include <sys/stat.h> 6 #include <sys/stat.h>
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 #include <gtest/gtest.h> 13 #include <gtest/gtest.h>
14 #include "chromeos/obsolete_logging.h" 14 #include "chromeos/obsolete_logging.h"
15 #include "update_engine/cycle_breaker.h" 15 #include "update_engine/cycle_breaker.h"
16 #include "update_engine/delta_diff_generator.h" 16 #include "update_engine/delta_diff_generator.h"
17 #include "update_engine/delta_performer.h"
17 #include "update_engine/graph_types.h" 18 #include "update_engine/graph_types.h"
18 #include "update_engine/graph_utils.h" 19 #include "update_engine/graph_utils.h"
19 #include "update_engine/subprocess.h" 20 #include "update_engine/subprocess.h"
20 #include "update_engine/test_utils.h" 21 #include "update_engine/test_utils.h"
21 #include "update_engine/utils.h" 22 #include "update_engine/utils.h"
22 23
23 using std::make_pair; 24 using std::make_pair;
24 using std::set; 25 using std::set;
25 using std::string; 26 using std::string;
26 using std::vector; 27 using std::vector;
27 28
28 namespace chromeos_update_engine { 29 namespace chromeos_update_engine {
29 30
30 typedef DeltaDiffGenerator::Block Block; 31 typedef DeltaDiffGenerator::Block Block;
31 32
32 namespace { 33 namespace {
33 int64 BlocksInExtents( 34 int64_t BlocksInExtents(
34 const google::protobuf::RepeatedPtrField<Extent>& extents) { 35 const google::protobuf::RepeatedPtrField<Extent>& extents) {
35 int64 ret = 0; 36 int64_t ret = 0;
36 for (int i = 0; i < extents.size(); i++) { 37 for (int i = 0; i < extents.size(); i++) {
37 ret += extents.Get(i).num_blocks(); 38 ret += extents.Get(i).num_blocks();
38 } 39 }
39 return ret; 40 return ret;
40 } 41 }
41 } // namespace {} 42 } // namespace {}
42 43
43 class DeltaDiffGeneratorTest : public ::testing::Test { 44 class DeltaDiffGeneratorTest : public ::testing::Test {
44 protected: 45 protected:
45 const string old_path() { return "DeltaDiffGeneratorTest-old_path"; } 46 const string old_path() { return "DeltaDiffGeneratorTest-old_path"; }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 EXPECT_FALSE(op.has_data_length()); 133 EXPECT_FALSE(op.has_data_length());
133 EXPECT_EQ(0, op.src_extents_size()); 134 EXPECT_EQ(0, op.src_extents_size());
134 EXPECT_FALSE(op.has_src_length()); 135 EXPECT_FALSE(op.has_src_length());
135 EXPECT_EQ(1, op.dst_extents_size()); 136 EXPECT_EQ(1, op.dst_extents_size());
136 EXPECT_EQ(new_data.size(), op.dst_length()); 137 EXPECT_EQ(new_data.size(), op.dst_length());
137 EXPECT_EQ(1, BlocksInExtents(op.dst_extents())); 138 EXPECT_EQ(1, BlocksInExtents(op.dst_extents()));
138 } 139 }
139 } 140 }
140 141
141 namespace { 142 namespace {
142 void AppendExtent(vector<Extent>* vect, uint64 start, uint64 length) { 143 void AppendExtent(vector<Extent>* vect, uint64_t start, uint64_t length) {
143 vect->resize(vect->size() + 1); 144 vect->resize(vect->size() + 1);
144 vect->back().set_start_block(start); 145 vect->back().set_start_block(start);
145 vect->back().set_num_blocks(length); 146 vect->back().set_num_blocks(length);
146 } 147 }
147 void OpAppendExtent(DeltaArchiveManifest_InstallOperation* op, 148 void OpAppendExtent(DeltaArchiveManifest_InstallOperation* op,
148 uint64 start, 149 uint64_t start,
149 uint64 length) { 150 uint64_t length) {
150 Extent* extent = op->add_src_extents(); 151 Extent* extent = op->add_src_extents();
151 extent->set_start_block(start); 152 extent->set_start_block(start);
152 extent->set_num_blocks(length); 153 extent->set_num_blocks(length);
153 } 154 }
154 } 155 }
155 156
156 TEST_F(DeltaDiffGeneratorTest, SubstituteBlocksTest) { 157 TEST_F(DeltaDiffGeneratorTest, SubstituteBlocksTest) {
157 vector<Extent> remove_blocks; 158 vector<Extent> remove_blocks;
158 AppendExtent(&remove_blocks, 3, 3); 159 AppendExtent(&remove_blocks, 3, 3);
159 AppendExtent(&remove_blocks, 7, 1); 160 AppendExtent(&remove_blocks, 7, 1);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 EXPECT_EQ(0, manifest.install_operations(0).data_offset()); 340 EXPECT_EQ(0, manifest.install_operations(0).data_offset());
340 EXPECT_EQ(3, manifest.install_operations(0).data_length()); 341 EXPECT_EQ(3, manifest.install_operations(0).data_length());
341 EXPECT_EQ(3, manifest.install_operations(1).data_offset()); 342 EXPECT_EQ(3, manifest.install_operations(1).data_offset());
342 EXPECT_EQ(1, manifest.install_operations(1).data_length()); 343 EXPECT_EQ(1, manifest.install_operations(1).data_length());
343 344
344 unlink(orig_blobs.c_str()); 345 unlink(orig_blobs.c_str());
345 unlink(new_blobs.c_str()); 346 unlink(new_blobs.c_str());
346 } 347 }
347 348
348 } // namespace chromeos_update_engine 349 } // namespace chromeos_update_engine
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698