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

Side by Side Diff: src/platform/update_engine/test_utils.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 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 "update_engine/test_utils.h" 5 #include "update_engine/test_utils.h"
6 #include <sys/stat.h> 6 #include <sys/stat.h>
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (a.size() != b.size()) 170 if (a.size() != b.size())
171 return false; 171 return false;
172 for (unsigned int i = 0; i < a.size(); i++) { 172 for (unsigned int i = 0; i < a.size(); i++) {
173 EXPECT_EQ(a[i], b[i]) << "offset: " << i; 173 EXPECT_EQ(a[i], b[i]) << "offset: " << i;
174 } 174 }
175 return true; 175 return true;
176 } 176 }
177 177
178 void CreateExtImageAtPath(const string& path, vector<string>* out_paths) { 178 void CreateExtImageAtPath(const string& path, vector<string>* out_paths) {
179 // create 10MiB sparse file 179 // create 10MiB sparse file
180 const char* const mount_path = kMountPath.c_str();
181 EXPECT_EQ(0, System(StringPrintf("dd if=/dev/zero of=%s" 180 EXPECT_EQ(0, System(StringPrintf("dd if=/dev/zero of=%s"
182 " seek=10485759 bs=1 count=1", 181 " seek=10485759 bs=1 count=1",
183 path.c_str()))); 182 path.c_str())));
184 EXPECT_EQ(0, System(StringPrintf("mkfs.ext3 -F %s", path.c_str()))); 183 EXPECT_EQ(0, System(StringPrintf("mkfs.ext3 -F %s", path.c_str())));
185 EXPECT_EQ(0, System(StringPrintf("mkdir -p %s", mount_path))); 184 EXPECT_EQ(0, System(StringPrintf("mkdir -p %s", kMountPath)));
186 EXPECT_EQ(0, System(StringPrintf("mount -o loop %s %s", path.c_str(), 185 EXPECT_EQ(0, System(StringPrintf("mount -o loop %s %s", path.c_str(),
187 mount_path))); 186 kMountPath)));
188 EXPECT_EQ(0, System(StringPrintf("echo hi > %s/hi", mount_path))); 187 EXPECT_EQ(0, System(StringPrintf("echo hi > %s/hi", kMountPath)));
189 EXPECT_EQ(0, System(StringPrintf("echo hello > %s/hello", mount_path))); 188 EXPECT_EQ(0, System(StringPrintf("echo hello > %s/hello", kMountPath)));
190 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir", mount_path))); 189 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir", kMountPath)));
191 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir/empty_dir", mount_path))); 190 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir/empty_dir", kMountPath)));
192 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir/mnt", mount_path))); 191 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir/mnt", kMountPath)));
193 EXPECT_EQ(0, System(StringPrintf("echo T > %s/some_dir/test", mount_path))); 192 EXPECT_EQ(0, System(StringPrintf("echo T > %s/some_dir/test", kMountPath)));
194 EXPECT_EQ(0, System(StringPrintf("mkfifo %s/some_dir/fifo", mount_path))); 193 EXPECT_EQ(0, System(StringPrintf("mkfifo %s/some_dir/fifo", kMountPath)));
195 EXPECT_EQ(0, System(StringPrintf("mknod %s/cdev c 2 3", mount_path))); 194 EXPECT_EQ(0, System(StringPrintf("mknod %s/cdev c 2 3", kMountPath)));
196 EXPECT_EQ(0, System(StringPrintf("ln -s /some/target %s/sym", mount_path))); 195 EXPECT_EQ(0, System(StringPrintf("ln -s /some/target %s/sym", kMountPath)));
197 EXPECT_EQ(0, System(StringPrintf("ln %s/some_dir/test %s/testlink", 196 EXPECT_EQ(0, System(StringPrintf("ln %s/some_dir/test %s/testlink",
198 mount_path, mount_path))); 197 kMountPath, kMountPath)));
199 EXPECT_EQ(0, System(StringPrintf("umount %s", mount_path))); 198 EXPECT_EQ(0, System(StringPrintf("umount %s", kMountPath)));
200 199
201 if (out_paths) { 200 if (out_paths) {
202 out_paths->clear(); 201 out_paths->clear();
203 out_paths->push_back(""); 202 out_paths->push_back("");
204 out_paths->push_back("/hi"); 203 out_paths->push_back("/hi");
205 out_paths->push_back("/hello"); 204 out_paths->push_back("/hello");
206 out_paths->push_back("/some_dir"); 205 out_paths->push_back("/some_dir");
207 out_paths->push_back("/some_dir/empty_dir"); 206 out_paths->push_back("/some_dir/empty_dir");
208 out_paths->push_back("/some_dir/mnt"); 207 out_paths->push_back("/some_dir/mnt");
209 out_paths->push_back("/some_dir/test"); 208 out_paths->push_back("/some_dir/test");
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 EXPECT_TRUE(expected_paths.empty()); 254 EXPECT_TRUE(expected_paths.empty());
256 if (!expected_paths.empty()) { 255 if (!expected_paths.empty()) {
257 for (set<string>::const_iterator it = expected_paths.begin(); 256 for (set<string>::const_iterator it = expected_paths.begin();
258 it != expected_paths.end(); ++it) { 257 it != expected_paths.end(); ++it) {
259 LOG(INFO) << "extra path: " << *it; 258 LOG(INFO) << "extra path: " << *it;
260 } 259 }
261 } 260 }
262 } 261 }
263 262
264 } // namespace chromeos_update_engine 263 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « src/platform/update_engine/test_utils.h ('k') | src/platform/update_engine/update_check_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698