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

Side by Side Diff: delta_performer_unittest.cc

Issue 3547019: AU: DeltaPerformer performs the download size/hash check now. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: 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 | « delta_performer.cc ('k') | download_action.cc » ('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) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 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 <sys/mount.h> 5 #include <sys/mount.h>
6 #include <inttypes.h> 6 #include <inttypes.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 EXPECT_FALSE(signature.data().empty()); 240 EXPECT_FALSE(signature.data().empty());
241 } 241 }
242 242
243 PrefsMock prefs; 243 PrefsMock prefs;
244 EXPECT_CALL(prefs, SetInt64(kPrefsManifestMetadataSize, 244 EXPECT_CALL(prefs, SetInt64(kPrefsManifestMetadataSize,
245 manifest_metadata_size)).WillOnce(Return(true)); 245 manifest_metadata_size)).WillOnce(Return(true));
246 EXPECT_CALL(prefs, SetInt64(kPrefsUpdateStateNextOperation, _)) 246 EXPECT_CALL(prefs, SetInt64(kPrefsUpdateStateNextOperation, _))
247 .WillRepeatedly(Return(true)); 247 .WillRepeatedly(Return(true));
248 EXPECT_CALL(prefs, SetInt64(kPrefsUpdateStateNextDataOffset, _)) 248 EXPECT_CALL(prefs, SetInt64(kPrefsUpdateStateNextDataOffset, _))
249 .WillRepeatedly(Return(true)); 249 .WillRepeatedly(Return(true));
250 EXPECT_CALL(prefs, SetString(kPrefsUpdateStateSHA256Context, _))
251 .WillRepeatedly(Return(true));
250 EXPECT_CALL(prefs, SetString(kPrefsUpdateStateSignedSHA256Context, _)) 252 EXPECT_CALL(prefs, SetString(kPrefsUpdateStateSignedSHA256Context, _))
251 .WillRepeatedly(Return(true)); 253 .WillOnce(Return(true));
252 254
253 // Update the A image in place. 255 // Update the A image in place.
254 DeltaPerformer performer(&prefs); 256 DeltaPerformer performer(&prefs);
255 257
256 EXPECT_EQ(0, performer.Open(a_img.c_str(), 0, 0)); 258 EXPECT_EQ(0, performer.Open(a_img.c_str(), 0, 0));
257 EXPECT_TRUE(performer.OpenKernel(old_kernel.c_str())); 259 EXPECT_TRUE(performer.OpenKernel(old_kernel.c_str()));
258 260
259 // Write at some number of bytes per operation. Arbitrarily chose 5. 261 // Write at some number of bytes per operation. Arbitrarily chose 5.
260 const size_t kBytesPerWrite = 5; 262 const size_t kBytesPerWrite = 5;
261 for (size_t i = 0; i < delta.size(); i += kBytesPerWrite) { 263 for (size_t i = 0; i < delta.size(); i += kBytesPerWrite) {
262 size_t count = min(delta.size() - i, kBytesPerWrite); 264 size_t count = min(delta.size() - i, kBytesPerWrite);
263 EXPECT_EQ(count, performer.Write(&delta[i], count)); 265 EXPECT_EQ(count, performer.Write(&delta[i], count));
264 } 266 }
265 267
266 // Wrapper around close. Returns 0 on success or -errno on error. 268 // Wrapper around close. Returns 0 on success or -errno on error.
267 EXPECT_EQ(0, performer.Close()); 269 EXPECT_EQ(0, performer.Close());
268 270
269 CompareFilesByBlock(old_kernel, new_kernel); 271 CompareFilesByBlock(old_kernel, new_kernel);
270 272
271 vector<char> updated_kernel_partition; 273 vector<char> updated_kernel_partition;
272 EXPECT_TRUE(utils::ReadFile(old_kernel, &updated_kernel_partition)); 274 EXPECT_TRUE(utils::ReadFile(old_kernel, &updated_kernel_partition));
273 EXPECT_EQ(0, strncmp(&updated_kernel_partition[0], new_data_string, 275 EXPECT_EQ(0, strncmp(&updated_kernel_partition[0], new_data_string,
274 strlen(new_data_string))); 276 strlen(new_data_string)));
275 277
276 EXPECT_TRUE(utils::FileExists(kUnittestPublicKeyPath)); 278 EXPECT_TRUE(utils::FileExists(kUnittestPublicKeyPath));
277 EXPECT_TRUE(performer.VerifyPayload(kUnittestPublicKeyPath)); 279 EXPECT_TRUE(performer.VerifyPayload(
280 kUnittestPublicKeyPath,
281 OmahaHashCalculator::OmahaHashOfData(delta),
282 delta.size()));
278 } 283 }
279 284
280 } // namespace chromeos_update_engine 285 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « delta_performer.cc ('k') | download_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698