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/install_action_unittest.cc

Issue 492008: AU: Try delta updates first, then full updates (Closed)
Patch Set: use mkstemp Created 11 years 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/stat.h> 5 #include <sys/stat.h>
6 #include <sys/types.h> 6 #include <sys/types.h>
7 #include <errno.h> 7 #include <errno.h>
8 #include <utime.h> 8 #include <utime.h>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 { 119 {
120 // Fill bigfile w/ some data in the new folder 120 // Fill bigfile w/ some data in the new folder
121 vector<char> buf(100 * 1024); 121 vector<char> buf(100 * 1024);
122 for (unsigned int i = 0; i < buf.size(); i++) { 122 for (unsigned int i = 0; i < buf.size(); i++) {
123 buf[i] = static_cast<char>(i); 123 buf[i] = static_cast<char>(i);
124 } 124 }
125 EXPECT_TRUE(WriteFileVector(new_dir + "/dir/bigfile", buf)); 125 EXPECT_TRUE(WriteFileVector(new_dir + "/dir/bigfile", buf));
126 } 126 }
127 const char* const new_dir_cstr = new_dir.c_str(); 127 const char* const new_dir_cstr = new_dir.c_str();
128 EXPECT_EQ(0, System(StringPrintf("mkdir -p '%s/newdir'", new_dir_cstr))); 128 EXPECT_EQ(0, System(StringPrintf("mkdir -p '%s/newdir'", new_dir_cstr)));
129 EXPECT_EQ(0, System(StringPrintf("chmod 03755 '%s/newdir'", new_dir_cstr)));
129 EXPECT_EQ(0, System(StringPrintf("mkdir -p '%s/newdir/x'", new_dir_cstr))); 130 EXPECT_EQ(0, System(StringPrintf("mkdir -p '%s/newdir/x'", new_dir_cstr)));
130 EXPECT_EQ(0, System(StringPrintf("echo -n foo > '%s/newdir/x/file'", 131 EXPECT_EQ(0, System(StringPrintf("echo -n foo > '%s/newdir/x/file'",
131 new_dir_cstr))); 132 new_dir_cstr)));
133 EXPECT_EQ(0, System(StringPrintf("touch '%s/new_empty'", new_dir_cstr)));
134 EXPECT_EQ(0, System(StringPrintf("chmod 04644 '%s/new_empty'",
135 new_dir_cstr)));
132 EXPECT_EQ(0, System(StringPrintf("echo -n x >> '%s/big_file'", 136 EXPECT_EQ(0, System(StringPrintf("echo -n x >> '%s/big_file'",
133 new_dir_cstr))); 137 new_dir_cstr)));
138 EXPECT_EQ(0, System(StringPrintf("chmod 02644 '%s/big_file'", new_dir_cstr)));
134 // Make a symlink that compresses well: 139 // Make a symlink that compresses well:
135 EXPECT_EQ(0, System(StringPrintf( 140 EXPECT_EQ(0, System(StringPrintf(
136 "ln -s " 141 "ln -s "
137 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 142 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
138 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 143 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
139 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " 144 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx "
140 "'%s/compress_sym'", new_dir_cstr))); 145 "'%s/compress_sym'", new_dir_cstr)));
141 146
142 // Make a device that will compress 147 // Make a device that will compress
143 EXPECT_EQ(0, mknod((new_dir + "/bdev_gz").c_str(), S_IFCHR | 0644, 0)); 148 EXPECT_EQ(0, mknod((new_dir + "/bdev_gz").c_str(), S_IFCHR | 0644, 0));
144 149
145 // Make a diff 150 // Make a diff
146 DeltaArchiveManifest* delta = 151 DeltaArchiveManifest* delta =
147 DeltaDiffGenerator::EncodeMetadataToProtoBuffer(new_dir.c_str()); 152 DeltaDiffGenerator::EncodeMetadataToProtoBuffer(new_dir.c_str());
148 EXPECT_TRUE(NULL != delta); 153 EXPECT_TRUE(NULL != delta);
149 EXPECT_TRUE(DeltaDiffGenerator::EncodeDataToDeltaFile(delta, 154 EXPECT_TRUE(DeltaDiffGenerator::EncodeDataToDeltaFile(delta,
150 original_dir, 155 original_dir,
151 new_dir, 156 new_dir,
152 "delta", 157 "delta",
158 set<string>(),
153 new_dir + "/bdev_gz")); 159 new_dir + "/bdev_gz"));
154 160
155 ASSERT_EQ(0, System(string("umount ") + original_dir)); 161 ASSERT_EQ(0, System(string("umount ") + original_dir));
156 162
157 ObjectFeederAction<InstallPlan> feeder_action; 163 ObjectFeederAction<InstallPlan> feeder_action;
158 InstallAction install_action; 164 InstallAction install_action;
159 ObjectCollectorAction<string> collector_action; 165 ObjectCollectorAction<string> collector_action;
160 166
161 BondActions(&feeder_action, &install_action); 167 BondActions(&feeder_action, &install_action);
162 BondActions(&install_action, &collector_action); 168 BondActions(&install_action, &collector_action);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 for (; !iter.IsEnd(); iter.Increment()) { 203 for (; !iter.IsEnd(); iter.Increment()) {
198 new_count++; 204 new_count++;
199 LOG(INFO) << "checking path: " << iter.GetPartialPath(); 205 LOG(INFO) << "checking path: " << iter.GetPartialPath();
200 EXPECT_TRUE(FilesEqual(original_dir + iter.GetPartialPath(), 206 EXPECT_TRUE(FilesEqual(original_dir + iter.GetPartialPath(),
201 new_dir + iter.GetPartialPath())); 207 new_dir + iter.GetPartialPath()));
202 } 208 }
203 EXPECT_FALSE(iter.IsErr()); 209 EXPECT_FALSE(iter.IsErr());
204 } 210 }
205 LOG(INFO) << "new_count = " << new_count; 211 LOG(INFO) << "new_count = " << new_count;
206 EXPECT_EQ(new_count, original_count); 212 EXPECT_EQ(new_count, original_count);
207 EXPECT_EQ(19, original_count); 213 EXPECT_EQ(20, original_count);
208 214
209 // Make sure hard-link installed properly 215 // Make sure hard-link installed properly
210 { 216 {
211 struct stat hard_link_stbuf; 217 struct stat hard_link_stbuf;
212 struct stat hi_stbuf; 218 struct stat hi_stbuf;
213 EXPECT_EQ(0, lstat((string(new_dir) + "/hard_link").c_str(), 219 EXPECT_EQ(0, lstat((string(new_dir) + "/hard_link").c_str(),
214 &hard_link_stbuf)); 220 &hard_link_stbuf));
215 EXPECT_EQ(0, lstat((string(new_dir) + "/hi").c_str(), &hi_stbuf)); 221 EXPECT_EQ(0, lstat((string(new_dir) + "/hi").c_str(), &hi_stbuf));
216 EXPECT_EQ(hard_link_stbuf.st_mode, hi_stbuf.st_mode); 222 EXPECT_EQ(hard_link_stbuf.st_mode, hi_stbuf.st_mode);
217 EXPECT_EQ(2, hard_link_stbuf.st_nlink); 223 EXPECT_EQ(2, hard_link_stbuf.st_nlink);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 270
265 InstallPlan install_plan(false, "", "", "no_such_file", "install_path"); 271 InstallPlan install_plan(false, "", "", "no_such_file", "install_path");
266 feeder_action.set_obj(install_plan); 272 feeder_action.set_obj(install_plan);
267 273
268 processor.StartProcessing(); 274 processor.StartProcessing();
269 EXPECT_FALSE(processor.IsRunning()) << "Update to handle async actions"; 275 EXPECT_FALSE(processor.IsRunning()) << "Update to handle async actions";
270 EXPECT_TRUE(collector_action.object().empty()); 276 EXPECT_TRUE(collector_action.object().empty());
271 } 277 }
272 278
273 } // namespace chromeos_update_engine 279 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « src/platform/update_engine/install_action.cc ('k') | src/platform/update_engine/integration_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698