blob: 4f6661e4803d6bb3ff46bbeedba6b56cabf3daa1 [file] [log] [blame]
Andrew de los Reyes09e56d62010-04-23 13:45:53 -07001// 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
3// found in the LICENSE file.
4
5#include <sys/mount.h>
6#include <inttypes.h>
7
8#include <algorithm>
9#include <string>
10#include <vector>
11
Darin Petkov73058b42010-10-06 16:32:19 -070012#include <base/scoped_ptr.h>
13#include <base/string_util.h>
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070014#include <google/protobuf/repeated_field.h>
15#include <gtest/gtest.h>
16
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070017#include "update_engine/delta_diff_generator.h"
18#include "update_engine/delta_performer.h"
Andrew de los Reyes353777c2010-10-08 10:34:30 -070019#include "update_engine/extent_ranges.h"
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070020#include "update_engine/graph_types.h"
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -070021#include "update_engine/payload_signer.h"
Darin Petkov73058b42010-10-06 16:32:19 -070022#include "update_engine/prefs_mock.h"
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070023#include "update_engine/test_utils.h"
24#include "update_engine/update_metadata.pb.h"
25#include "update_engine/utils.h"
26
27namespace chromeos_update_engine {
28
29using std::min;
30using std::string;
31using std::vector;
Darin Petkov73058b42010-10-06 16:32:19 -070032using testing::_;
33using testing::Return;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070034
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -070035extern const char* kUnittestPrivateKeyPath;
Darin Petkovd7061ab2010-10-06 14:37:09 -070036extern const char* kUnittestPublicKeyPath;
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -070037
Andrew de los Reyes27f7d372010-10-07 11:26:07 -070038namespace {
39 const size_t kBlockSize = 4096;
40} // namespace {}
41
42
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070043class DeltaPerformerTest : public ::testing::Test { };
44
45TEST(DeltaPerformerTest, ExtentsToByteStringTest) {
46 uint64_t test[] = {1, 1, 4, 2, kSparseHole, 1, 0, 1};
47 COMPILE_ASSERT(arraysize(test) % 2 == 0, array_size_uneven);
48 const uint64_t block_size = 4096;
49 const uint64_t file_length = 5 * block_size - 13;
50
51 google::protobuf::RepeatedPtrField<Extent> extents;
52 for (size_t i = 0; i < arraysize(test); i += 2) {
53 Extent* extent = extents.Add();
54 extent->set_start_block(test[i]);
55 extent->set_num_blocks(test[i + 1]);
56 }
57
58 string expected_output = "4096:4096,16384:8192,-1:4096,0:4083";
59 string actual_output;
60 EXPECT_TRUE(DeltaPerformer::ExtentsToBsdiffPositionsString(extents,
61 block_size,
62 file_length,
63 &actual_output));
64 EXPECT_EQ(expected_output, actual_output);
65}
66
67class ScopedLoopMounter {
68 public:
69 explicit ScopedLoopMounter(const string& file_path, string* mnt_path,
70 unsigned long flags) {
71 EXPECT_TRUE(utils::MakeTempDirectory("/tmp/mnt.XXXXXX", mnt_path));
72 dir_remover_.reset(new ScopedDirRemover(*mnt_path));
73
74 string loop_dev = GetUnusedLoopDevice();
75 EXPECT_EQ(0, system(StringPrintf("losetup %s %s", loop_dev.c_str(),
76 file_path.c_str()).c_str()));
77 loop_releaser_.reset(new ScopedLoopbackDeviceReleaser(loop_dev));
78
79 EXPECT_TRUE(utils::MountFilesystem(loop_dev, *mnt_path, flags));
80 unmounter_.reset(new ScopedFilesystemUnmounter(*mnt_path));
81 }
82 private:
83 scoped_ptr<ScopedDirRemover> dir_remover_;
84 scoped_ptr<ScopedLoopbackDeviceReleaser> loop_releaser_;
85 scoped_ptr<ScopedFilesystemUnmounter> unmounter_;
86};
87
88void CompareFilesByBlock(const string& a_file, const string& b_file) {
89 vector<char> a_data, b_data;
Andrew de los Reyes3270f742010-07-15 22:28:14 -070090 EXPECT_TRUE(utils::ReadFile(a_file, &a_data)) << "file failed: " << a_file;
91 EXPECT_TRUE(utils::ReadFile(b_file, &b_data)) << "file failed: " << b_file;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070092
93 EXPECT_EQ(a_data.size(), b_data.size());
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070094 EXPECT_EQ(0, a_data.size() % kBlockSize);
95 for (size_t i = 0; i < a_data.size(); i += kBlockSize) {
96 EXPECT_EQ(0, i % kBlockSize);
97 vector<char> a_sub(&a_data[i], &a_data[i + kBlockSize]);
98 vector<char> b_sub(&b_data[i], &b_data[i + kBlockSize]);
99 EXPECT_TRUE(a_sub == b_sub) << "Block " << (i/kBlockSize) << " differs";
100 }
101}
102
103namespace {
104bool WriteSparseFile(const string& path, off_t size) {
105 int fd = open(path.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0644);
106 TEST_AND_RETURN_FALSE_ERRNO(fd >= 0);
107 ScopedFdCloser fd_closer(&fd);
108 off_t rc = lseek(fd, size + 1, SEEK_SET);
109 TEST_AND_RETURN_FALSE_ERRNO(rc != static_cast<off_t>(-1));
110 int return_code = ftruncate(fd, size);
111 TEST_AND_RETURN_FALSE_ERRNO(return_code == 0);
112 return true;
113}
114}
115
116TEST(DeltaPerformerTest, RunAsRootSmallImageTest) {
117 string a_img, b_img;
118 EXPECT_TRUE(utils::MakeTempFile("/tmp/a_img.XXXXXX", &a_img, NULL));
119 ScopedPathUnlinker a_img_unlinker(a_img);
120 EXPECT_TRUE(utils::MakeTempFile("/tmp/b_img.XXXXXX", &b_img, NULL));
121 ScopedPathUnlinker b_img_unlinker(b_img);
122
123 CreateExtImageAtPath(a_img, NULL);
124 CreateExtImageAtPath(b_img, NULL);
125
Darin Petkov7ea32332010-10-13 10:46:11 -0700126 int image_size = static_cast<int>(utils::FileSize(a_img));
127
128 // Extend the "partitions" holding the file system a bit.
129 EXPECT_EQ(0, System(base::StringPrintf(
130 "dd if=/dev/zero of=%s seek=%d bs=1 count=1",
131 a_img.c_str(),
132 image_size + 1024 * 1024 - 1)));
133 EXPECT_EQ(0, System(base::StringPrintf(
134 "dd if=/dev/zero of=%s seek=%d bs=1 count=1",
135 b_img.c_str(),
136 image_size + 1024 * 1024 - 1)));
137 EXPECT_EQ(image_size + 1024 * 1024, utils::FileSize(a_img));
138 EXPECT_EQ(image_size + 1024 * 1024, utils::FileSize(b_img));
139
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700140 // Make some changes to the A image.
141 {
142 string a_mnt;
143 ScopedLoopMounter b_mounter(a_img, &a_mnt, 0);
144
145 EXPECT_TRUE(utils::WriteFile(StringPrintf("%s/hardtocompress",
146 a_mnt.c_str()).c_str(),
147 reinterpret_cast<const char*>(kRandomString),
148 sizeof(kRandomString) - 1));
149 // Write 1 MiB of 0xff to try to catch the case where writing a bsdiff
150 // patch fails to zero out the final block.
151 vector<char> ones(1024 * 1024, 0xff);
152 EXPECT_TRUE(utils::WriteFile(StringPrintf("%s/ones",
153 a_mnt.c_str()).c_str(),
154 &ones[0],
155 ones.size()));
156 }
157
158 // Make some changes to the B image.
159 {
160 string b_mnt;
161 ScopedLoopMounter b_mounter(b_img, &b_mnt, 0);
162
163 EXPECT_EQ(0, system(StringPrintf("cp %s/hello %s/hello2", b_mnt.c_str(),
164 b_mnt.c_str()).c_str()));
165 EXPECT_EQ(0, system(StringPrintf("rm %s/hello", b_mnt.c_str()).c_str()));
166 EXPECT_EQ(0, system(StringPrintf("mv %s/hello2 %s/hello", b_mnt.c_str(),
167 b_mnt.c_str()).c_str()));
168 EXPECT_EQ(0, system(StringPrintf("echo foo > %s/foo",
169 b_mnt.c_str()).c_str()));
170 EXPECT_EQ(0, system(StringPrintf("touch %s/emptyfile",
171 b_mnt.c_str()).c_str()));
172 EXPECT_TRUE(WriteSparseFile(StringPrintf("%s/fullsparse", b_mnt.c_str()),
173 1024 * 1024));
174 EXPECT_EQ(0, system(StringPrintf("dd if=/dev/zero of=%s/partsparese bs=1 "
175 "seek=4096 count=1",
176 b_mnt.c_str()).c_str()));
177 EXPECT_TRUE(utils::WriteFile(StringPrintf("%s/hardtocompress",
178 b_mnt.c_str()).c_str(),
179 reinterpret_cast<const char*>(kRandomString),
180 sizeof(kRandomString)));
181 }
182
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700183 string old_kernel;
184 EXPECT_TRUE(utils::MakeTempFile("/tmp/old_kernel.XXXXXX", &old_kernel, NULL));
185 ScopedPathUnlinker old_kernel_unlinker(old_kernel);
186
187 string new_kernel;
188 EXPECT_TRUE(utils::MakeTempFile("/tmp/new_kernel.XXXXXX", &new_kernel, NULL));
189 ScopedPathUnlinker new_kernel_unlinker(new_kernel);
190
191 vector<char> old_kernel_data(4096); // Something small for a test
192 vector<char> new_kernel_data(old_kernel_data.size());
193 FillWithData(&old_kernel_data);
194 FillWithData(&new_kernel_data);
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700195
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700196 // change the new kernel data
197 const char* new_data_string = "This is new data.";
198 strcpy(&new_kernel_data[0], new_data_string);
199
200 // Write kernels to disk
201 EXPECT_TRUE(utils::WriteFile(
202 old_kernel.c_str(), &old_kernel_data[0], old_kernel_data.size()));
203 EXPECT_TRUE(utils::WriteFile(
204 new_kernel.c_str(), &new_kernel_data[0], new_kernel_data.size()));
205
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700206 string delta_path;
207 EXPECT_TRUE(utils::MakeTempFile("/tmp/delta.XXXXXX", &delta_path, NULL));
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700208 LOG(INFO) << "delta path: " << delta_path;
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700209 ScopedPathUnlinker delta_path_unlinker(delta_path);
210 {
211 string a_mnt, b_mnt;
212 ScopedLoopMounter a_mounter(a_img, &a_mnt, MS_RDONLY);
213 ScopedLoopMounter b_mounter(b_img, &b_mnt, MS_RDONLY);
214
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700215 EXPECT_TRUE(
216 DeltaDiffGenerator::GenerateDeltaUpdateFile(a_mnt,
217 a_img,
218 b_mnt,
219 b_img,
220 old_kernel,
221 new_kernel,
222 delta_path,
223 kUnittestPrivateKeyPath));
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700224 }
225
226 // Read delta into memory.
227 vector<char> delta;
228 EXPECT_TRUE(utils::ReadFile(delta_path, &delta));
229
Darin Petkov73058b42010-10-06 16:32:19 -0700230 uint64_t manifest_metadata_size;
231
Darin Petkov36a58222010-10-07 22:00:09 -0700232 // Check the metadata.
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700233 {
234 LOG(INFO) << "delta size: " << delta.size();
235 DeltaArchiveManifest manifest;
236 const int kManifestSizeOffset = 12;
237 const int kManifestOffset = 20;
238 uint64_t manifest_size = 0;
239 memcpy(&manifest_size, &delta[kManifestSizeOffset], sizeof(manifest_size));
240 manifest_size = be64toh(manifest_size);
241 LOG(INFO) << "manifest size: " << manifest_size;
242 EXPECT_TRUE(manifest.ParseFromArray(&delta[kManifestOffset],
243 manifest_size));
244 EXPECT_TRUE(manifest.has_signatures_offset());
Darin Petkov73058b42010-10-06 16:32:19 -0700245 manifest_metadata_size = kManifestOffset + manifest_size;
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700246
247 Signatures sigs_message;
248 EXPECT_TRUE(sigs_message.ParseFromArray(
Darin Petkov73058b42010-10-06 16:32:19 -0700249 &delta[manifest_metadata_size + manifest.signatures_offset()],
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700250 manifest.signatures_size()));
251 EXPECT_EQ(1, sigs_message.signatures_size());
252 const Signatures_Signature& signature = sigs_message.signatures(0);
253 EXPECT_EQ(1, signature.version());
254
255 uint64_t expected_sig_data_length = 0;
256 EXPECT_TRUE(PayloadSigner::SignatureBlobLength(kUnittestPrivateKeyPath,
257 &expected_sig_data_length));
258 EXPECT_EQ(expected_sig_data_length, manifest.signatures_size());
259 EXPECT_FALSE(signature.data().empty());
Darin Petkov36a58222010-10-07 22:00:09 -0700260
Darin Petkov698d0412010-10-13 10:59:44 -0700261 // TODO(petkov): Add a test once the generator start sending old kernel
262 // info.
263 EXPECT_FALSE(manifest.has_old_kernel_info());
264
Darin Petkov36a58222010-10-07 22:00:09 -0700265 EXPECT_EQ(new_kernel_data.size(), manifest.new_kernel_info().size());
Darin Petkov7ea32332010-10-13 10:46:11 -0700266 EXPECT_EQ(image_size, manifest.old_rootfs_info().size());
267 EXPECT_EQ(image_size, manifest.new_rootfs_info().size());
Darin Petkov36a58222010-10-07 22:00:09 -0700268
Darin Petkov36a58222010-10-07 22:00:09 -0700269 EXPECT_FALSE(manifest.new_kernel_info().hash().empty());
270 EXPECT_FALSE(manifest.old_rootfs_info().hash().empty());
271 EXPECT_FALSE(manifest.new_rootfs_info().hash().empty());
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700272 }
273
Darin Petkov73058b42010-10-06 16:32:19 -0700274 PrefsMock prefs;
275 EXPECT_CALL(prefs, SetInt64(kPrefsManifestMetadataSize,
276 manifest_metadata_size)).WillOnce(Return(true));
277 EXPECT_CALL(prefs, SetInt64(kPrefsUpdateStateNextOperation, _))
278 .WillRepeatedly(Return(true));
Darin Petkov9b230572010-10-08 10:20:09 -0700279 EXPECT_CALL(prefs, GetInt64(kPrefsUpdateStateNextOperation, _))
280 .WillOnce(Return(false));
Darin Petkov73058b42010-10-06 16:32:19 -0700281 EXPECT_CALL(prefs, SetInt64(kPrefsUpdateStateNextDataOffset, _))
282 .WillRepeatedly(Return(true));
Darin Petkov437adc42010-10-07 13:12:24 -0700283 EXPECT_CALL(prefs, SetString(kPrefsUpdateStateSHA256Context, _))
Darin Petkov73058b42010-10-06 16:32:19 -0700284 .WillRepeatedly(Return(true));
Darin Petkov437adc42010-10-07 13:12:24 -0700285 EXPECT_CALL(prefs, SetString(kPrefsUpdateStateSignedSHA256Context, _))
286 .WillOnce(Return(true));
Darin Petkov73058b42010-10-06 16:32:19 -0700287
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700288 // Update the A image in place.
Darin Petkov73058b42010-10-06 16:32:19 -0700289 DeltaPerformer performer(&prefs);
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700290
291 EXPECT_EQ(0, performer.Open(a_img.c_str(), 0, 0));
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700292 EXPECT_TRUE(performer.OpenKernel(old_kernel.c_str()));
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700293
Darin Petkov698d0412010-10-13 10:59:44 -0700294 vector<char> rootfs_hash;
295 CHECK_EQ(image_size,
296 OmahaHashCalculator::RawHashOfFile(a_img, image_size, &rootfs_hash));
297 performer.set_current_rootfs_hash(&rootfs_hash);
298
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700299 // Write at some number of bytes per operation. Arbitrarily chose 5.
300 const size_t kBytesPerWrite = 5;
301 for (size_t i = 0; i < delta.size(); i += kBytesPerWrite) {
302 size_t count = min(delta.size() - i, kBytesPerWrite);
303 EXPECT_EQ(count, performer.Write(&delta[i], count));
304 }
305
306 // Wrapper around close. Returns 0 on success or -errno on error.
307 EXPECT_EQ(0, performer.Close());
308
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700309 CompareFilesByBlock(old_kernel, new_kernel);
Darin Petkov2dd01092010-10-08 15:43:05 -0700310 CompareFilesByBlock(a_img, b_img);
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700311
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700312 vector<char> updated_kernel_partition;
313 EXPECT_TRUE(utils::ReadFile(old_kernel, &updated_kernel_partition));
314 EXPECT_EQ(0, strncmp(&updated_kernel_partition[0], new_data_string,
315 strlen(new_data_string)));
Darin Petkovd7061ab2010-10-06 14:37:09 -0700316
317 EXPECT_TRUE(utils::FileExists(kUnittestPublicKeyPath));
Darin Petkov437adc42010-10-07 13:12:24 -0700318 EXPECT_TRUE(performer.VerifyPayload(
319 kUnittestPublicKeyPath,
320 OmahaHashCalculator::OmahaHashOfData(delta),
321 delta.size()));
Darin Petkov2dd01092010-10-08 15:43:05 -0700322 EXPECT_TRUE(performer.VerifyAppliedUpdate(a_img, old_kernel));
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700323}
324
Andrew de los Reyes27f7d372010-10-07 11:26:07 -0700325TEST(DeltaPerformerTest, NewFullUpdateTest) {
326 vector<char> new_root(20 * 1024 * 1024);
327 vector<char> new_kern(16 * 1024 * 1024);
328 const off_t kChunkSize = 128 * 1024;
329 FillWithData(&new_root);
330 FillWithData(&new_kern);
Darin Petkov7ea32332010-10-13 10:46:11 -0700331 // Assume hashes take 2 MiB beyond the rootfs.
332 off_t new_rootfs_size = new_root.size() - 2 * 1024 * 1024;
Darin Petkov437adc42010-10-07 13:12:24 -0700333
Andrew de los Reyes27f7d372010-10-07 11:26:07 -0700334 string new_root_path;
335 EXPECT_TRUE(utils::MakeTempFile("/tmp/NewFullUpdateTest_R.XXXXXX",
336 &new_root_path,
337 NULL));
338 ScopedPathUnlinker new_root_path_unlinker(new_root_path);
339 EXPECT_TRUE(WriteFileVector(new_root_path, new_root));
340
341 string new_kern_path;
342 EXPECT_TRUE(utils::MakeTempFile("/tmp/NewFullUpdateTest_K.XXXXXX",
343 &new_kern_path,
344 NULL));
345 ScopedPathUnlinker new_kern_path_unlinker(new_kern_path);
346 EXPECT_TRUE(WriteFileVector(new_kern_path, new_kern));
347
348 string out_blobs_path;
349 int out_blobs_fd;
350 EXPECT_TRUE(utils::MakeTempFile("/tmp/NewFullUpdateTest_D.XXXXXX",
351 &out_blobs_path,
352 &out_blobs_fd));
353 ScopedPathUnlinker out_blobs_path_unlinker(out_blobs_path);
354 ScopedFdCloser out_blobs_fd_closer(&out_blobs_fd);
Darin Petkov437adc42010-10-07 13:12:24 -0700355
Andrew de los Reyes27f7d372010-10-07 11:26:07 -0700356 off_t out_blobs_length = 0;
Darin Petkov437adc42010-10-07 13:12:24 -0700357
Andrew de los Reyes27f7d372010-10-07 11:26:07 -0700358 Graph graph;
359 vector<DeltaArchiveManifest_InstallOperation> kernel_ops;
360 vector<Vertex::Index> final_order;
Darin Petkov437adc42010-10-07 13:12:24 -0700361
Andrew de los Reyes27f7d372010-10-07 11:26:07 -0700362 EXPECT_TRUE(DeltaDiffGenerator::ReadFullUpdateFromDisk(&graph,
363 new_kern_path,
364 new_root_path,
Darin Petkov7ea32332010-10-13 10:46:11 -0700365 new_rootfs_size,
Andrew de los Reyes27f7d372010-10-07 11:26:07 -0700366 out_blobs_fd,
367 &out_blobs_length,
368 kChunkSize,
369 &kernel_ops,
370 &final_order));
Darin Petkov7ea32332010-10-13 10:46:11 -0700371 EXPECT_EQ(new_rootfs_size / kChunkSize, graph.size());
372 EXPECT_EQ(new_rootfs_size / kChunkSize, final_order.size());
Andrew de los Reyes27f7d372010-10-07 11:26:07 -0700373 EXPECT_EQ(new_kern.size() / kChunkSize, kernel_ops.size());
Darin Petkov7ea32332010-10-13 10:46:11 -0700374 for (off_t i = 0; i < (new_rootfs_size / kChunkSize); ++i) {
Andrew de los Reyes27f7d372010-10-07 11:26:07 -0700375 EXPECT_EQ(i, final_order[i]);
376 EXPECT_EQ(1, graph[i].op.dst_extents_size());
377 EXPECT_EQ(i * kChunkSize / kBlockSize,
378 graph[i].op.dst_extents(0).start_block()) << "i = " << i;
379 EXPECT_EQ(kChunkSize / kBlockSize,
380 graph[i].op.dst_extents(0).num_blocks());
381 if (graph[i].op.type() !=
382 DeltaArchiveManifest_InstallOperation_Type_REPLACE) {
383 EXPECT_EQ(DeltaArchiveManifest_InstallOperation_Type_REPLACE_BZ,
384 graph[i].op.type());
385 }
386 }
387}
388
Andrew de los Reyes353777c2010-10-08 10:34:30 -0700389TEST(DeltaPerformerTest, IsIdempotentOperationTest) {
390 DeltaArchiveManifest_InstallOperation op;
391 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op));
392 *(op.add_dst_extents()) = ExtentForRange(0, 5);
393 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op));
394 *(op.add_src_extents()) = ExtentForRange(4, 1);
395 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op));
396 op.clear_src_extents();
397 *(op.add_src_extents()) = ExtentForRange(5, 3);
398 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op));
399 *(op.add_dst_extents()) = ExtentForRange(20, 6);
400 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op));
401 *(op.add_src_extents()) = ExtentForRange(19, 2);
402 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op));
403}
404
Andrew de los Reyes09e56d62010-04-23 13:45:53 -0700405} // namespace chromeos_update_engine