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

Side by Side Diff: delta_performer_unittest.cc

Issue 3599025: AU: Verify that the applied delta update matches the server-sent hashes. (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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 const size_t kBytesPerWrite = 5; 279 const size_t kBytesPerWrite = 5;
280 for (size_t i = 0; i < delta.size(); i += kBytesPerWrite) { 280 for (size_t i = 0; i < delta.size(); i += kBytesPerWrite) {
281 size_t count = min(delta.size() - i, kBytesPerWrite); 281 size_t count = min(delta.size() - i, kBytesPerWrite);
282 EXPECT_EQ(count, performer.Write(&delta[i], count)); 282 EXPECT_EQ(count, performer.Write(&delta[i], count));
283 } 283 }
284 284
285 // Wrapper around close. Returns 0 on success or -errno on error. 285 // Wrapper around close. Returns 0 on success or -errno on error.
286 EXPECT_EQ(0, performer.Close()); 286 EXPECT_EQ(0, performer.Close());
287 287
288 CompareFilesByBlock(old_kernel, new_kernel); 288 CompareFilesByBlock(old_kernel, new_kernel);
289 CompareFilesByBlock(a_img, b_img);
289 290
290 vector<char> updated_kernel_partition; 291 vector<char> updated_kernel_partition;
291 EXPECT_TRUE(utils::ReadFile(old_kernel, &updated_kernel_partition)); 292 EXPECT_TRUE(utils::ReadFile(old_kernel, &updated_kernel_partition));
292 EXPECT_EQ(0, strncmp(&updated_kernel_partition[0], new_data_string, 293 EXPECT_EQ(0, strncmp(&updated_kernel_partition[0], new_data_string,
293 strlen(new_data_string))); 294 strlen(new_data_string)));
294 295
295 EXPECT_TRUE(utils::FileExists(kUnittestPublicKeyPath)); 296 EXPECT_TRUE(utils::FileExists(kUnittestPublicKeyPath));
296 EXPECT_TRUE(performer.VerifyPayload( 297 EXPECT_TRUE(performer.VerifyPayload(
297 kUnittestPublicKeyPath, 298 kUnittestPublicKeyPath,
298 OmahaHashCalculator::OmahaHashOfData(delta), 299 OmahaHashCalculator::OmahaHashOfData(delta),
299 delta.size())); 300 delta.size()));
301 EXPECT_TRUE(performer.VerifyAppliedUpdate(a_img, old_kernel));
300 } 302 }
301 303
302 TEST(DeltaPerformerTest, NewFullUpdateTest) { 304 TEST(DeltaPerformerTest, NewFullUpdateTest) {
303 vector<char> new_root(20 * 1024 * 1024); 305 vector<char> new_root(20 * 1024 * 1024);
304 vector<char> new_kern(16 * 1024 * 1024); 306 vector<char> new_kern(16 * 1024 * 1024);
305 const off_t kChunkSize = 128 * 1024; 307 const off_t kChunkSize = 128 * 1024;
306 FillWithData(&new_root); 308 FillWithData(&new_root);
307 FillWithData(&new_kern); 309 FillWithData(&new_kern);
308 310
309 string new_root_path; 311 string new_root_path;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 op.clear_src_extents(); 372 op.clear_src_extents();
371 *(op.add_src_extents()) = ExtentForRange(5, 3); 373 *(op.add_src_extents()) = ExtentForRange(5, 3);
372 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); 374 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op));
373 *(op.add_dst_extents()) = ExtentForRange(20, 6); 375 *(op.add_dst_extents()) = ExtentForRange(20, 6);
374 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); 376 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op));
375 *(op.add_src_extents()) = ExtentForRange(19, 2); 377 *(op.add_src_extents()) = ExtentForRange(19, 2);
376 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op)); 378 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op));
377 } 379 }
378 380
379 } // namespace chromeos_update_engine 381 } // 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